Page 364 - Information_Practice_Fliipbook_Class11
P. 364
27. What is an infinite loop? Give one example.
Ans. An infinite loop is the one whose terminating condition is either missing or is not reachable. Thus, the body-of-
the-loop keeps repeating endlessly in an infinite loop.
28. Differentiate between strings and lists.
Ans. The lists and strings are different in following ways:
a. The lists are mutable sequences while strings are immutable.
b. Strings store single type of elements – all characters while lists can store elements belonging to different types.
29. Consider the following dictionary:
stateCapitals = {"Punjab": "Chandigarh", "Uttar Pradesh": "Lucknow", "Tamil
Nadu": "Chennai"}
Write code to:
a. Add the state as "Karnataka" and capital as " Bengaluru" in the above dictionary.
b. Display a list of all the states in stateCapitals.
Ans. a. Caps['Karnataka'] = 'Bengaluru'
b. sorted(Caps.items( ))
30. What will be the output produced on execution of the following code?
lst = [1, 3, 6, 82, 5, 7, 11, 92]
print(lst[2:5])
Ans. [6, 82, 5]
31. What are the key features of Python programming?
Ans. Python is a versatile and widely-used programming language known for its simplicity and readability. It has
many key features that make it popular among developers for a variety of applications. Here are some of the key
features of Python programming:
i. Extensive Standard Library
ii. Dynamic Typing
iii. Open Source
iv. Object-Oriented
32. Write a statement in Python to create a dictionary whose keys are 1, 2, 3 and values are Monday, Tuesday and
Wednesday respectively.
Ans. day = {1: 'Monday', 2: 'Tuesday', 3: 'Wednesday'}
33. What are the difference between a list and a tuple?
Ans. List Tuples
A list is mutable. A tuple is immutable.
Lists are enclosed in brackets[] and their Tuples are enclosed in parethesis() and can not
elements and size can be changed. be updated.
Example:
Example: S = ("Orange", "education")
L = [10,11,12,13] or
S = ("orange", "education")
350 Touchpad Informatics Practices-XI

