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 … Read more

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 … Read more

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 … Read more

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): … Read more

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): … Read more

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 … Read more

Copywrite © 2020-2025, CBSE Python,
All Rights Reserved