PLC - Python
PLC - Python
Mark CO PO
S
1. List any 2 rules to frame variable names. ldentify whether the following are 2 2
valid or invalid variable names. Justify your answer if they are
a. 78Python b. first name
invalid.
c. false
Identify errors in the below given code fragments. Justify why python 06
throws an error and write the output for the corrected python code.
X=100
a y=300
1f x>y b
X-y=X X<y:
elsif: icx i range (x, y, 10) :
print (y) printf(i)
x=X+20
print (z)
4 a) With a suitable example illustrate the syntax and working of while loop. 4+3 2
10
6. Consider the below scenario: There are 5 users for whom electricity bill has
to be generated based on the units consumed per month. Every user will be
chargeda meter charge of Rs.250. The bill is generated based on the below
categories of units consumed by the user:
First 100 units are charged as Rs.5 per unit.
For the next 100 units, Rs. 10 per unit.
For Units exceeding 200, Rs. 15 per unit. number of
Write a python program to read the user name. Bill Id and the
units consumed. Calculate the total bill amount for each user.
OR
10 3 3
7. Consider the following scenario: John is a travel enthusiast. He loves to
travel different places every month. This month, he has a plan to travel to 5
different places. Write a program to input the name of the place and the
amount required to visit that place from the user. Compute the total required
travel amount. His bank offers him travel discounts as follows:
If the total amount is between 10000 to 20000. 7% discount.
Ifthe total amount is between 20000 to 25000, 12%discount.
Ifthe total amount is between 25000 to 30000, 17% discount.
If the total amount is above 30000, 20% discount.
Find the net amount spent by John.