1. The document contains 25 multiple choice questions related to Python programming concepts such as string methods, data types, variables, operators, functions, modules and more.
2. Students are asked to answer the questions in their notebook over summer vacation as homework for their Computer Science class.
3. The questions cover a wide range of fundamental and intermediate Python topics to help students strengthen their understanding of the language.
1. The document contains 25 multiple choice questions related to Python programming concepts such as string methods, data types, variables, operators, functions, modules and more.
2. Students are asked to answer the questions in their notebook over summer vacation as homework for their Computer Science class.
3. The questions cover a wide range of fundamental and intermediate Python topics to help students strengthen their understanding of the language.
1. The document contains 25 multiple choice questions related to Python programming concepts such as string methods, data types, variables, operators, functions, modules and more.
2. Students are asked to answer the questions in their notebook over summer vacation as homework for their Computer Science class.
3. The questions cover a wide range of fundamental and intermediate Python topics to help students strengthen their understanding of the language.
Write answer of the following questions in your fair NB. Q1. Which string method is used to implement the following: (a) To count the number of characters in the string (b) To change the first character of the string in capital letter (c) To change lowercase to uppercase letter (d) To check whether the given character is letter or a number Q2. What are default arguments ? Q3. What is the difference between built-in functions and modules? Q4. What is the difference between local variable and global variable? Q5. What are the advantages of writing functions with keyword arguments? Q6. What do you mean by scope of variables ? Q7. Differentiate between the round() and floor() functions with the help of suitable example. Q8. What is the difference between actual and formal parameters ? CP INTERNATIONAL SCHOOL Q9. Which of the following is valid arithmetic operator in Python: (i) // (ii) ? (iii) < (iv) and
Q10. Write the type of tokens from the following:
(i) if (ii) roll_no
Q11. Which of the following can be used as valid variable identifier(s) in Python? (i) 4thSum (ii) Total (iii) Number# (iv) _Data
Q12. Give the output of the following code:-
list=['p','r','o','b','l','e','m'] list[1:3]=[] print(list) list[2:5]=[] print(list) CP INTERNATIONAL SCHOOL Q13. Give the output of the following code:- l1=[13,18,11,16,13,18,13] print(l1.index(18)) print(l1.count(18)) l1.append(l1.count(13)) print(l1) Q14. Find the output of following codes (a) t1=("sun","mon","tue","wed") print(t1[-1]) (b) t2=("sun","mon","tue","wed","thru","fri") for i in range (-6,2): print(t2[i]) 15. What possible outputs(s) are expected to be displayed on screen at the time of execution of the program from the following code? import random AR=[20,30,40,50,60,70]; FROM=random.randint(1,3) TO=random.randint(2,4) for K in range(FROM,TO+1): print (AR[K],end=”#“) (i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70#
CP INTERNATIONAL SCHOOL, FARRUKHABAD
Kaimganj By Pass Road, Post Awajpur, Farrukhabad (U.P) 209625. CP INTERNATIONAL SCHOOL Q16. What will be the output of the following Python code? >>>t=(1,2,4,3) >>>t[1:-1] (a) (1, 2) (b) (1, 2, 4) (c) (2, 4) (d) (2, 4, 3) Q17. What does 3 ^ 4 evaluate to? (a) 81 (b) 12 (c) 0.75 (d) 7 Q18. What does ~4 evaluate to? (a) -5 (b) -4 (c) -3 (d) +3 Q19. Which of the following cannot be a variable? (a) __init__ (b) in (Which of the following is not a keyword? (a) eval (b) assert (c) nonlocal (d) passc) it (d) on Q20. What is the maximum possible length of an identifier? (a) 31 characters (b) 63 characters (c) 79 characters (d) none of the mentioned Q21. Which of the following is an invalid variable? (a) my_string_1 (b) 1st_string (c) foo (d) _ Q22. Is Python case sensitive when dealing with identifiers? (a) Yes (b) No (c) Machine dependent (d) None of the mentioned Q23. Which of the following is not a keyword? (a) eval (b) assert (c) nonlocal (d) pass Q24. All keywords in Python are in _________ (a) lower case (b) UPPER CASE (c) Capitalized (d) None of the mentioned Q25. What is the output of print 0.1 + 0.2 == 0.3? (a) True (b) False (c) Machine dependent (d) Error