Page 355 - Artificial Intellegence_v2.0_Class_9
P. 355

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
                       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<=a<=100:
                         print("grade is A")
                       elif 75<=a<=89.9:
                         print("grade is B")
                       elif 60<=a<=74.9:
                         print("grade is C")

                       elif 45<=a<=59.5:
                         print(" grade is D")
                       elif 33<=a<=44.9:
                         print("grade is E")
                       elif 0<=a<=32.9:

                         print("grade is F")
                       else:
                         print("Invalid marks")
                       Output:
                       Enter marks out of hundred:
                       68
                       Grade is C


                                                                               Python Practical Questions  353
   350   351   352   353   354   355   356   357   358   359   360