The document contains Python code snippets for various basic programming tasks including addition of two numbers, calculating the area and perimeter of a rectangle, checking voting eligibility, determining if a number is positive, negative, or zero, and finding the maximum value among two or three numbers. It demonstrates user input handling and conditional statements. The code is structured in a way that allows for interactive execution in a Python environment.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
37 views27 pages
Python Revision Tour 1 12th March 2025
The document contains Python code snippets for various basic programming tasks including addition of two numbers, calculating the area and perimeter of a rectangle, checking voting eligibility, determining if a number is positive, negative, or zero, and finding the maximum value among two or three numbers. It demonstrates user input handling and conditional statements. The code is structured in a way that allows for interactive execution in a Python environment.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27
a=int(input("Enter First Number:"))
b=int(input("Enter Second Number:"))
c=a+b print("Addition=",c) ord("A") 65 ord("Z") 90 ord("0") 48 chr(65) 'A' chr(98) 'b' #Add two numbers a=int(input("Enter First Number:")) #Total Marks and Percentage b=int(input("Enter Second Number:")) m1=int(input("Enter First Marks:")) c=a+b m2=int(input("Enter Second Marks:")) print("Addition=",c) m3=int(input("Enter Third Marks:")) m4=int(input("Enter Fourth Marks:")) m5=int(input("Enter Fifth Marks:")) total=m1+m2+m3+m4+m5 #Area of rectangle print("Total Marks=",total) length=int(input("Enter Length:")) per=total/5 wid=int(input("Enter Width:")) print("Perimeter=",per) area=lenght*wid print("Area of rectangle=",area) per=2*(length+wid) print("Perimeter=",per) #voting #Odd Even age=int(input("Enter Age:")) num=int(input("Enter Number to Check:")) if age>=18: if num%2==0: print("Eligible for Voting...") print("Even Number") else: else: print("Not Eligible for Voting...") print("Odd Number")
#Positive Negative Zero #max between two
num=int(input("Enter Number to Check:")) a=int(input("Enter First Number:")) if num>0: b=int(input("Enter Second Number:")) print("Positive") if a>b: elif num<0: print("Max Value=",a) print("Negative") else: else: print("Max Value=",b) print("Zero") #max between three a=int(input("Enter First Number:")) b=int(input("Enter Second Number:")) c=int(input("Enter Third Number:")) if a>b and a>c: print("Max Value=",a) elif b>a and b>c: print("Max Value=",b) else: print("Max Value=",c)