Python Labsheet
Python Labsheet
1.
2.
2^12 = 4096
Note : to calculate 2^5 in python we need to use the following expression 2**5
3.
Write a program to input a series of marks from the keyboard. Calculate and find the Average of
the numbers. The user can stop entering values by entering 0.
4.
Modify the above program to prevent users from entering negative or marks above 100 by
making use of the continue statement.
6.
A list called heightList has the heights of the students in a class. If you assemble the students
according to the height, write a program to calculate the height of the student who is exactly in
the middle of the line.
Hint : You may need to use the sort function.
e.g heightList = [5.3, 4.2, 4.8, 5.1, 4.9]
7.
A string called emailstring has a list of email addresses separated by semi colons. Write a
program to extract the email addresses and print them.
Hint : store them into a list and then print them.
e.g. emailString = [email protected]; [email protected]; [email protected]; [email protected]
8.
A certain credit card company has a promotion for existing customers to introduce new
members.
Prizes are given to the customers depending on the number of new members they introduce.
For example if a customer has introduced 6 people. Then he/she is entitled to a Wrist Watch,
Umbrella and a bag.
New Member
1
3
5
10
15
Prize
Wrist Watch
Umbrella
Bag
Mini TV Set
DVD Player
Write a program to input the number of new members a customer has introduced and print the
prizes the customer is entitled to.
Sample Dialog
Enter number of customers introduced : 6
Your prizes are a Wrist Watch, Umbrella, Bag