CLASS TEST QP (Chapter 1 and 2)
CLASS TEST QP (Chapter 1 and 2)
9.
(a) Given is a Python string declaration: (1M)
myexam="Russia Ukrain"
Write the output of: print(myexam[-2:2:-2])
(b) Write the output of the code given below: (1M)
d1 = {"name": "Aman", "age": 26}
d2 = {27:'age','age':28}
d1.update(d2)
print(d1.values())
11. What will be the possible output from (i)-(iv) for following code? (2M)
import random
list1 = [2, 3, 4, 5, 6, 7, 9]
L = random.randint(1, 4)
U = random.randint(3, 5)
for K in range (L, U + 1):
print(list1 [K], end = “#”)
(i) 3#4#5# (ii) 5#6#7# (iii) 6#7#9# (iv) 2#3#4
12.Write a program to repeatedly ask the user to enter the state and capital,
where state is the key and capital is the value for the given dictionary.
display only those states where the capital ends with the letter ‘i’. (3M)
13.Write a program that enters a string and stores indices of all the vowels of
a given string in a list . (3M)
For example: If S is "Computer", then indexList should be [1,4,6]