Page 439 - Ai_417_V3.0_C9_Flipbook
P. 439
S. No. Program
16 Create a list List_1=[10,20,30,40]. Add the elements [14,15,12] using the extend function. Now
sort the final list in ascending order and print it.
List_1=[10,20,30,40]
List_1.extend([14,15,12])
List_1=sorted(List_1)
print(List_1)
Output:
[10, 12, 14, 15, 20, 30, 40]
17 Program to check if a person can vote or not.
Age=int(input("Enter Age : "))
if Age>=18:
print("The person can vote")
else:
print("The person cannot vote")
print("Wait for ",18-Age, "years")
Output:
Enter Age: 18
The person can vote
Enter Age: 15
The person cannot vote
Wait for 3 years
18 To check the grade of a student
marks=float(input("Enter marks out of hundred:\n"))
if 90<=marks<=100:
print("Grade is A")
elif 75<=marks<=89.9:
print("Grade is B")
elif 60<=marks<=74.9:
print("Grade is C")
elif 45<=marks<=59.5:
print("Grade is D")
elif 33<=marks<=44.9:
print("Grade is E")
elif 0<=marks<=32.9:
print("Grade is F")
else:
print("Invalid Marks")
Output:
Enter marks out of hundred:
68
Grade is C
Python Practical Questions 437

