Shree Swaminarayan Academy
Python Programming
Std : IX(A.I.)
I Sem
Python coding
Portion
(Part –I)
Dimple Patel –TGT I.T. /A.I. Page 1
Shree Swaminarayan Academy
Program 1: Program to get your name , age and then print it.
name= input("Enter your Name:")
age= input("Enter your Age:")
print(name)
print(age)
p: school name and add
Program 2: Program to print the sum of two numbers using int() function:
num1=int(input("enter no. 1 ="))
num2=int(input("enter no. 2 ="))
sum = num1 + num2
print(sum)
P: / , %
Program 3: Program to print the product of two numbers using int() function:
num1=int(input("enter value 1"))
num2=int(input("enter value 2"))
product=num1*num2
print("the product of 2 no. is", product)
Program 4: Program to find the average of three numbers.
num1=int(input("enter any no."))
num2=int(input("enter any no."))
num3=int(input("enter any no."))
total = num1 + num2 + num3
avg = total/3
print("the sum is ",total)
print("the avg is ",avg)
Program 5: Program to convert Kilogram into Grams.
Dimple Patel –TGT I.T. /A.I. Page 2
Shree Swaminarayan Academy
kg=int(input("enter kg"))
gm=kg*1000
print("total gm is",gm)
P: mL TO L
Program 6: Program to calculate area of a rectangle.
length=int(input("enter length of rectangle"))
breadth=int(input("enter breadth of rectangle"))
area=length*breadth
print("the area of rectangle ",area)
P: FIND AREA OF SQUARE
Program 7: Program to check if the given number is negative.
num= -2
if num<0:
print("Number is negative")
P: USE ==,!=
P: use Float data type
P: you are to old
Program 8: Program to print the largest between the two numbers.
Num1=45
Num2=85
if num1>num2:
print("num1 is greater than num2")
else:
print("num2 is greater than num1")
P:Enter value during run time for num1 and num2 and do program
P:age>=50
Dimple Patel –TGT I.T. /A.I. Page 3
Shree Swaminarayan Academy
Pg: 215
Program 9: Program to check whether you are eligible to vote or not.
age=int(input("enter your age"))
if age >=18 :
print ("you are eligible to vote")
else:
print("you are not eligible to vote")
Program 10: Program to check whether the shape is square or rectangle
based on dimension.
l=int(input("enter length"))
b=int(input("enter breadth"))
if l==b :
print("it is square")
else :
print("it is rectangle")
Program 11: Program to check whether the market or school is near by home.
dis1=int(input("Enter the distance of home to market "))
dis2=int(input("Enter the distance of home to school "))
if dis1<dis2 :
print("Market is near by Home")
else :
print("School is near by Home")
Program 12: Program to check whether a triangle is equilateral or not.
angle1=int(input("Enter First Angle"))
angle2=int(input("Enter second Angle "))
angle3=int(input("Enter third Angle "))
if angle1== angle2== angle3 :
print("it is an equilateral triangle")
else :
Dimple Patel –TGT I.T. /A.I. Page 4
Shree Swaminarayan Academy
print("it is not an equilateral triangle")
Program 13: Program to print lesser weight between two kids.
kid1=int(input("Enter the weight of the First Kid: "))
kid2=int(input("Enter the weight of the Second Kid: "))
if kid1<kid2:
print ("The weight of Kid 1 is Lesser than Kid 2")
else :
print ("The weight of Kid 2 is Lesser than Kid 1")
P:> , =
Program 14: Program to check whether the given letter is vowel or a
consonant.
alpha=input("Enter any letter")
if alpha =='a' or alpha =='e' or alpha =='i' or alpha =='o' or alpha =='u':
print("it is a vowel")
else:
print("it is a consonant")
p: !=
Program 15: Program to input the marks from users and print the grades
accordingly.
marks=int(input("enter your marks"))
if marks>=90 :
print ("grade A")
elif marks>=80 :
print ("grade B")
elif marks>=70 :
print ("grade C")
elif marks>=60 :
print("grade D")
else :
print("grade E")
Dimple Patel –TGT I.T. /A.I. Page 5
Shree Swaminarayan Academy
Program 16: Program to print either number entered by the user is negative,
positive or zero.
num=int(input("enter any no."))
if num>0 :
print("no. is positive")
elif num<0 :
print("no. is negative")
else :
print("no. is zero")
Program 17: Program to print kid , teenager,adult or [Link] by entering age.
age=int(input("enter your age "))
if age<12 :
print("kid")
elif age<18 :
print("teenager")
elif age<60 :
print("adult")
else :
print("senior citizen")
Also refer Text Book Programs. (5.1)
Dimple Patel –TGT I.T. /A.I. Page 6