Page 347 - Artificial Intellegence_v2.0_Class_9
P. 347
b. Input five names from the user and print them in the same line with a single space.
c. Swap the values of two variables using third variable.
d. Convert kilometre unit to metre.
e. Calculate the area of a square.
f. Interchange the values of the adjacent elements of the list. Print the updated list.
g. Input five names of cities in a list. Accept a name and check whether it exists in a list or not. Display
appropriate message.
h. Input five subject's marks in a list and print the percentage of all.
i. Create a list with heterogeneous values and print the values which are only integer.
j. Create a list of five subject's marks and print the marks >50.
4. Find the output of the following programs:
a. A list is declared as
marks = [20,15,45,25,30]
What will be the output of
print(3*marks[2] - 4*marks[4])
b. word=['P','R','O','G','R','A','M']
print(word[-4:])
print(word[::-2])
c. word=['P','R','O','G','R','A','M']
print(word.count('R'))
print(word.index('R'))
d. L=[1,2,3]
L*=3
print(L)
e. list1=[10,20]
list2=[30,40]
list1.append(25)
print(list1)
list1.extend(list2)
print(list1)
Answers
Exercise (Section A)
A. 1. d 2. b 3. c 4. a 5. c 6. b 7. a 8. c 9. c 10. b
11. b 12. a 13. b 14. a 15. b
B. 1. program 2. sequentia 3. True/False 4. step-by-step 5. interpreter
6. arithmetic 7. Single-line/Multi-line 8. type() 9. program 10. condition
11. two 12. entry-controlled loop 13. heterogeneous 14. mutable
15. Forward Indexing
C. 1. False 2. False 3. True 4. True 5. False 6. True
7. False 8. True 9. False 10. True 11. False 12. True
13. True 14. False 15. True
Introduction to Python 345

