Lab 5 V 1
Lab 5 V 1
1. (Nested list) In a diving competition, every diver makes 3 dive attempts. Each dive
attempt is awarded a score which is a value between 0 and 10, inclusive of 0 and
10. The diver with the best total wins.
You may assume that every diver will make 3 attempts (fixed). However, the
number of divers can vary.
b. Display the top 3 positions in descending order of the total score as follows:
Top three positions
Diver Total
6 28.2
3 27.6
4 27.4
The above represents 3 games played between player A and B. Based on the game
score, the score of the first game score is 21-11 in which Player A is the winner, etc.
The overall game score is 1-2 and player B is the winner.
It is possible that only 2 games are played with the game score, as shown in the
following example:
gameScore=[['A','B'],[21,1],[21,10]]
In this example, the overall game score is 2-0 and player A is the winner.
Player A vs B
Game 1 21-11
SINGAPORE UNIVERSITY OF SOCIAL SCIENCES (SUSS) ICT133 Lab – Page 1 of 4
Game 2 19-21
Game 3 11-21
Overall 1-2
Winner is player B
Since there are no game scores yet, the list consists of only the player names.
The scores are entered with a dash in between. Add each game score in score
list. Test out the function.
The currency and rate are added to the currs dictionary as a key value pair. If
the currency already exists in the dictionary, print ‘Currency already exists!’,
otherwise, proceed to include the currency in the dictionary.
d. Function adjustCurrency(currs).
The function should prompt user to input a currency, e.g.
SINGAPORE UNIVERSITY OF SOCIAL SCIENCES (SUSS) ICT133 Lab – Page 2 of 4
Enter currency: HKD
Rate is 5.73
Enter new rate: 5.77
HKD adjusted to 5.77
The program checks that the currency exists before prompting for new rate. A
message ‘Currency not found!’ should be displayed if the currency is not found.
4. (Dictionary, list) Write a program to manage a collection of student names and their
course marks. Course mark consists of 2 components – course work, and exam. Both
are of equal weightage. Implement the program as described:
a. Assume that student names have been read from a file. Use the following initial
dictionary structure:
marks = { 'John':[0,0], 'Jane':[0,0], 'Peter':[0,0], 'Joe':[0,0] }
Note that for each dictionary entry, name is the key and a list representing the
coursework and exam marks is the value.