Dremendo Tag Line

Input calls and calculate telephone bill in Python

if elif - Question 12

In this question, we will see how to calculate and display the monthly telephone bill along with total numbers of calls and monthly rental in Python programming using the if elif statement. To know more about if elif statement click on the if elif statement lesson.

Q12) A telephone company charges for using telephone from their consumers according to the calls made (per month) as per the given tariff:

Numbers of calls Charge
Up to 50 calls No charge (free)
For next 100 calls exceeding 50 call Rs. 2 per call
For next 200 calls exceeding 150 call Rs. 1.50 per call + Previous 100 calls bill amount
More than 350 calls Rs. 1 per call + Previous 200 calls bill amount + previous 100 calls bill amount

However, monthly rental charge is Rs.180/- per month for all the consumers for using Telephones. Write a program in Python to calculate and display the monthly telephone bill along with total numbers of calls and monthly rental.

Program

mr=180
call=int(input('Enter total number of calls '))

if call<=50:
     bill=0
elif call>50 and call<=150:
     bill=(call-50)*2
elif call>150 and call<=350:
     bill=(call-150)*1.5+(100*2)
else:
     bill=(call-350)*1+(200*1.5)+(100*2)

print('Total Calls = {}'.format(call))
print('Total Calls Charges = {:.2f}'.format(bill))
print('Fixed Monthly Rental = {}'.format(mr))
print('Total Bill Amount = {:.2f}'.format(bill+mr))

Output

Enter total number of calls 243
Total Calls = 243
Total Calls Charges = 339.50
Fixed Monthly Rental = 180
Total Bill Amount = 519.50
video-poster