Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
12 views6 pages

ID 4th Sem Uggestions

The document contains a series of multiple-choice questions (MCQs) related to Python programming, covering topics such as syntax, data types, operators, and control flow. Each question is followed by four answer options, with the correct answer indicated. The questions are organized into parts, focusing on different aspects of Python, including its introduction, basics, and loops.

Uploaded by

dbhowmik060
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)
12 views6 pages

ID 4th Sem Uggestions

The document contains a series of multiple-choice questions (MCQs) related to Python programming, covering topics such as syntax, data types, operators, and control flow. Each question is followed by four answer options, with the correct answer indicated. The questions are organized into parts, focusing on different aspects of Python, including its introduction, basics, and loops.

Uploaded by

dbhowmik060
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/ 6

Python MCQS

Part 1: Introduction to Python (1–15) A. echo("Hello World")


B. print("Hello World")
C. printf("Hello World")
1. Which language is Python written in?
D. cout << "Hello World"
A. Java
Answer: B
B. C
10. What is the output of
C. Python
print(type("Python"))?
D. C++
Answer: B A. <class 'string'>
B. <type 'str'>
2. Who developed Python programming
language? C. <class 'str'>
A. James Gosling D. <data 'string'>
B. Guido van Rossum Answer: C
C. Dennis Ritchie 11. Which of these is a valid Python identifier?
D. Bjarne Stroustrup A. 2python
Answer: B B. python_3
3. In which year was Python first released? C. python-3
A. 1991 D. python.3
B. 1989 Answer: B
C. 2000 12. Which of the following is not a Python
D. 2010 keyword?
Answer: A A. def
4. Python is a ___ typed language. B. lambda
A. Static C. class
B. Strong D. main
C. Weak Answer: D
D. Dynamically 13. Python is an example of a _______
Answer: D programming language.
5. Which of the following is not a feature of A. markup
Python? B. scripting
A. Interpreted C. query
B. Dynamically typed D. compiled
C. Low-level language Answer: B
D. Free and Open Source 14. Which function is used to take input from
Answer: C the user?
6. Which symbol is used to comment a single A. input()
line in Python? B. read()
A. // C. scan()
B. -- D. cin
C. # Answer: A
D. /* 15. What is the default mode of the input()
Answer: C function?
7. Which file extension is used for Python A. int
source code? B. str
A. .py C. float
B. .python D. bool
C. .pt Answer: B
D. .pyt
Answer: A Part 2: Python Basics, Variables, Expressions
8. Which of these is an interpreted language? (16–45)
A. C++
B. Java
C. Python 16. Which of the following is not a data type in
D. Assembly Python?
A. int
Answer: C
B. real
9. Which one is the correct way to output
C. float
"Hello World" in Python?
D. str 26. Which of the following converts a string to
Answer: B an integer?
17. What is the output of print(3 + 2 * 2)? A. str()
A. 7 B. int()
B. 10 C. eval()
C. 9 D. float()
D. 8 Answer: B
Answer: A 27. What will print("5" + "10") output?
18. Which of the following is a valid variable A. 15
name in Python? B. 510
A. my-variable C. Error
B. 123name D. 5 10
C. name_123 Answer: B
D. None 28. Which of the following is not a comparison
Answer: C operator?
19. Which of the following operators is used for A. !=
exponentiation? B. ==
A. ^ C. <=
B. ** D. =
C. pow Answer: D
D. % 29. What is the result of 10 % 3?
Answer: B A. 3
20. What will be the result of print(type(3.0))? B. 1
A. <class 'int'> C. 0
B. <class 'float'> D. 10
C. <class 'double'> Answer: B
D. Error
Answer: B Part 2 Continued: Python Basics, Variables,
21. Which one is a valid assignment?
Expressions (30–45)
A. x := 10
B. 10 = x
C. x = 10 30. Which operator is used for assignment?
D. let x = 10 A. :=
Answer: C B. ==
22. Which of the following is not an arithmetic C. =
operator? D. =>
A. + Answer: C
B. - 31. What is the output of print(2**3)?
C. ** A. 6
D. && B. 8
Answer: D C. 9
23. Which of these shows integer division in D. 5
Python 3? Answer: B
A. / 32. What will be the type of result for 7 / 2 in
B. // Python 3?
C. div A. int
D. \ B. float
Answer: B C. double
24. What will be the output of print(5//2)? D. str
A. 2.5 Answer: B
B. 2 33. Which keyword is used to define a constant
C. 3 in Python?
D. 2.0 A. const
Answer: B B. define
25. Which function is used to find the data type C. final
of a variable? D. Python does not have constants by default
A. typeof() Answer: D
B. datatype() 34. Which of the following will produce a
C. type() TypeError?
D. data() A. 5 + 3.2
Answer: C B. "5" + "7"
C. "5" + 2
D. 5 * 3
Part 2 Continued: Python Basics, Variables, Answer: C
Expressions (26–45) 35. What does str(3.14) return?
A. '3.14'
B. 3.14
C. str C. type()
D. Error D. is
Answer: A Answer: C
36. Which of the following is not a valid escape
sequence? Part 3: For Loop and Range Function (46–100)
A. \n
B. \t
C. \d 46. What is the output of for i in range(3):
D. \\ print(i)?
Answer: C A. 1 2 3
37. Which function returns the remainder of a B. 0 1 2
division? C. 0 1 2 3
A. mod() D. 1 2
B. remainder() Answer: B
C. % 47. What is the default start value in range(n)?
D. // A. 0
Answer: C B. 1
38. Which is the correct output of print(2 + 3 C. -1
* 4)? D. Error
A. 20 Answer: A
B. 14 48. What is the output of range(5)?
C. 24 A. 1 to 5
D. 18 B. 0 to 5
Answer: B C. range object
39. Which one will evaluate to True? D. [0, 1, 2, 3, 4]
A. 0 == True Answer: C
B. 1 == False 49. What will list(range(2, 10, 2)) return?
C. 1 == True A. [2, 4, 6, 8]
D. 0 == 1 B. [2, 3, 4, 5, 6, 7, 8, 9]
Answer: C C. [2, 5, 8]
40. Which built-in function returns the memory D. [2, 10]
location (address) of a variable? Answer: A
A. mem() 50. What is the step value in range(10, 1, -2)?
B. location() A. 1
C. id() B. -1
D. ref() C. -2
Answer: C D. 2
41. Which of the following represents a floating Answer: C
point number? 51. Which of the following loops is used for
A. 5 definite iteration?
B. "5.0" A. while
C. 5.0 B. for
D. "five" C. do while
Answer: C D. loop
42. What is the result of bool(0)? Answer: B
A. True 52. What is the output of:
B. False
C. 0 for i in range(1, 5):
D. None print(i, end=" ")
A. 0 1 2 3 4
Answer: B B. 1 2 3 4
43. What will print("abc" * 3) produce? C. 1 2 3 4 5
A. abc3 D. Error
**Answer:** B
B. abcabcabc
C. Error
D. abc abc abc 53. What does end=" " in the print function do?
Answer: B A. Ends the program
44. Which operator checks for equality in B. Prints a space after each output
Python? C. Ends with newline
A. = D. Skips output
B. := Answer: B
C. ==
D. === 54. Which range will generate only even
Answer: C numbers from 0 to 10 (inclusive)?
45. Which keyword is used to check the type of A. range(0, 10)
an object? B. range(0, 10, 1)
A. object() C. range(0, 11, 2)
B. check()
D. range(2, 10, 2) B. while
Answer: C C. do while
55. Which loop runs when the number of D. repeat until
iterations is known beforehand? Answer: A
A. while 63. Which of the following is a valid range?
B. infinite A. range(5, 10, 0)
C. for B. range(5, 10, 1)
D. do-while C. range(5, 10, -1)
Answer: C D. range(10, 5, 1)
Answer: B
64. What happens if step=0 is used in range()?
Part 3 Continued: For Loop and Range
A. Outputs all numbers
Function (56–100) B. Infinite loop
C. Error
56. What will for i in range(3, 0, -1): D. Outputs 0
print(i) output? Answer: C
A. 3 2 1 65. How many times will this loop run?
B. 3 2 1 0
C. 0 1 2 3 for i in range(2, 10, 2):
D. 1 2 3 print(i)
Answer: A
57. What is the output of for i in range(2): A. 4
print("Hi")? B. 5
A. Hi C. 3
B. Hi Hi D. 6
C. 0 Hi Answer: A
D. Error
Answer: B
58. What is printed by this loop? 66. What is the result of list(range(10, 5, -
1))?
A. [10, 9, 8, 7, 6]
for i in range(1, 5, 2):
print(i) B. [10, 9, 8, 7, 6, 5]
C. [5, 6, 7, 8, 9, 10]
D. [5, 6, 7, 8]
A. 1 2 3 4 Answer: A
B. 1 3 67. What does range(0) return?
C. 1 3 5 A. [0]
D. 1 2 3 B. [1]
Answer: B C. []
D. Error
59. Which of the following will iterate 5 times? Answer: C
A. range(5) 68. In a for loop, which keyword is used to skip
B. range(0, 5) the current iteration?
C. range(1, 6) A. stop
D. All of the above B. skip
Answer: D C. continue
60. What will be the value of i after this loop? D. pass
Answer: C
for i in range(3): 69. Which keyword breaks the loop entirely?
pass A. break
B. return
A. 2 C. exit
B. 3 D. stop
C. 0 Answer: A
D. Undefined 70. What is the result of this code?
Answer: A
for i in range(3):
print(i, end=", ")
61. What is the result of list(range(5, 1, -
1))?
A. [5, 4, 3, 2, 1] A. 0, 1, 2
B. [5, 4, 3, 2] B. 0, 1, 2,
C. [5, 3, 1] C. 0 1 2
D. [1, 2, 3, 4, 5] D. 1 2 3
Answer: B Answer: B
62. Which loop is typically used for iterating
over sequences like lists or strings? 71. Which of the following creates an infinite
A. for loop?
A. for i in range(10): A. 3
B. while True: B. 6
C. for i in range(1, 10, 0): C. 10
D. Both B and C D. 7
Answer: D Answer: B
72. What is the final output of:
78. How many times will this loop run?
for i in range(1, 6):
if i == 3:
break for i in range(0, 11, 2):
print(i) print(i)

A. 1 2 3 A. 5
B. 1 2 B. 6
C. 1 2 3 4 5 C. 10
D. None D. Infinite
Answer: B Answer: B

73. What is the output of: 79. Which keyword is used to do nothing in a
loop body?
for i in range(4):
A. stop
if i == 2: B. skip
continue C. null
print(i) D. pass
Answer: D
A. 0 1 2 3 80. What is the output of:
B. 0 1 3
C. 0 1 2 for i in range(1, 10, 3):
D. 0 1 2 3 print(i, end=" ")
Answer: B
A. 1 4 7
74. Which of these functions returns a sequence B. 1 3 5 7 9
object? C. 1 2 3
A. input() D. 1 4 7 10
B. print() Answer: A
C. range()
D. type() 81. Which of the following can loop over a
Answer: C string?
75. What is the output of range(1, 5, -1)? A. for
A. [1, 0, -1, -2] B. while
B. [1, 2, 3, 4] C. Both
C. [] D. None
D. Error Answer: C
Answer: C 82. Which function can you use to check the
length of a string?
Part 4: Mixed MCQs and Logical Thinking (76– A. count()
100) B. length()
C. len()
D. size()
76. What is the output of: Answer: C
83. What is the output of
for x in range(2, 10, 2): print(len("Python"))?
print(x, end=" ")
A. 6
B. 5
A. 2 4 6 8 C. 7
B. 2 3 4 5 6 7 8 9 D. Error
C. 2 4 6 8 10 Answer: A
D. 2 4 6 8 9 84. Which character is used to escape
Answer: A characters in Python?
A. /
77. What is printed by this code? B. \
C. ^
sum = 0
D. ~
for i in range(1, 4): Answer: B
sum += i 85. What is the output of print("P\nython")?
print(sum) A. Python
B. P\nython C. float()
C. P D. input()
ython Answer: A
D. Error 94. What does print(bool("")) return?
Answer: C A. True
86. What will print('a' + 'b' + 'c') return? B. False
A. abc C. ""
B. a b c D. Error
C. a + b + c Answer: B
D. Error 95. What is the output of:
Answer: A
87. Which of the following is a correct loop for i in "Hi":
header in Python? print(i)
A. for (i = 0; i < 5; i++)
B. for i = 0 to 5 A. H
C. for i in range(5): i
D. loop i from 1 to 5 B. Hi
Answer: C C. Error
88. What is the output of for i in range(2): D. i H
print(i * 2)? Answer: A
A. 0 1
B. 2 4
C. 0 2 96. What will print("5" * 2) output?
D. 0 2 4 A. 10
Answer: C B. 55
C. 5
89. Which of the following is invalid?
A. x = 10 D. 25
B. y = "Hello" Answer: B
C. 5 = x 97. Which keyword is used to define a function?
D. name_1 = "Roy" A. func
Answer: C B. def
C. define
90. Which of these is a compound assignment
D. lambda
operator?
A. == Answer: B
B. += 98. Which operator is used for string
C. := concatenation?
D. => A. ,
Answer: B B. +
C. &
91. What is the output of print(3 == 3.0)?
D. *
A. True
Answer: B
B. False
C. Error 99. What is the output of
print(type(range(5)))?
D. None
Answer: A A. <class 'list'>
92. Which operator is used for logical AND in B. <class 'range'>
Python? C. <range>
A. && D. range(0,5)
B. and Answer: B
C. & 100. Which Python version introduced the
D. AND range() as a lazy iterator?
Answer: B A. 2.x
93. Which function is used to convert a number B. 3.x
to string? C. 1.x
A. str() D. 4.x
B. int() Answer: B

You might also like