0% found this document useful (0 votes)
20 views34 pages

Python Basics - MCQ

The document contains a set of 100 multiple-choice questions (MCQs) focused on Python programming basics, specifically tailored for CBSE NCERT 083 Computer Science. Each question includes options and the correct answer is marked. The questions cover various topics such as data types, operators, functions, and control structures in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views34 pages

Python Basics - MCQ

The document contains a set of 100 multiple-choice questions (MCQs) focused on Python programming basics, specifically tailored for CBSE NCERT 083 Computer Science. Each question includes options and the correct answer is marked. The questions cover various topics such as data types, operators, functions, and control structures in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Basics – 100 Tough MCQs (CBSE NCERT 083 Computer Science)

1. What is the output of `print(type(5))`?

A. \<class 'float'>

B. \<class 'int'>

C. \<class 'str'>

D. \<class 'bool'>

✔ Answer: B

2. Which of the following is a valid variable name in Python?

A. 1variable

B. variable\_1

C. variable-name

D. @variable

✔ Answer: B

3. What does the `input()` function return?

A. Integer

B. Float

C. String

D. List

✔ Answer: C

4. What is the correct syntax to print "Hello, World!"?

A. echo("Hello, World!")

B. print("Hello, World!")

C. printf("Hello, World!")

D. console.log("Hello, World!"
✔ Answer: B

5. Which of the following is an arithmetic operator in Python?

A. +

B. and

C. or

D. not

✔ Answer: A

6. What will be the output of `print(2 ** 3)`?

A. 6

B. 8

C. 9

D. 5

✔ Answer: B

7. Which data type is used to store text in Python?

A. int

B. float

C. str

D. bool

✔ Answer: C

8. Which of the following is used to start a comment in Python?

A. //

B. /\* \*/

C. #

D. --
✔ Answer: C

9. Which keyword is used to define a function in Python?

A. func

B. function

C. define

D. def

✔ Answer: D

10. What will be the output of `print(10 / 3)`?

A. 3

B. 3.0

C. 3.3333333333333335

D. Error

✔ Answer: C

11. Which of the following will create a list in Python?

A. {}

B. \[]

C. ()

D. <>

✔ Answer: B

12. What is the output of `print(5 % 2)`?

A. 2
B. 1

C. 0

D. 5

✔ Answer: B

13. Which of the following is a logical operator in Python?

A. +

B. -

C. or

D. \*

✔ Answer: C

14. What is the result of `bool(0)`?

A. True

B. False

C. Error

D. None

✔ Answer: B

15. What is the output of `print(2 < 3)`?

A. True

B. False

C. 1

D. 0

✔ Answer: A
16. Which symbol is used to assign a value to a variable?

A. ==

B. =

C. ===

D. =>

✔ Answer: B

17. Which of the following is used to import a module?

A. include

B. import

C. require

D. module

✔ Answer: B

18. What will `print(len("Python"))` output?

A. 5

B. 6

C. 7

D. Error

✔ Answer: B

19. Which of the following is a floating-point number?

A. 10

B. 3.14
C. '3.14'

D. True

✔ Answer: B

20. Which of the following is a correct way to write a tuple?

A. \[1, 2, 3]

B. {1, 2, 3}

C. (1, 2, 3)

D. <1, 2, 3>

✔ Answer: C

21. What will the following code output?

```python

x = "10"

y = int(x) + 5

print(y)

```

A. 105

B. 15

C. Error

D. 10

✔ Answer: B
22. Which of the following is true about Python?

A. It is case-insensitive.

B. It uses curly braces to define code blocks.

C. It uses indentation to define code blocks.

D. It requires semicolons at the end of each statement.

✔ Answer: C

23. What will this output?

```python

x = True

print(not x)

```

A. True

B. False

C. None

D. Error

✔ Answer: B

24. What is the output of `print(7 // 2)`?

A. 3.5

B. 4

C. 3

D. 7
✔ Answer: C

25. What is the output of `print(4 * 'A')`?

A. AAAA

B. A4

C. 4A

D. Error

✔ Answer: A

26. Which function converts a string into a floating-point number?

A. int()

B. float()

C. str()

D. bool()

✔ Answer: B

27. What will this output?

```python

x = "Python"

print(x[0])

```

A. P

B. y
C. n

D. Error

✔ Answer: A

28. What is the output of `print(3 == 3.0)`?

A. True

B. False

C. Error

D. None

✔ Answer: A

29. Which of the following is used for exponentiation in Python?

A. ^

B. \*\*

C. exp()

D. pow()

✔ Answer: B

30. Which data type is used to store True or False?

A. str

B. bool

C. list

D. dict

✔ Answer: B
31. What will this code output?

```python

x=5

y=2

print(x % y)

```

A. 1

B. 2

C. 0

D. 3

✔ Answer: A

32. Which of the following is correct for comments?

A. -- comment

B. # comment

C. /\* comment \*/

D. ## comment

✔ Answer: B

33. What is printed by this code?

```python

x = "Hello"
y = "World"

print(x + " " + y)

```

A. HelloWorld

B. Hello World

C. Hello + World

D. Error

✔ Answer: B

34. What will be the output of `print(type(True))`?

A. \<class 'int'>

B. \<class 'str'>

C. \<class 'bool'>

D. \<class 'float'>

✔ Answer: C

35. Which of these operators is used to check equality?

A. =

B. ==

C. !=

D. =>

✔ Answer: B

36. What will this output?


```python

print(3 < 4 and 4 < 5)

```

A. True

B. False

C. Error

D. None

✔ Answer: A

37. Which of the following is the correct way to take user input?

A. input("Enter value:")

B. read("Enter value:")

C. scan("Enter value:")

D. get("Enter value:")

✔ Answer: A

38. What is the output of `print(bool(""))`?

A. True

B. False

C. Error

D. None

✔ Answer: B
39. What will `print(2 + 3 * 4)` output?

A. 20

B. 14

C. 18

D. 24

✔ Answer: B

40. Which of the following is not a Python data type?

A. int

B. real

C. float

D. bool

✔ Answer: B

---

### Tough Questions (41 – 100)

41. What is the output of `print((5 > 3) + (3 < 2))`?

A. TrueTrue

B. 2

C. 1

D. 0

✔ Answer: C
42. Which of the following is immutable in Python?

A. List

B. Set

C. Tuple

D. Dictionary

✔ Answer: C

43. What is the output of `print(int('12', 8))`?

A. 10

B. 12

C. 8

D. 14

✔ Answer: A

44. Which of the following will not cause an error?

A. x = '5' + 5

B. x = int('5') + 5

C. x = float('abc')

D. x = 5 / 0

✔ Answer: B

45. What will `print("Python"[::-1])` output?

A. Python

B. nohtyP

C. Error
D. Pytho

✔ Answer: B

46. Which of the following is used to check membership?

A. in

B. not

C. is

D. lambda

✔ Answer: A

47. What is printed by this code?

```python

x = [1, 2, 3]

print(x * 2)

```

A. \[1, 2, 3, 1, 2, 3]

B. \[2, 4, 6]

C. Error

D. \[1, 2, 3, 2, 4, 6]

✔ Answer: A

48. Which of the following will create an empty dictionary?

A. {}
B. \[]

C. ()

D. set()

✔ Answer: A

49. What is the output of `print(2 == 2.0)`?

A. True

B. False

C. Error

D. None

✔ Answer: A

50. What will be the output?

```python

print(4 / 2 == 2)

```

A. True

B. False

C. Error

D. None

✔ Answer: A

51. Which method is used to convert a string into lowercase?


A. lower()

B. upper()

C. capitalize()

D. title()

✔ Answer: A

52. What will `print([1, 2, 3] + [4, 5])` output?

A. \[1, 2, 3, 4, 5]

B. \[5, 7, 8]

C. \[\[1, 2, 3], \[4, 5]]

D. Error

✔ Answer: A

53. Which of the following will return the index of an element?

A. find()

B. index()

C. search()

D. locate()

✔ Answer: B

54. What is the output of `print(bool(None))`?

A. True

B. False

C. None

D. Error
✔ Answer: B

55. Which of the following is the correct way to open a file for reading?

A. open("file.txt", "r")

B. open("file.txt", "w")

C. open("file.txt", "x")

D. open("file.txt", "a")

✔ Answer: A

56. Which function returns a sequence of numbers?

A. range()

B. random()

C. list()

D. enumerate()

✔ Answer: A

57. What will be the output of `print(0.1 + 0.2 == 0.3)`?

A. True

B. False

C. Error

D. None

✔ Answer: B

58. What is printed by this code?


```python

x = [1, 2, 3]

x.append([4, 5])

print(x)

```

A. \[1, 2, 3, 4, 5]

B. \[1, 2, 3, \[4, 5]]

C. \[1, 2, 3]

D. Error

✔ Answer: B

59. What is the result of `print(type(3 + 4.5))`?

A. \<class 'int'>

B. \<class 'float'>

C. \<class 'complex'>

D. \<class 'str'>

✔ Answer: B

60. Which keyword is used to create an anonymous function?

A. lambda

B. def

C. func

D. anonymous

✔ Answer: A
61. Which of the following is true for dictionaries?

A. Keys can be mutable

B. Values must be integers

C. Keys are unique

D. Values must be unique

✔ Answer: C

62. What will this output?

```python

print(5 > 3 > 1)

```

A. True

B. False

C. Error

D. None

✔ Answer: A

63. Which of the following can be used as a loop control statement?

A. break

B. return

C. pass

D. import
✔ Answer: A

64. What will be printed?

```python

x = "Hello"

print(x[-1])

```

A. H

B. o

C. l

D. Error

✔ Answer: B

65. What will be the output?

```python

x = [1, 2, 3]

x.insert(1, 5)

print(x)

```

A. \[1, 5, 2, 3]

B. \[1, 2, 5, 3]
C. \[1, 2, 3, 5]

D. Error

✔ Answer: A

66. What will this code output?

```python

print(5 & 3)

```

A. 1

B. 0

C. 7

D. 8

✔ Answer: A

67. Which of these is not a valid literal in Python?

A. 3.14

B. 'Python'

C. True

D. 2j + 3i

✔ Answer: D

68. Which operator has the highest precedence?

A. \*
B. +

C. ==

D. and

✔ Answer: A

69. What is the output?

```python

print(bool("False"))

```

A. False

B. True

C. Error

D. None

✔ Answer: B

70. What is the output of `print(3 + True)`?

A. 3

B. 4

C. True

D. Error

✔ Answer: B

71. Which of the following converts a list into a tuple?


A. list()

B. tuple()

C. set()

D. dict()

✔ Answer: B

72. What will be printed?

```python

x = "abc"

y=x*3

print(y)

```

A. abcabcabc

B. abc3

C. Error

D. abc abc abc

✔ Answer: A

73. What will this output?

```python

x = 10

y = 20
x, y = y, x

print(x, y)

```

A. 10 20

B. 20 10

C. Error

D. None

✔ Answer: B

74. Which of the following is used to handle exceptions?

A. try-except

B. if-else

C. for-else

D. while-break

✔ Answer: A

75. What is printed?

```python

print(3 ** 2 ** 2)

```

A. 81

B. 512
C. 36

D. 9

✔ Answer: A

76. What is the output of `print("5" * 3)`?

A. 15

B. 555

C. Error

D. 5 \* 3

✔ Answer: B

77. What is printed?

```python

x = "abcde"

print(x[1:4])

```

A. bcd

B. abc

C. bcde

D. Error

✔ Answer: A

78. Which of the following is true?


A. Python supports method overloading

B. Python supports multiple inheritance

C. Python does not support recursion

D. Python does not support dynamic typing

✔ Answer: B

79. Which is used to check if a key exists in a dictionary?

A. has\_key()

B. in

C. find()

D. search()

✔ Answer: B

80. Which of these is used to define block of code in Python?

A. Parentheses

B. Curly braces

C. Indentation

D. Quotes

✔ Answer: C

81. What is printed?

```python

x = "Python"

print(x[-3])
```

A. h

B. o

C. t

D. n

✔ Answer: C

82. What is the output of `print(7 // 3)`?

A. 2.33

B. 3

C. 2

D. Error

✔ Answer: C

83. What is the correct way to import only the sqrt function from the math module?

A. from math import sqrt

B. import math.sqrt

C. include math.sqrt

D. import sqrt from math

✔ Answer: A

84. What is the output of `print(3 * (2 + 1))`?

A. 6

B. 9
C. 5

D. 3

✔ Answer: B

85. Which of the following is true about Python lists?

A. Lists are immutable

B. Lists can hold elements of different types

C. Lists require elements of the same type

D. Lists cannot be nested

✔ Answer: B

86. Which built-in function returns the memory address of an object?

A. id()

B. address()

C. location()

D. mem()

✔ Answer: A

87. What is the output of `print(bool([]))`?

A. True

B. False

C. None

D. Error

✔ Answer: B
88. Which keyword is used to skip the rest of the code inside a loop for the current iteration?

A. break

B. continue

C. pass

D. exit

✔ Answer: B

89. What is the output of `print(0b1010)`?

A. 5

B. 10

C. 1010

D. 8

✔ Answer: B

90. What will this output?

```python

x = [1, 2, 3, 4, 5]

print(x[::-1])

```

A. \[5, 4, 3, 2, 1]

B. \[1, 2, 3, 4, 5]

C. \[2, 3, 4, 5]

D. Error
✔ Answer: A

91. Which operator is used to perform bitwise OR?

A. &

B. |

C. ^

D. \~

✔ Answer: B

92. Which method removes and returns the last item from a list?

A. pop()

B. remove()

C. discard()

D. delete()

✔ Answer: A

93. What will be the output of `print('abc'.upper())`?

A. abc

B. ABC

C. Abc

D. error

✔ Answer: B

94. Which of the following is used to terminate a loop prematurely?

A. return
B. break

C. continue

D. pass

✔ Answer: B

95. What is printed by this code?

```python

x = "Hello"

print(x[1:])

```

A. Hello

B. ello

C. Hell

D. error

✔ Answer: B

96. What will `print(3 + 4 * 2 / (1 - 5) ** 2)` output?

A. 3.5

B. 3.25

C. 5.5

D. 4.0

✔ Answer: B
97. Which function can convert a number into a hexadecimal string?

A. hex()

B. oct()

C. bin()

D. format()

✔ Answer: A

98. What is the output of `print(5 and 0 or 3)`?

A. 0

B. 3

C. 5

D. error

✔ Answer: B

99. Which of the following correctly defines a function with no arguments?

A. def fun\[]:

B. def fun():

C. function fun():

D. define fun():

✔ Answer: B

100. Which of these is a correct way to handle exceptions?

A. if error:

B. try-except

C. while error:
D. do-except

✔ Answer: B

You might also like