You are on page 1of 3

NATIONAL ACADEMY FOR LEARNING

BENGALURU

SECOND SEMESTER EXAMINATION 2021-22

REVISION

Class: 11 M.M = 20
[All questions carry same marks.]

1.  Which of the following will add a key to the dictionary only if it does not already exist in the
dictionary?

2. Which of the following will raise an error if the given dictionary is empty?

3. What will be the result of the following code?

4. Identify if program is correct. If not, write correct code and explain error.
NATIONAL ACADEMY FOR LEARNING

BENGALURU

SECOND SEMESTER EXAMINATION 2021-22

REVISION

5. Write a Python program to create a dictionary from a string.

Note: Track the count of the letters from the string.


Sample string  : 'w3resource'
Expected output : {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1}

6. In which data type, indexing is not valid?

7. Correct way to declare a variable x of float data type in python

8. Write output.
a = (23,34,65,20,5)
print(a[0]+a.index(5))
NATIONAL ACADEMY FOR LEARNING

BENGALURU

SECOND SEMESTER EXAMINATION 2021-22

REVISION

9. Write output.

10. Which of the following is False regarding loops in Python?


a.Loops are used to perform certain tasks repeatedly.
b.While loop is used when multiple statements are to be executed repeatedly until the given condition
becomes False
c.While loop is used when multiple statements are tobeexecuted repeatedly until the given condition
becomes True.
d.for loop can be used to iterate through the elements of lists.

You might also like