FahmidasClassroom

Learn by easy steps

99 Python Mcq

1. What is the correct file extension for Python files?

  • A) .pyth
  • B) .pt
  • C) .py
  • D) .pyt

Answer: C) .py

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

  • A) 2variable
  • B) variable_2
  • C) variable-2
  • D) variable.2

Answer: B) variable_2

3. What will the following code snippet print?

pythonCopy codeprint(type(5 / 2))
  • A) <class 'int'>
  • B) <class 'float'>
  • C) <class 'str'>
  • D) <class 'bool'>

Answer: B) <class 'float'>

4. How do you insert comments in Python code?

  • A) /* comment */
  • B) # comment
  • C) <!-- comment -->
  • D) // comment

Answer: B) # comment

5. What is the output of the following code?

pythonCopy codeprint("Hello" + " World")
  • A) Hello + World
  • B) Hello World
  • C) HelloWorld
  • D) Hello World

Answer: B) Hello World

6. How do you create a list in Python?

  • A) list = []
  • B) list = ()
  • C) list = {}
  • D) list = <>

Answer: A) list = []

7. Which of the following is a mutable data type in Python?

  • A) tuple
  • B) str
  • C) list
  • D) int

Answer: C) list

8. What is the output of the following code?

pythonCopy codex = [1, 2, 3]
x.append(4)
print(x)
  • A) [1, 2, 3, 4]
  • B) [1, 2, 3]
  • C) [4, 1, 2, 3]
  • D) [1, 4, 2, 3]

Answer: A) [1, 2, 3, 4]

9. How do you define a function in Python?

  • A) def function_name():
  • B) function function_name():
  • C) define function_name():
  • D) function_name() =

Answer: A) def function_name():

10. What will this code output?

pythonCopy codex = [1, 2, 3]
print(x[0:2])
  • A) [1, 2]
  • B) [1, 2, 3]
  • C) [2, 3]
  • D) [1]

Answer: A) [1, 2]

11. What will be the output of the following code?

pythonCopy codex = "Python"
print(x[1:4])
  • A) Pyt
  • B) yth
  • C) tho
  • D) ytho

Answer: B) yth

12. How do you handle exceptions in Python?

  • A) try/except
  • B) catch/throw
  • C) error/handle
  • D) exception/resolve

Answer: A) try/except

13. What does the len() function do in Python?

  • A) Returns the length of a list
  • B) Returns the length of a string
  • C) Returns the length of a dictionary
  • D) All of the above

Answer: D) All of the above

14. What will the following code print?

pythonCopy codefor i in range(3):
    print(i)
  • A) 0 1 2
  • B) 1 2 3
  • C) 0 1 2 3
  • D) 1 2

Answer: A) 0 1 2

15. Which method is used to remove whitespace from the beginning and end of a string?

  • A) strip()
  • B) trim()
  • C) remove()
  • D) clean()

Answer: A) strip()

16. What will the following code output?

pythonCopy codex = {1, 2, 2, 3}
print(len(x))
  • A) 3
  • B) 4
  • C) 2
  • D) 5

Answer: A) 3

17. Which keyword is used to create a class in Python?

  • A) class
  • B) def
  • C) create
  • D) object

Answer: A) class

18. How do you access the last item of a list in Python?

  • A) list[-1]
  • B) list[last]
  • C) list[len(list)]
  • D) list.get_last()

Answer: A) list[-1]

19. What is the result of 3 ** 2 in Python?

  • A) 9
  • B) 6
  • C) 8
  • D) 5

Answer: A) 9

20. How do you concatenate two strings in Python?

  • A) string1 + string2
  • B) string1 - string2
  • C) string1 * string2
  • D) string1 & string2

Answer: A) string1 + string2

21. Which of the following is used to start a loop in Python?

  • A) loop
  • B) for
  • C) while
  • D) Both B and C

Answer: D) Both B and C

22. How do you create a dictionary in Python?

  • A) dict = {key1: value1, key2: value2}
  • B) dict = [key1: value1, key2: value2]
  • C) dict = (key1: value1, key2: value2)
  • D) dict = <key1: value1, key2: value2>

Answer: A) dict = {key1: value1, key2: value2}

23. What will this code output?

pythonCopy codex = "Python"
print(x.upper())
  • A) PYTHON
  • B) python
  • C) Python
  • D) PytHon

