|

Input a number and check if the number is a prime or composite number Python Program

Input a number and check if the number is a prime or composite number Python Program   num = int(input(“Enter any number : “)) if num > 1: for i in range(2, num): if (num % i) == 0: print(num, “is NOT a PRIME number, it is a COMPOSITE number”) break else: print(num, “is a…

|

Determine whether a number is a perfect number an armstrong number or a palindrome Python Program

Determine whether a number is a perfect number an armstrong number or a palindrome Python Program   # Palindrome (12321 is Palindrome) number=int(input(“Enter any number:”)) num=number num1= number rev=0 while num>0: digit=num%10 rev=rev*10+digit num=int(num/10) if number==rev: print(number ,’is a Palindrome’) else: print(number , ‘Not a Palindrome’) # Armstrong number is equal to sum of cubes…

|

Python MySQL Connectivity Notes Class 12

Python MySQL Connectivity Notes Class 12   Interface Python with MySQL database Contents: ♦  Connecting SQL with Python ♦  Creating database connectivity application ♦  Performing insert, delete, update, queries ♦  Display data by using fetchone(), fetchall(),fetchmany(), rowcount()   Database connectivity Database connectivity refers to connection and communication between an application and a database system. The…

|

Informatics Practices Sample Paper Term 2 Class 12

Informatics Practices Sample Paper Term 2 Class 12   Sample Question Paper INFORMATICS PRACTICES (Code : 065) Maximum Marks: 35 Time: 2 hours General Instructions  The question paper is divided into 3 sections – A, B and C  Section A, consists of 7 questions (1-7). Each question carries 2 marks.  Section B,…

|

Create a CSV file by entering user-id and password, read and search the password for given userid

Create a CSV file by entering user-id and password, read and search the password for given userid # Python Program   import csv with open(“user_info.csv”, “w”) as obj: fileobj = csv.writer(obj) fileobj.writerow([“User Id”, “password”]) while(True): user_id = input(“enter id: “) password = input(“enter password: “) record = [user_id, password] fileobj.writerow(record) x = input(“press Y/y to…

|

Input a list of numbers and swap elements at the even location with the elements at the odd location Python Program

Input a list of numbers and swap elements at the even location with the elements at the odd location Python Program   # Program to input number list and swapping odd and even index elements    # Entering 5 element Lsit mylist = [] print(“Enter 5 elements for the list: “) for i in range(5):…

|

Input three numbers and display the largest/smallest number Python Program

Input three numbers and display the largest/smallest number Python Program # Python Program to input 3 numbers and display the largest number   #input first,Second and third number num1=int(input(“Enter First Number”)) num2=int(input(“Enter Second Number”)) num3=int(input(“Enter Third Number”)) #Check if first number is greater than rest of the two numbers. if (num1> num2 and num1> num3):…

|

Input two numbers and display the larger/smaller number Python Program

Input two numbers and display the larger/smaller number Python Program    # Python Program to input 2 numbers and display larger number   #input first number num1=int(input(“Enter First Number”)) #input Second number num2=int(input(“Enter Second Number”)) #Check if first number is greater than second if (num1>num2): print(“The Larger number is”, num1) else: print (“The Larger number…