Page 431 - Ai_417_V3.0_C9_Flipbook
P. 431
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. sequential 3. True/False 4. step-by-step 5. interpreted
6. arithmetic 7. Single-line/Multi-line 8. type() 9. program 10. condition
11. two 12. entry-controlled loop or indefinite loop 13. heterogeneous
14. mutable 15. Forward Indexing
C. 1. False 2. True 3. True 4. True 5. False 6. False
7. False 8. True 9. False 10. True 11. False 12. True
13. False 14. False 15. True
Introduction to Python 429

