Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

PYTHON PROGRAMMING

Assignment-2
Guidelines:
1. Attempt all the questions.
2. Assignment consists of 3 questions of 10 marks each.
3. Last Date of Submission is 31st August 2020.
4. For assignment submission, create one folder with format
‘Section(RollNo)_RegistrationNo._Name’ and submit it through UMS only. Do create
separate python file within the main folder for individual question.
5. Assignment should be submitted as python supported file only.
6. For checking the assignment SET of yours, go through the following table( strictly follow
this else you will be marked zero).

SET No. Roll No.


1 1,8,15,22,29,36,43,50,57,64,71
2 2,9,16,23,30,37,44,51,58,65,72
3 3,10,17,24,31,38,45,52,59,66
4 4,11,18,25,32,39,46,53,60,67
5 5,12,19,26,33,40,47,54,61,68
6 6,13,20,27,34,41,48,55,62,69
7 7,14,21,28,35,42,49,56,63,70
Python Programming
Assignment 2
SET- 1
1. Create a python function ‘assign_grade(list)’ which records the marks of ten students from a
list and con the following conditions: If marks>=90 then
grade A
If marks >=80 &&<90 then grade B
If marks >65 &&<80 then grade C
If marks>=40 &&<=65 then grade D
If marks <40 then grade E
Consider the list of marks of 10 students in Biology.

2. Print the following pattern using loops. Create your own logic, do not try to print pattern using
print() statements.

3. An ATM contains Indian currency notes of 100, 500 and 2000. To withdraw cash from
this ATM, the user has to enter the number of notes he/she wants of each currency, i.e. of 100,
500 and 2000. Write a python program to calculate the total amount withdrawn by the person
from the ATM in rupees.
SET- II
1. Write a program to calculate an Internet browsing bill. Use the conditions specified as
follows:
a. 1 hour-Rs 40
b. ½ hour- Rs 20
c. For unlimited hours in a day- Rs 200
The owner should enter the number of hours spent on browsing.
2. Print the following pattern using loops. Create your own logic, do not try to print pattern
using print() statements.

3. Make a list of 5 communicable diseases, then using the slice operation do the following
operations.
a. Print the first three values from the list
b. Print any two values from the middle.
c. Print the letters from any particular index to the end of the list.
d. Print the list in sorted order and then reverse it.
SET- III
1. Write the python code to print appropriate message depending upon the value of the
variables temperature and humidity as given as follows. Assume that the temperature can only be
warm and cold and the humidity can only be dry and humid.

If temperature is If humidity is Print this activity


Warm Dry Play Basketball
Warm Humid Play Tennis
Cold Dry Play Cricket
Cold Humid Swim

2. Write a program that has a dictionary of state name (as keys) and their population (as
values). Print the items in the dictionary in a sorted order of population. Prompt the user
to enter a name and check if it is present in the dictionary. If the name does not exist, then
ask the user to enter population. Add the details in the dictionary. Also implement various
methods on dictionaries.
3. Create a python function ‘bill(list)’ which records the bill amount of last fivemonths from
a list and assign a category based on the following conditions:
If bill_amount>=10000 then category A
If bill_amount>=8000&&<10000 then category B
If bill_amount>6000&&<8000 then category C
If bill_amount>=4000&&<=6000 then category D
If bill_amount<4000 then category E
SET-IV
1. Print the following pattern using loops. Create your own logic, do not try to print pattern
using print() statements.

2. Write a program that displays a menu and its price. Take the order from the customer.
Check if the ordered product is in the menu. In case it is not there, the customer should be asked
to reorder and if it is present, then product should be added in the bill.

3. Write a program that has a dictionary of cars name (as keys) and their price (as values).
Print the items in the dictionary in a sorted order. Prompt the user to enter a name and check if it
is present in the dictionary. If the name does not exist, then ask the user to enter price. Add the
details in the dictionary.
SET-V
1. Consider a scenario where a son eats five ice creams every day. The price of each ice
cream is different. His mother pays the bill to the ice cream vendor at the end of every
week. Write a python program that can generate the bills for the ice creams and send to
his mother.
2. Make a list of last 10 letters of alphabets, then using the slice operation do the following
operations.
e. Print the first five letters from the list
f. Print any three letters from the middle.
g. Print the letters from any particular index to the end of the list.
3. Write a program that has a dictionary of books name (as keys) and their price (as values).
Print the items in the dictionary in a sorted order. Prompt the user to enter a name and
check if it is present in the dictionary. If the name does not exist, then ask the user to
enter price. Add the details in the dictionary.

SET-VI
1. Print the following pattern using using loops. Create your own logic, do not try to print
pattern using print() statements.

2. Write a program to generate and print all possible combinations of the characters present
in a given string. Take length of string = 4 e.g. JOHN will have combinations
JONH, JNOH…………

3. Write a program to calculate electricity bill based on following information:

SET-VII
1. Print the following pattern using using loops. Create your own logic, do not try to print pattern
using print() statements.

2. Write a program to calculate the parking charges of a vehicle. Enter the type of vehicle as a
character (like c for car, b for bus, etc.) and read the hours and minutes when the vehicle enters
the parking lot. When the vehicle is leaving, enters its leaving time. Calculate the difference
between the two timings to calculate the number of hours and minutes for which the vehicle was
parked. Calculate the charges based on the following information:
Vehicle Name Rate till 3 hours Rate after 3 hours
Truck / bus Rs 20 30
Car Rs 10 20
Scooter /cycle/ Motor cycle Rs 5 10
3. Write a program that encrypt a message by adding a key value to every character. (Caesar
Cipher) hint if key = 3, then add 3 to every character
Example: input=’hello hello’
Output=’khoor#khoor’
Replace space with #

You might also like