Xi Ip Sa1 Practical File Que With Ans
Xi Ip Sa1 Practical File Que With Ans
Yr[2022-23]
Informatics Practices
Practical File
PROGRAM 1:
A) DESCRIPTION:
Write a Menu driven python program to accepts two integers and do all
arithmetic operations (+ , - ,*,/,//,**).
SOURCE CODE:
#PROGRAM TO DO ARITHMETIC OPERATIONS
print("1.Addition +")
print("2.Subraction -")
print("3.Multiplication *")
print("4.Division /")
print("5.Floor Division //")
print("6.Exponentiation **")
choice=input("Enter Your choice [ +,-,*,/,//,**]")
Num1=int(input("Enter First Number:"))
Num2=int(input("Enter Second Number:"))
if choice=='+':
result=Num1+Num2
elif choice=='-':
result=Num1-Num2
elif choice=='*':
result=Num1*Num2
elif choice=='/':
result=Num1/Num2
elif choice=='//':
result=Num1//Num2
elif choice=="**":
result=Num1**Num2
else:
print("Invalid Choice")
print("The Result is", result)
Lalaji Memorial Omega International School Aca.Yr[2022-23]
PROGRAM 2:
A) DESCRIPTION:
Write a python program to accept a character from the user and display
whether it is a vowel or consonant.
SOURCE CODE:
B) DESCRIPTION:
SOURCE CODE:
PROGRAM 3:
A) DESCRIPTION:
Write a python program that inputs a student’s marks in five subjects (out of
100) and prints the total and average and display the grade based on the average of
the marks.
Average Grade
>=90 A
>=80 and <90 B
>=70 and <80 C
>=60 and <70 D
Other E
SOURCE CODE:
# Write Python code to display Total, Average and
Grade.
Eng=int(input("Enter marks of the first subject: "))
IIlang=int(input("Enter marks of the second subject: "))
Math=int(input("Enter marks of the third subject: "))
Sci=int(input("Enter marks of the fourth subject: "))
Soc=int(input("Enter marks of the fifth subject: "))
tot=Eng+IIlang+Math+Sci+Soc
avg=int(tot/5)
print("Total Marks :",tot)
print("Average:",avg)
if(avg>=90):
print("Grade: A")
elif(avg>=80&avg<90):
print("Grade: B")
elif(avg>=70&avg<80):
print("Grade: C")
elif(avg>=60&avg<70):
print("Grade: D")
else:
print("Grade: E")
Lalaji Memorial Omega International School Aca.Yr[2022-23]
PROGRAM 4:
A) DESCRIPTION:
SOURCE CODE:
#PROGRAM TO FIND AREA OF SQUARE
Num1=int(input("Enter SIDE:"))
area=side*side
B) DESCRIPTION:
Where, A is amount P is the principal amount R is the rate and T is the time span
Input: Principle (amount): 1200, Time: 2, Rate: 5.4
Output: Compound Interest = 133.099243
SOURCE CODE:
#PROGRAM TO FIND Compound Interest
time=int(input("Enter time:"))
Amt=principal*((1+rate/100)**time)
CI=Amt-principal
PROGRAM 5:
A) DESCRIPTION:
SOURCE CODE:
#PROGRAM TO FIND Simple Interest
time=int(input("Enter time:"))
SI=principal*rate*time/100
B) DESCRIPTION:
SOURCE CODE:
#PROGRAM TO CHECK ELIGIBILITY TO VOTE
if Age>=18:
else:
PROGRAM 6:
A) DESCRIPTION:
SOURCE CODE:
#PROGRAM TO CHECK ODD OR EVEN
if Num%2==0:
else:
B) DESCRIPTION:
Write a python program to find largest number among three integers using
nested if statement.
SOURCE CODE:
#PROGRAM TO FIND LARGEST OF THREE NUMBERS
Num1=int(input("Enter Number1 :"))
Num2=int(input("Enter Number2 :"))
Num3=int(input("Enter Number3 :"))
if (Num1>Num2):
if(Num1>Num3):
print(Num1,"is the largest number")
else:
print(Num3,"is the largest number")
else:
if(Num2>Num3):
print(Num2,"is the largest number")
else:
print(Num3,"is the largest number")
Lalaji Memorial Omega International School Aca.Yr[2022-23]
PROGRAM 7:
A) DESCRIPTION:
Write a python program to check entered number is positive or negative.
SOURCE CODE:
# Program to find positive or negative number
num=int(input("Enter Any Number:"))
if(num>0):
print("Number is positive")
elif(num<0):
print("Number is negative")
else:
print("Number is Zero")
B) DESCRIPTION:
Write a python program to print roots of a quadratic equation ax2 + bx +c=0
(where a≠0).Inputs: a=1 b= -5 c=6 Output: root1=3.0 root2=2.0
SOURCE CODE:
print("Equation: ax^2 + bx + c ")
a=int(input("Enter a: "))
b=int(input("Enter b: "))
c=int(input("Enter c: "))
d=b**2-4*a*c
d1=d**0.5
if(d<0):
print("The roots are imaginary. ")
else:
r1=(-b+d1)/2*a
r2=(-b-d1)/2*a
print("The first root: ",r1)
print("The second root: ",r2)