Page 319 - Computer Science Class 11 Without Functions
P. 319
b. construct a tuple (say, sqrTuple) as follows:
i. The elements at odd indexes are same as those at odd indexes in the tuple tpl.
ii. The elements at even indexes are computed according to the formula: n**2, where n is the index of the element.
if the user enters the tuple:
(20, 5, 2, 8, 23, 26, 54, 83, 23, 99)
the program should display the tuple:
(0, 5, 4, 8, 16, 26, 36, 83, 64, 99)
9. Write a program that
a. accepts a tuple (say, tpl) of numbers from a user
b. construct a list (say, sqrList) as follows:
i. The elements at odd indexes are same as those at odd indexes in the tuple tpl.
ii. The elements at even indexes are computed according to the formula: n**2, where n is the index of the
element.
if the user enters the tuple:
(20, 5, 2, 8, 23, 26, 54, 83, 23, 99)
the program should display the list:
[0, 5, 4, 8, 16, 26, 36, 83, 64, 99]
You are not allowed to use the concatenation of lists.
10. Write a program that accepts a list of numbers from a user and replaces the elements at indices which are multiples of
3, by the cube of the number at that index. Elements at other indexes should remain unchanged. For example, if the user
enters the list:
[3, 5, 5, 2, 8, 9, 7, 21, 6, 5, 4]
the program should display the list:
[27, 5, 5, 8, 8, 9, 343, 21, 6, 125, 4]
You should not create a new list, but rather modify the existing list.
11. Write a program that takes a list as input (say, key) and searches for a key in the list. If the key is found in the list the
program should output the index of the first occurrence in the list, otherwise, the program should print an appropriate
message.
12. Write a program marksUpdate that accepts a list of lists RollNoMarksList (where each inner list comprises a pair
of roll number and marks of students) and the RollNo and returns the updated list with the marks increased by 5
corresponding to RollNo. Write a program that accepts pairs of roll number and marks of some students as lists and uses
the function RollNoMarksUpdateto increase the marks by 5. Finally, display the updated list.
13. Write a program that accepts a list of lists RollNoMarksList (each inner list comprises a pair of roll numbers and marks
of students) from the user and the RollNo and outputs the updated list with the marks increased by 5 corresponding to
RollNo.
14. Write a program that accepts a list of lists NameMarksList (where each inner list comprises a pair of roll number
and marks of students) and outputs the updated list with the marks appropriately moderated according to the following
criteria:
Marks range Moderation
marks <40 6
40<=marks<50 5
50<=marks<60 4
60<=marks<70 3
70<=marks<80 2
80<=marks<90 1
90<=marks 0
Lists and Tuples 317

