Page 348 - Computer Science Class 11 With Functions
P. 348
36 objective: To update result of all students
37 Global data:
38 result: list of lists of result of all students
39 Return value: None
40 Side effect: List classResult gets updated
41 '''
42 #Update result
43 #Accept roll number and updated marks interactively
44 print('Continue to update the result?')
45 moreUpdates = input('Say Y/y for yes, N/n for no:')
46
47 while moreUpdates == 'Y' or moreUpdates == 'y':
48 rollNo = int(input('Enter roll no for marks update: '))
49 marks = int(input('Enter revised marks for update: '))
50 marksUpdate(rollNo, marks)
51 print('Continue another update?')
52 moreUpdates = input('Say Y/y for yes, N/n for no:')
53
54 classResult = []
55 readResult()
56 allUpdates()
57 #Display results
58 print('Moderated result:')
59 print(classResult)
60 print('Thank you, bye')
Below we give the output of a sample run of the program.
Sample Output:
>>> Enter number of students: 4
>>> Enter the list [Roll No, Marks] and press enter:
[rollNo, marks]: [501, 66]
[rollNo, marks]: [503, 55]
[rollNo, marks]: [504, 46]
[rollNo, marks]: [505, 30]
Continue to update the result?
Say Y/y for yes, N/n for no:y
>>> Enter roll no for marks update: 505
>>> Enter revised marks for update: 33
Continue another update?
Say Y/y for yes, N/n for no:y
>>> Enter roll no for marks update: 501
>>> Enter revised marks for update: 60
Continue another update?
Say Y/y for yes, N/n for no:n
Moderated result:
[[501, 60], [503, 55], [504, 46], [505, 33]]
Thank you, bye
13.7 Tuples
A tuple is a sequence of elements, separated by commas and usually enclosed between parentheses. For example,
>>> bDate = (30, 'September', 1987)
>>> bDate
(30, 'September', 1987)
346 Touchpad Computer Science-XI

