Skip to content

Chapter -1 Computer Science MCQ

Chapter -1 Computer Science

MCQ

Chapter 1 & Chapter 2: Python Revision Tour-I and Python Revision Tour-II

1. Which function is used to find the length of a string?

  • (a) size()
  • (b) length()
  • (c) len()
  • (d) count()

Answer: (c) len()

2. What is the output of len("Computer")?

  • (a) 7
  • (b) 8
  • (c) 9
  • (d) 10

Answer: (b) 8

3. Which operator is used for string concatenation?

  • (a) *
  • (b) &
  • (c) +
  • (d) %

Answer: (c) +

4. What is the output of "Python"*3?

  • (a) Python3
  • (b) Python Python Python
  • (c) PythonPythonPython
  • (d) Error

Answer: (c) PythonPythonPython

5. Strings in Python are:

  • (a) Mutable
  • (b) Immutable
  • (c) Numeric
  • (d) Dynamic

Answer: (b) Immutable

6. Which method converts a string into uppercase?

  • (a) upper()
  • (b) uppercase()
  • (c) capital()
  • (d) title()

Answer: (a) upper()

7. Which method converts a string into lowercase?

  • (a) small()
  • (b) lower()
  • (c) lowercase()
  • (d) down()

Answer: (b) lower()

8. What is the index of the first character in a string?

  • (a) 1
  • (b) -1
  • (c) 0
  • (d) 2

Answer: (c) 0

9. What is the output of "Python"[2]?

  • (a) P
  • (b) y
  • (c) t
  • (d) h

Answer: (c) t

10. Which function is used to take input from the user?

  • (a) get()
  • (b) read()
  • (c) scan()
  • (d) input()

Answer: (d) input()

11. Which data type stores decimal values?

  • (a) int
  • (b) float
  • (c) bool
  • (d) str

Answer: (b) float

12. What is the output of 10//3?

  • (a) 3.33
  • (b) 3
  • (c) 4
  • (d) 1

Answer: (b) 3

13. Which operator returns the remainder?

  • (a) //
  • (b) **
  • (c) %
  • (d) /

Answer: (c) %

14. Which keyword is used to define a function?

  • (a) define
  • (b) func
  • (c) def
  • (d) function

Answer: (c) def

15. A function that calls itself is called:

  • (a) Recursive Function
  • (b) Nested Function
  • (c) Lambda Function
  • (d) Built-in Function

Answer: (a) Recursive Function

16. Which statement is used to terminate a loop?

  • (a) stop
  • (b) continue
  • (c) break
  • (d) pass

Answer: (c) break

17. Which statement skips the current iteration?

  • (a) pass
  • (b) break
  • (c) continue
  • (d) exit

Answer: (c) continue

18. Which collection type is ordered and mutable?

  • (a) Tuple
  • (b) Set
  • (c) Dictionary
  • (d) List

Answer: (d) List

19. Which bracket is used for lists?

  • (a) ()
  • (b) []
  • (c) {}
  • (d) <>

Answer: (b) []

20. Which bracket is used for tuples?

  • (a) ()
  • (b) []
  • (c) {}
  • (d) <>

Answer: (a) ()

21. Dictionaries store data in:

  • (a) Sequence
  • (b) Key-Value pairs
  • (c) Indexes only
  • (d) Rows

Answer: (b) Key-Value pairs

22. Which bracket is used for dictionaries?

  • (a) ()
  • (b) []
  • (c) {}
  • (d) <>

Answer: (c) {}

23. Which function returns the type of an object?

  • (a) datatype()
  • (b) kind()
  • (c) type()
  • (d) typeof()

Answer: (c) type()

24. What is the output of bool(0)?

  • (a) True
  • (b) False
  • (c) 0
  • (d) Error

Answer: (b) False

25. Which operator is used for exponentiation?

  • (a) ^
  • (b) **
  • (c) //
  • (d) %

Answer: (b) **

26. Which method removes leading and trailing spaces?

  • (a) trim()
  • (b) remove()
  • (c) strip()
  • (d) clean()

Answer: (c) strip()

27. Which method splits a string into a list?

  • (a) divide()
  • (b) split()
  • (c) partition()
  • (d) slice()

Answer: (b) split()

28. What is the output of round(4.6)?

  • (a) 4
  • (b) 5
  • (c) 4.6
  • (d) Error

Answer: (b) 5

29. Which module contains mathematical functions?

  • (a) random
  • (b) string
  • (c) math
  • (d) os

Answer: (c) math

30. Which function generates random integers?

  • (a) randint()
  • (b) randomint()
  • (c) integer()
  • (d) random()

Answer: (a) randint()

31. Which keyword creates an anonymous function?

  • (a) lambda
  • (b) func
  • (c) def
  • (d) anonymous

Answer: (a) lambda

32. What is the output of abs(-15)?

  • (a) -15
  • (b) 15
  • (c) 0
  • (d) Error

Answer: (b) 15

33. Which statement handles exceptions?

  • (a) if
  • (b) switch
  • (c) try-except
  • (d) catch

Answer: (c) try-except

34. What is the output of max(10,20,5)?

  • (a) 5
  • (b) 10
  • (c) 20
  • (d) Error

Answer: (c) 20

35. Which function returns the smallest value?

  • (a) minimum()
  • (b) low()
  • (c) min()
  • (d) small()

Answer: (c) min()

36. Which string method counts occurrences?

  • (a) count()
  • (b) find()
  • (c) search()
  • (d) index()

Answer: (a) count()

37. Which method finds the position of a substring?

  • (a) count()
  • (b) locate()
  • (c) find()
  • (d) search()

Answer: (c) find()

38. Which loop executes at least once?

  • (a) for
  • (b) while
  • (c) do-while
  • (d) None in Python

Answer: (d) None in Python

39. Which function converts a string to an integer?

  • (a) str()
  • (b) float()
  • (c) int()
  • (d) bool()

Answer: (c) int()

40. What is the output of list("ABC")?

  • (a) ['ABC']
  • (b) ['A','B','C']
  • (c) ABC
  • (d) Error

Answer: (b) ['A','B','C']

41. Which function converts data into a string?

  • (a) int()
  • (b) float()
  • (c) str()
  • (d) bool()

Answer: (c) str()

42. Which keyword is used to import a module?

  • (a) include
  • (b) using
  • (c) import
  • (d) module

Answer: (c) import

43. Which operator checks equality?

  • (a) =
  • (b) ==
  • (c) !=
  • (d) <=

Answer: (b) ==

44. What is the output of 10 > 5?

  • (a) True
  • (b) False
  • (c) 10
  • (d) 5

Answer: (a) True

45. Which data type stores True/False values?

  • (a) str
  • (b) int
  • (c) bool
  • (d) float

Answer: (c) bool

46. What is the output of 5 + 2 * 3?

  • (a) 21
  • (b) 11
  • (c) 15
  • (d) 7

Answer: (b) 11

47. Which operator has the highest precedence?

  • (a) +
  • (b) *
  • (c) **
  • (d) %

Answer: (c) **

48. Which function is used to display output?

  • (a) display()
  • (b) write()
  • (c) show()
  • (d) print()

Answer: (d) print()

49. Python is a:

  • (a) Low-level language
  • (b) High-level language
  • (c) Machine language
  • (d) Assembly language

Answer: (b) High-level language

50. Python was developed by:

  • (a) Dennis Ritchie
  • (b) James Gosling
  • (c) Guido van Rossum
  • (d) Tim Berners-Lee

Answer: (c) Guido van Rossum