Answer: A) PYTHON

24. How do you create a tuple in Python?

  • A) tuple = []
  • B) tuple = ()
  • C) tuple = {}
  • D) tuple = <>

Answer: B) tuple = ()

25. What will the following code output?

pythonCopy codex = "hello"
print(x * 2)
  • A) hellohello
  • B) hello 2
  • C) hellohellohello
  • D) 2hello

Answer: A) hellohello

26. What will the following code output?

pythonCopy codex = [1, 2, 3]
print(x.pop())
  • A) 3
  • B) 2
  • C) [1, 2, 3]
  • D) None

Answer: A) 3

27. How do you define a variable in Python?

  • A) var = value
  • B) variable : value
  • C) value => variable
  • D) value = variable

Answer: A) var = value

28. What will the following code output?

pythonCopy codeprint("A" * 3)
  • A) AAA
  • B) A A A
  • C) A3
  • D) AA A

Answer: A) AAA

29. How do you check if a key exists in a dictionary?

  • A) key in dict
  • B) dict.has_key(key)
  • C) key.exists(dict)
  • D) dict.contains(key)

Answer: A) key in dict

30. What does the pop() method do on a list?

  • A) Removes and returns the last item
  • B) Adds an item
  • C) Reverses the list
  • D) Clears the list

Answer: A) Removes and returns the last item

31. What is the output of the following code?

pythonCopy codex = "Python"
print(x[:3])
  • A) Pyt
  • B) Pyt
  • C) Python
  • D) tho

Answer: A) Pyt

