lab4_21 Lab 4: Graded lab Problem 1 Write a python program to calculate the electricity bill. In your program, ask user to input the electricity consumption in units and calculate the total...

urgent. listed in the pdf


lab4_21 Lab 4: Graded lab Problem 1 Write a python program to calculate the electricity bill. In your program, ask user to input the electricity consumption in units and calculate the total electricity bill according to the given condition: 1) For first 50 units, the charge is $0.25/unit 2) For next 100 units, the charge is $0.5/unit 3) For next 100 units, the charge is $1/unit 4) For units above 250, the charge is $2/unit 5) An additional surcharge of 20% is added to the bill. For example, if the consumption is 250 units, surcharge is: (50*.25 + .5*100 + 1*100)*20/100 Test your program for five test cases and save your program as a python file with the name electricity.py Problem 2 Harshad/Niven number: A number that is divisible by the sum of its own digits. For example, 1729 is a Harshad number because 1 + 7 + 2 + 9 = 19 and 1729 = 19 × 91. On the contrary, 1727 is not a Harshad number because 1+7+2+7 = 17 and 1727 is not divisible by 17. Write a function is_harshad(n) that takes a number n as a parameter and returns True if n is a Harshad/Niven number otherwise returns False. Ask the user to input a positive number outside the function and invoke is_harshad function to check whether it is a Harshad/Niven number. If the number is a Harshad/Niven number, print the message ‘[n] is a harshad number’ otherwise print the message ‘[n] is not a harshad number’. The program should behave as follows: Run 1 Enter a positive number: 1729 1729 is a harshad number Run 2 Enter a positive number: 1727 1727 is not a harshad number Save your program as a python file with the name is_harshad.py What to hand in Upon completion of your laboratory, create a folder by your last name, copy your python scripts(electricity.py and is_harshad.py) inside the folder. Then create a zip file(your_last_name.zip) and upload the zip file in the moodle.
Oct 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here