0% found this document useful (0 votes)
6 views2 pages

AI 11 U-3 Python Worksheet 2

This document is a worksheet for a Python course at Delhi Public School, focusing on basic input/output and operators. It includes multiple-choice questions covering identifiers, operators, flow of execution, string methods, and built-in functions. The questions test knowledge on Python syntax and programming concepts.

Uploaded by

gurveen.can
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

AI 11 U-3 Python Worksheet 2

This document is a worksheet for a Python course at Delhi Public School, focusing on basic input/output and operators. It includes multiple-choice questions covering identifiers, operators, flow of execution, string methods, and built-in functions. The questions test knowledge on Python syntax and programming concepts.

Uploaded by

gurveen.can
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DELHI PUBLIC SCHOOL R. N.

EXTENSION
(Under the aegis of the Delhi Public School Society, New Delhi)
WORKSHEET – 2 MCQ XI AI 0843 PYTHON
BASIC IOP & OPERATORS
1. Which of the following is a valid identifier: i. >>>not -5 ii. >>>not 5 iii. >>>not 0
i. 9type ii. _type iii. Same-type iv. True iv. >>>not(5- 1)
2. Which of the following is a relational operator: 13. Give the output of the following code:
i. > ii. // iii. or iv. ** >>>7*(8/(5//2))
3. Which of the following is a logical operator: i. 28 ii. 28.0 iii. 20 iv. 60
i. + ii. /= iii. and iv.in 14. Give the output of the following code: >>>import
4. Identify the membership operator from the math
following: >>> math.ceil(1.03)+math.floor(1.03)
i. in ii. not in iii. both i & ii iv. Only i i. 3 ii. -3.0 iii. 3.0 iv. None of the
5. Which one is a arithmetic operator: above
i. not ii. ** iii. both i & ii iv. Only ii 15. What will be the output of the following code:
6. What will be the correct output of the statement : >>>import math ;>>>math.fabs(-5.03)
>>>4//3.0 i. 5.0 ii. 5.03 iii. -5.03 iv . None of the
i. 1 ii. 1.0 iii 1.3333 iv. None of the above
above 16. Single line comments in python begin with……..
7. What will be the correct output of the statement : symbol.
>>> 4+2**2*10 i. # ii. “ iii. % iv. _
i. 18 ii. 80 iii. 44 iv. None of the 17. Which of the following are the fundamental building
above block of a python program.
8. Give the output of the following code: i. Identifier ii. Constant iii. Punctuators iv.
>>> a,b=4,2 ;>>> a+b**2*10 Tokens
i. 44 ii. 48 iii. 40 iv. 88 18. The input() function always returns a value of
9. Give the output of the following code: …..type.
>>> a,b = 4,2.5 ; >>> a-b//2**2 i. Integer ii. float iii. string
i. 4.0 ii. 4 iii. 0 iv. None of the above iv. Complex
10. Give the output of the following code: 19. .......... function is used to determine the data type of
>>>a,b,c=1,2,3 ;>>> a//b**c+a-c*a a variable.
i. -2 ii. -2.0 iii. 2.0 iv. None of the above i. type( ) ii. id( ) iii. print( ) iv. str( )
11. If a=1,b=2 and c= 3 then which statement will give 20. The smallest individual unit in a program is known as
the output as : 2.0 from the following: a..
i. a%b%c+1 ii. a%b%c+1.0 iii. a%b%c iv. a%b%c-1 i. Token ii. keyword iii. punctuator iv. identifier
12. Which statement will give the output as : True from
the following :
FLOW OF EXECUTION
21.Which of the following is not a decision making while a>0: print(a)
statement print(“Bye”)
i. if..else statement ii. for statement iii. if-elif i. times ii. Once iii. Infinite iv. None of these
statement iv. if statement 24.What abandons the current iteration of the loop
22. .......... loop is the best choice when the number of i. continue ii. stop iii. infinite iv. Break
iterations are known. 25.Find the output of the following python program
ii. while ii. do-while iii. for iv. None of for i in range(1,15,4): print(i, end=’,’)
these i. 1,20,3 ii. 2,3,4 iii. 1,5,10,14 iv. 1,5,9,13
23. How many times will the following code be 26. .......... loop is the best when the number of iterations
executed. are not known.

Page 1 of 2 PYTHON
a=5

i. while ii. do-while iii. for iv. None of 29. How many times will the following code be executed
these for i in range(1,15,5):
27. In the nested loop............... loop must be terminated print(i,end=’,’)
before the outer loop. i. 3 ii. 4 iii. 1 iv. infinite
i. Outer ii. enclosing iii. inner iv. None of 30. Symbol used to end the if statement:
these i. Semicolon(;) ii.Hyphen(-) iii. Underscore( _ ) iv.
28. .........statement is an empty statement in python. colon(:)
i. pass ii. break iii. continue iv. if

STRING METHODS AND BUILT-IN FUNCTIONS


31. Which of the following is not a python legal string 39. What will be the output
operation. of the following code.
i. ‘abc’+’aba’ ii. ‘abc’*3 iii. ‘abc’+3 iv. Str=”python 38”
‘abc’.lower() print(Str.isalnum())
32. Which of the following is not a valid string i. True ii. False iii.
operation. None iv. Error
i. Slicing ii. concatenation iii. Repetition iv. 40. What will be the output
floor of the following code.
33. Which of the following is a mutable type. Str=”pyThOn”
i. string ii. tuple iii. int iv. list print(Str.swapcase())
34. What will be the output of the following code i. PYtHoN ii. pyThon iii. python iv.
str1=”I love Python” PYTHON
strlen=len(str1)+5 print(strlen) 41. What will be the output
i. 18 ii. 19 iii. 13 iv. 15 of the following code.
35. Which method removes all the leading Str=”Computers”
whitespaces from the left of the string. print(Str.rstrip(“rs”))
i. split() ii. remove() iii. lstrip() iv rstrip() i. Computer ii. Computers iii. Compute iv.
36. It returns True if the string contains only compute
whitespace characters, otherwise returns False. 42. What will be the output
i) isspace() ii. strip() iii. islower() iv. isupper() of the following code.
37. It converts uppercase letter to lowercase and vice Str=”This is Meera\’ pen”
versa of the given string. print(Str.isdigit())
i. lstrip() ii. swapcase() iii. istitle() iv. count() i. 21 ii. 20 iii. 18 iv. 19
38. What will be the output of the following code. 43. How many times is the word ‘Python’ printed in
Str=’Hello World! Hello Hello’ the following statement.
Str.count(‘Hello’,12,25) s = ”I love Python”
i. 2 ii. 3 iii. 4 iv. 5 for ch in s[3:8]:
print(‘Python’)
i. 11 times ii. 8 times iii. 3 times iv. 5 times

Page 2 of 2 PYTHON

You might also like