Page 269 - Robotics and AI class 10
P. 269

16.  Write a Python program to calculate the electricity bill. Accept the last meter reading and current meter
                 reading and the rate per unit from the user. Calculate the number of units and total bill consumption for
                 the user.
              Ans.   Calls                Rate
                 First 100                Free

                 Next 50                  Rs. 1 per unit
                 Next 100                 Rs. 1.50 per unit

                 Above this               Rs. 2 per unit

                 Unit=int(input("Enter the number of calls: "))
                 if(Units<=100):

                   Bill=0
                 elif(Units<=150):

                   Bill=Units-100
                 elif(Units<=250):

                   Bill=(Units-150)*1.50+100
                 elif(calls>250):

                   Bill=(Units-250)*2+150+100;
                 print("You have to pay Rs.",Bill)
                 Output:

                 Enter the number of units consumed: 180
                 Your electricity bill is Rs. 130.0

              17.  A company decided to give bonus of 5% to an employee if his/her year of service is more than 5 years. Write
                 a Python program to ask the user for their salary and year of service and print the net bonus amount.

              Ans.   salary = float(input("Enter your salary: "))
                 years_of_service = int(input("Enter your years of service: "))

                 # Calculate the bonus amount
                 if years_of_service > 5:

                    bonus_amount = 0.05* salary
                    print("Congratulations! You are eligible for Bonus Amount of :", bonus_amount)

                 else:

                    print("Sorry, you do not qualify for a bonus.")
                 Output:
                 Enter your salary: 40000
                 Enter your years of service: 7

                 Congratulations! You are eligible for Bonus Amount of : 2000.0




                                                                                     Viva Voce Questions   267
   264   265   266   267   268   269   270   271   272   273   274