Page 37 - ipp11
P. 37

if choice == 1:
                                side = float(input("Enter the side length of the cube: "))
                                volume_cube = side ** 3
                                print("Volume of the Cube:", volume_cube)
                            elif choice == 2:
                                radius = float(input("Enter the radius of the sphere: "))
                                volume_sphere = (4 / 3) * pi * (radius ** 3)
                                print("Volume of the Sphere:", volume_sphere)
                            elif choice == 3:
                                radius = float(input("Enter the radius of the cylinder: "))
                                height = float(input("Enter the height of the cylinder: "))
                                volume_cyl = pi * (radius ** 2) * height
                                print("Volume of the Cylinder:", volume_cyl)
                            elif choice == 4:
                                radius = float(input("Enter the radius of the cone: "))
                                height = float(input("Enter the height of the cone: "))
                                volume_cone = (1 / 3) * pi * (radius ** 2) * height
                                print("Volume of the Cone:", volume_cone)
                            elif choice == 5:
                                print("Exiting the program.")
                                break
                            else:
                                print("Invalid choice! Please select a valid option (1-5).")
                 33.  Predict the output of the following code.                                               (4)

                     info = ["Sender", "Encode", "Channel", "Message", "Decode"]
                     info.extend(["Voice", "Receiver"])
                     info.reverse()
                     info.pop(4)
                     info.sort()
                     print(info.count("Message"))
                     print(info)
                Ans.  1
                     ['Decode', 'Encode', 'Message', 'Receiver', 'Sender', 'Voice']
                 34.  (a)  Write a Python program to store vehicle information like Registration Number, Model, Owner Name
                         and Price in a dictionary. The program should allow the user to input multiple vehicles’ details and
                         then display the information based on the Registration Number entered by the user.   (4)
                                                               OR
                      (b)  Predict the output of the following code.
                         teacher = {"Name": "Mehul Chawla", "Subject": "Science", "Experience": 10}
                        teacher["Qualification"] = "M.Sc"
                        teacher.pop("Experience")
                        print(teacher.get("Subject"))
                        print(teacher)
                Ans.  (a)  vehicles = {}
                        n = int(input("Enter the number of vehicles to store: "))
                        for _ in range(n):
                            reg_no = input("\n Enter Vehicle Registration Number: ")
                            model = input("Enter Vehicle Model: ")
                            owner = input("Enter Owner's Name: ")
                            price = float(input("Enter Vehicle Price: "))



                                                              M.7
   32   33   34   35   36   37   38   39   40   41   42