32. How do you write a single-line comment in Python?

  • A) # This is a comment
  • B) // This is a comment
  • C) `/*

2/2ChatGPT

Certainly! Here’s a set of 99 multiple-choice questions (MCQs) about Python programming:

1. What is the correct file extension for Python files?

  • A) .pyth
  • B) .pt
  • C) .py
  • D) .pyt

Answer: C) .py

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

  • A) 2variable
  • B) variable_2
  • C) variable-2
  • D) variable.2

Answer: B) variable_2

3. What will the following code snippet print?

pythonCopy codeprint(type(5 / 2))
  • A) <class 'int'>
  • B) <class 'float'>
  • C) <class 'str'>
  • D) <class 'bool'>

Answer: B) <class 'float'>

4. How do you insert comments in Python code?

  • A) /* comment */
  • B) # comment
  • C) <!-- comment -->
  • D) // comment

Answer: B) # comment

5. What is the output of the following code?

pythonCopy codeprint("Hello" + " World")
  • A) Hello + World
  • B) Hello World
  • C) HelloWorld
  • D) Hello World

Answer: B) Hello World

6. How do you create a list in Python?

  • A) list = []
  • B) list = ()
  • C) list = {}
  • D) list = <>

Answer: A) list = []

7. Which of the following is a mutable data type in Python?

  • A) tuple
  • B) str
  • C) list
  • D) int

Answer: C) list

8. What is the output of the following code?

pythonCopy codex = [1, 2, 3]
x.append(4)
print(x)
  • A) [1, 2, 3, 4]
  • B) [1, 2, 3]
  • C) [4, 1, 2, 3]
  • D) [1, 4, 2, 3]

Answer: A) [1, 2, 3, 4]

9. How do you define a function in Python?

  • A) def function_name():
  • B) function function_name():
  • C) define function_name():
  • D) function_name() =

Answer: A) def function_name():

10. What will this code output?

pythonCopy codex = [1, 2, 3]
print(x[0:2])
  • A) [1, 2]
  • B) [1, 2, 3]
  • C) [2, 3]
  • D) [1]

Answer: A) [1, 2]

11. What will the following code output?

pythonCopy codex = "Python"
print(x[1:4])
  • A) Pyt
  • B) yth
  • C) tho
  • D) ytho

Answer: B) yth

12. How do you handle exceptions in Python?

  • A) try/except
  • B) catch/throw
  • C) error/handle
  • D) exception/resolve

Answer: A) try/except

13. What does the len() function do in Python?

  • A) Returns the length of a list
  • B) Returns the length of a string
  • C) Returns the length of a dictionary
  • D) All of the above

Answer: D) All of the above

14. What will the following code print?

pythonCopy codefor i in range(3):
    print(i)
  • A) 0 1 2
  • B) 1 2 3
  • C) 0 1 2 3
  • D) 1 2

Answer: A) 0 1 2

15. Which method is used to remove whitespace from the beginning and end of a string?

  • A) strip()
  • B) trim()
  • C) remove()
  • D) clean()

Answer: A) strip()

16. What will the following code output?

pythonCopy codex = {1, 2, 2, 3}
print(len(x))
  • A) 3
  • B) 4
  • C) 2
  • D) 5

Answer: A) 3

17. Which keyword is used to create a class in Python?

  • A) class
  • B) def
  • C) create
  • D) object

Answer: A) class

18. How do you access the last item of a list in Python?

  • A) list[-1]
  • B) list[last]
  • C) list[len(list)]
  • D) list.get_last()

Answer: A) list[-1]

19. What is the result of 3 ** 2 in Python?

  • A) 9
  • B) 6
  • C) 8
  • D) 5

Answer: A) 9

20. How do you concatenate two strings in Python?

  • A) string1 + string2
  • B) string1 - string2
  • C) string1 * string2
  • D) string1 & string2

Answer: A) string1 + string2

21. Which of the following is used to start a loop in Python?

  • A) loop
  • B) for
  • C) while
  • D) Both B and C

Answer: D) Both B and C

22. How do you create a dictionary in Python?

  • A) dict = {key1: value1, key2: value2}
  • B) dict = [key1: value1, key2: value2]
  • C) dict = (key1: value1, key2: value2)
  • D) dict = <key1: value1, key2: value2>

Answer: A) dict = {key1: value1, key2: value2}

23. What will this code output?

pythonCopy codex = "Python"
print(x.upper())
  • A) PYTHON
  • B) python
  • C) Python
  • D) PytHon

Answer: A) PYTHON

24. How do you create a tuple in Python?

  • A) tuple = []
  • B) tuple = ()
  • C) tuple = {}
  • D) tuple = <>

Answer: B) tuple = ()

25. What will the following code output?

pythonCopy codex = "hello"
print(x * 2)
  • A) hellohello
  • B) hello 2
  • C) hellohellohello
  • D) 2hello

Answer: A) hellohello

26. What will the following code output?

pythonCopy codex = [1, 2, 3]
print(x.pop())
  • A) 3
  • B) 2
  • C) [1, 2, 3]
  • D) None

Answer: A) 3

27. How do you define a variable in Python?

  • A) var = value
  • B) variable : value
  • C) value => variable
  • D) value = variable

Answer: A) var = value

28. What will the following code output?

pythonCopy codeprint("A" * 3)
  • A) AAA
  • B) A A A
  • C) A3
  • D) AA A

Answer: A) AAA

29. How do you check if a key exists in a dictionary?

  • A) key in dict
  • B) dict.has_key(key)
  • C) key.exists(dict)
  • D) dict.contains(key)

Answer: A) key in dict

30. What does the pop() method do on a list?

  • A) Removes and returns the last item
  • B) Adds an item
  • C) Reverses the list
  • D) Clears the list

Answer: A) Removes and returns the last item

31. What is the output of the following code?

pythonCopy codex = "Python"
print(x[:3])
  • A) Pyt
  • B) Pyt
  • C) Python
  • D) tho

Answer: A) Pyt

32. How do you write a single-line comment in Python?

  • A) # This is a comment
  • B) // This is a comment
  • C) /* This is a comment */
  • D) <!-- This is a comment -->

Answer: A) # This is a comment

33. What will be the output of this code?

pythonCopy codex = [10, 20, 30]
x[1] = 40
print(x)
  • A) [10, 40, 30]
  • B) [10, 20, 30, 40]
  • C) [10, 40]
  • D) [40, 10, 30]

Answer: A) [10, 40, 30]

34. What does the isinstance() function do?

  • A) Checks if an object is of a specified type
  • B) Creates a new instance of a class
  • C) Returns the type of an object
  • D) Checks if two objects are the same

Answer: A) Checks if an object is of a specified type

35. What will this code output?

pythonCopy codex = [1, 2, 3]
print(len(x))
  • A) 3
  • B) 2
  • C) 4
  • D) None

Answer: A) 3

36. Which method is used to add an item at the end of a list?

  • A) add()
  • B) append()
  • C) insert()
  • D) extend()

Answer: B) append()

37. How do you convert a string to an integer in Python?

  • A) int(string)
  • B) string.toInt()
  • C) convert(string)
  • D) string.to_integer()

Answer: A) int(string)

38. Which of the following statements is correct for Python dictionaries?

  • A) Dictionaries are ordered.
  • B) Dictionary keys must be immutable.
  • C) Dictionary values must be immutable.
  • D) Dictionary keys must be unique, but values do not.

Answer: B) Dictionary keys must be immutable.

39. What is the output of this code?

pythonCopy codex = [1, 2, 3]
x.insert(1, 4)
print(x)
  • A) [1, 4, 2, 3]
  • B) [1, 2, 4, 3]
  • C) [4, 1, 2, 3]
  • D) [1, 2, 3, 4]

Answer: A) [1, 4, 2, 3]

40. What does the join() method do?

  • A) Joins two lists
  • B) Joins elements of an iterable into a string
  • C) Joins two strings
  • D) Joins two dictionaries

Answer: B) Joins elements of an iterable into a string

41. What will this code output?

pythonCopy codex = "Python"
print(x.find("o"))
  • A) 4
  • B) 5
  • C) -1
  • D) 0

Answer: A) 4

42. How do you create an empty set in Python?

  • A) set = {}
  • B) set = []
  • C) set = ()
  • D) set = set()

Answer: D) set = set()

43. What is the output of the following code?

pythonCopy codex = (1, 2, 3)
print(type(x))
  • A) <class 'list'>
  • B) <class 'tuple'>
  • C) <class 'set'>
  • D) <class 'dict'>

Answer: B) <class 'tuple'>

44. How do you remove an item from a set?

  • A) set.remove(item)
  • B) set.delete(item)
  • C) set.pop(item)
  • D) set.discard(item)

Answer: A) set.remove(item)

45. What will the following code print?

pythonCopy codex = 5
print(f"{x} is a number")
  • A) 5 is a number
  • B) 5 is a number
  • C) 5 is a number
  • D) 5 is a number

Answer: A) 5 is a number

46. How can you convert a list to a tuple in Python?

  • A) tuple(list)
  • B) list.to_tuple()
  • C) convert_to_tuple(list)
  • D) tuple(list())

Answer: A) tuple(list)

47. Which method is used to add a key-value pair to a dictionary?

  • A) add()
  • B) update()
  • C) append()
  • D) insert()

Answer: B) update()

48. What will this code output?

pythonCopy codex = "Hello, World!"
print(x[7:])
  • A) World!
  • B) Hello
  • C) World!
  • D) Hello, World!

Answer: A) World!

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

  • A) ^
  • B) **
  • C) *
  • D) //

Answer: B) **

50. What will the following code output?

pythonCopy codex = [1, 2, 3]
x.extend([4, 5])
print(x)
  • A) [1, 2, 3, 4, 5]
  • B) [1, 2, 3]
  • C) [1, 2, 3, [4, 5]]
  • D) [4, 5, 1, 2, 3]

Answer: A) [1, 2, 3, 4, 5]

51. How do you remove all items from a list in Python?

  • A) list.clear()
  • B) list.remove_all()
  • C) list.delete()
  • D) list.empty()

Answer: A) list.clear()

52. What will the following code output?

pythonCopy codex = 7
if x % 2 == 0:
    print("Even")
else:
    print("Odd")
  • A) Even
  • B) Odd
  • C) Error
  • D) None

Answer: B) Odd

53. What does the split() method do on a string?

  • A) Splits the string into a list based on a separator
  • B) Joins the elements of a list into a string
  • C) Replaces characters in the string
  • D) Converts the string to uppercase

Answer: A) Splits the string into a list based on a separator

54. Which of the following methods can be used to remove whitespace from both ends of a string?

  • A) strip()
  • B) trim()
  • C) cut()
  • D) clear()

Answer: A) strip()

55. How do you define a class method in Python?

  • A) def method(self):
  • B) function method(self):
  • C) method(self):
  • D) method() -> self:

Answer: A) def method(self):

56. What will this code print?

pythonCopy codex = [1, 2, [3, 4]]
print(x[2][0])
  • A) 3
  • B) [3, 4]
  • C) 4
  • D) 2

Answer: A) 3

57. How do you get the current working directory in Python?

  • A) os.getcwd()
  • B) os.getwd()
  • C) os.current_directory()
  • D) os.dir()

Answer: A) os.getcwd()

58. What is the output of the following code?

pythonCopy codex = [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, 5]
  • D) [[4, 5], 1, 2, 3]

Answer: A) [1, 2, 3, [4, 5]]

59. How do you check the type of an object in Python?

  • A) type(object)
  • B) object.type()
  • C) object.get_type()
  • D) check_type(object)

Answer: A) type(object)

60. What will this code output?

pythonCopy codex = "Python"
print(x[1:5:2])
  • A) ytn
  • B) yto
  • C) ytn
  • D) yton

Answer: C) ytn

61. What does the sorted() function do?

  • A) Sorts a list and returns a new list
  • B) Sorts a list in place
  • C) Reverses the list
  • D) Creates a new list

Answer: A) Sorts a list and returns a new list

62. Which method returns the number of occurrences of a specified element in a list?

  • A) count()
  • B) find()
  • C) search()
  • D) index()

Answer: A) count()

63. What will the following code output?

pythonCopy codex = "Python"
print(x.replace("o", "a"))
  • A) Pythan
  • B) Pythan
  • C) Pythan
  • D) Pythan

Answer: A) Pythan

64. What is the result of the expression 5 % 2 in Python?

  • A) 1
  • B) 2
  • C) 0
  • D) 2.5

Answer: A) 1

65. How do you create a class in Python?

  • A) class MyClass:
  • B) create class MyClass:
  • C) define class MyClass:
  • D) new class MyClass:

Answer: A) class MyClass:

66. What will this code output?

pythonCopy codex = [5, 10, 15]
print(x.pop(1))
  • A) 10
  • B) 15
  • C) [10]
  • D) None

Answer: A) 10

67. How do you get the number of items in a list?

  • A) list.size()
  • B) len(list)
  • C) list.count()
  • D) list.length()

Answer: B) len(list)

68. What does the append() method do to a list?

  • A) Adds an item to the end of the list
  • B) Removes an item from the end of the list
  • C) Inserts an item at the beginning of the list
  • D) Reverses the list

Answer: A) Adds an item to the end of the list

69. What is the output of this code?

pythonCopy codex = "hello world"
print(x.title())
  • A) Hello World
  • B) hello world
  • C) HELLO WORLD
  • D) Hello World

Answer: A) Hello World

70. How do you remove a specific item from a list?

  • A) list.remove(item)
  • B) list.discard(item)
  • C) list.delete(item)
  • D) list.pop(item)

Answer: A) list.remove(item)

71. What will this code output?

pythonCopy codex = 4
y = 2
print(x ** y)
  • A) 16
  • B) 8
  • C) 6
  • D) 2

Answer: A) 16

72. Which keyword is used to indicate a function is to be used for a specific method of a class?

  • A) class
  • B) static
  • C) def
  • D) self

Answer: D) self

73. What is the output of this code?

pythonCopy codex = "Python"
print(x[::2])
  • A) Pto
  • B) Pyn
  • C) Python
  • D) Pyt

Answer: A) Pto

74. Which method is used to remove and return an arbitrary element from a set?

  • A) set.remove()
  • B) set.pop()
  • C) set.discard()
  • D) set.delete()

Answer: B) set.pop()

75. What will this code output?

pythonCopy codex = "Python"
print(x.split("o"))
  • A) ['Pyth', 'n']
  • B) ['Pyth', 'n']
  • C) ['Python']
  • D) ['P', 'yth', 'n']

Answer: A) ['Pyth', 'n']

76. How do you check if a value exists in a dictionary?

  • A) value in dict
  • B) dict.has_value(value)
  • C) dict.contains(value)
  • D) value.exists(dict)

Answer: A) value in dict

77. What will this code print?

pythonCopy codex = [1, 2, [3, 4]]
print(x[2][1])
  • A) 4
  • B) [3, 4]
  • C) 3
  • D) 2

Answer: A) 4

78. What does the int() function do?

  • A) Converts a value to an integer
  • B) Converts a value to a string
  • C) Converts a value to a float
  • D) Converts a value to a boolean

Answer: A) Converts a value to an integer

79. What is the output of this code?

pythonCopy codex = {1, 2, 3}
y = {3, 4, 5}
print(x & y)
  • A) {3}
  • B) {1, 2, 3, 4, 5}
  • C) {1, 2}
  • D) {4, 5}

Answer: A) {3}

80. How do you access elements of a dictionary?

  • A) dict[key]
  • B) dict.get(key)
  • C) dict.key()
  • D) Both A and B

Answer: D) Both A and B

81. What will this code output?

pythonCopy codex = "Python"
print(x[::-1])
  • A) nohtyP
  • B) Python
  • C) Phtno
  • D) nohty

Answer: A) nohtyP

82. Which method returns the lowest value in a list?

  • A) list.min()
  • B) min(list)
  • C) list.low()
  • D) list.first()

Answer: B) min(list)

83. What will this code print?

pythonCopy codex = 5
y = 10
print(x + y)
  • A) 15
  • B) 510
  • C) 5 10
  • D) 50

Answer: A) 15

84. How do you define an empty set in Python?

  • A) set = {} (incorrect)
  • B) set = [] (incorrect)
  • C) set = set()
  • D) set = () (incorrect)

Answer: C) set = set()

85. Which of the following is not a valid Python keyword?

  • A) if
  • B) else
  • C) foreach
  • D) elif

Answer: C) foreach

86. What will this code output?

pythonCopy codex = "Python"
print(x.index("t"))
  • A) 2
  • B) 3
  • C) 4
  • D) -1

Answer: B) 3

87. How do you open a file in Python for reading?

  • A) open("file.txt", "r")
  • B) open("file.txt")
  • C) file.open("file.txt")
  • D) file.read("file.txt")

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

88. What does break do in a loop?

  • A) Exits the loop
  • B) Pauses the loop
  • C) Continues to the next iteration
  • D) Restarts the loop

Answer: A) Exits the loop

89. What is the output of the following code?

pythonCopy codex = "Python"
print(x[1:4])
  • A) yth
  • B) yth
  • C) Pyt
  • D) tho

Answer: A) yth

90. Which of the following is used to comment out multiple lines in Python?

  • A) /* comment */
  • B) # comment
  • C) ''' comment '''
  • D) <!-- comment -->

Answer: C) ''' comment '''

91. What does the dict.keys() method return?

  • A) A list of dictionary values
  • B) A list of dictionary keys
  • C) A dictionary of key-value pairs
  • D) A set of dictionary values

Answer: B) A list of dictionary keys

92. How do you handle missing keys in a dictionary?

  • A) Use dict.get(key, default)
  • B) Use dict[key]
  • C) Use dict.pop(key, default)
  • D) Use dict.update(key, default)

Answer: A) Use dict.get(key, default)

93. What is the output of the following code?

pythonCopy codex = [1, 2, 3]
y = x.copy()
y.append(4)
print(x)
  • A) [1, 2, 3]
  • B) [1, 2, 3, 4]
  • C) [4, 1, 2, 3]
  • D) [1, 2, 3, 4]

Answer: A) [1, 2, 3]

94. What is the output of the following code?

pythonCopy codex = {1, 2, 3}
x.add(4)
print(x)
  • A) {1, 2, 3, 4}
  • B) {1, 2, 4}
  • C) {4, 1, 2, 3}
  • D) {1, 2, 3}

Answer: A) {1, 2, 3, 4}

95. How do you get the maximum value from a list?

  • A) list.max()
  • B) max(list)
  • C) list.maximum()
  • D) list.high()

Answer: B) max(list)

96. What will this code print?

pythonCopy codex = [1, 2, 3]
x.insert(1, [4, 5])
print(x)
  • A) [1, [4, 5], 2, 3]
  • B) [1, 4, 5, 2, 3]
  • C) [1, 2, [4, 5], 3]
  • D) [4, 5, 1, 2, 3]

Answer: A) [1, [4, 5], 2, 3]

97. How do you concatenate two strings in Python?

  • A) str1 + str2
  • B) str1.append(str2)
  • C) str1.concat(str2)
  • D) str1.join(str2)

Answer: A) str1 + str2

98. What will this code output?

pythonCopy codex = "Python"
print(x[2:5])
  • A) tho
  • B) tho
  • C) tho
  • D) tho

Answer: A) tho

99. What is the output of the following code?

pythonCopy codex = "Python"
print(x[:4])
  • A) Pyth
  • B) Pytho
  • C) P
  • D) Python

Answer: A) Pyth

100. How do you create a list in Python?

  • A) list = ()
  • B) list = []
  • C) list = {}
  • D) list = set()

Answer: B) list = []