Lab III – 28.12.
2020 By- Aditya Raj
a. Write a program to sum the series
i. 12 /1 + 22 / 2 + 32 / 3+………. n2 /n.
ii. – x + x2 – x3 + x4 + …
iii. 1 + (1+2) + (1+2+3) + … i
iv. 1 – x + x2 / 2! – x3 / 3! + …
b. Write a program that prompts the user to enter five words. If the length of any word is less than 6
characters, then it asks the user to enter it again. However, if the word is of 6 or more characters, then
it displays it on the screen.
c. Write a program to calculate electricity bill based on following information
Consumption Unit Rate of charge
0-150 Rs 3 per Unit
151-350 Rs 100 plus Rs3.75 per Unit exceeding
150 units
301-450 Rs 250 plus Rs 4 per unit exceeding 350
units
451-600 Rs 300 plus Rs 4.25 per unit exceeding
450 units
Above 600 Rs 400 plus Rs 5 per unit exceeding 600
units
d. Write a program to calculate parking charges of a vehicle. Read the hours and minutes when the vehicle
enters the parking lot. When the vehicle is leaving enter its leaving time. Calculate the difference
between the two timings to calculate the number of hours and minutes for which the vehicle was
parked.
Vehicle Name Rate till 3 hours Rate after 3 hours Finally
Truck / bus 20 30
Car 10 20
Cycle/Motor cycle/Scooter 5 10
calculate the charges based on following rules and then display the result on the screen.
e. Write a program that accepts the current date and date of birth of the user. Then calculate the age of
the user and display it on the screen. Note that the date should be displayed in the following format
specified as dd/mm/yy.
f. Write a program to read month of the year as an integer. Then display the name of the month.
g. Write a program to read a 5-digit number and then display the number in the following formats…for
example, if the user entered 12345, the result should be
12345 1
2345 12
345 123
45 1234
5 12345
h. Write a simple python program the displays the following powers of 2, one per line:21, 22, 23, 24, 25,
26, 27, 28.
i. Write a program to generate the following pattern.
j. Write programs to implement the following sequence of numbers.
1, 8, 27, 64, … -5, -2, 0, 3, 6, 9, 12, …
-2, -4, -6, -8, -10, -12, … 1, 4, 7, 10, …
k. An employee’s total weekly pay is calculated by multiplying the hourly wage and number of
regular hours plus any overtime pay which in turn is calculated as total overtime hours
multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage,
total regular hours and total overtime hours and prints an employee’s total weekly pay.