Python/Python Mcq Set 7 Sample Test,Sample questions

Question:
 Suppose list1 = [0.5 * x for x in range(0, 4)], list1 is:

1. [0, 1, 2, 3]

2. [0, 1, 2, 3, 4]

3.[0.0, 0.5, 1.0, 1.5]

4.[0.0, 0.5, 1.0, 1.5, 2.0]

Posted Date:-2021-12-30 22:18:48


Question:
 Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?

1. 3

2. 5

3.25

4. 1

Posted Date:-2021-12-30 22:15:11


Question:
 Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?

1. 5

2.4

3.None

4. Error

Posted Date:-2021-12-30 22:14:24


Question:
 To insert 5 to the third position in list1, we use which command?

1. list1.insert(3, 5)

2. list1.insert(2, 5)

3.list1.add(3, 5)

4. list1.append(3, 5)

Posted Date:-2021-12-30 22:20:01


Question:
 What will be the output of the following Python code snippet?

print('ab
cd
ef'.splitlines())

1. [‘ab’, ‘cd’, ‘ef’]

2. [‘ab ’, ‘cd ’, ‘ef ’]

3.[‘ab ’, ‘cd ’, ‘ef’]

4. [‘ab’, ‘cd’, ‘ef ’]

Posted Date:-2021-12-30 10:36:36


Question:
 What will be the output of the following Python code snippet?

print('abcdef12'.replace('cd', '12'))

1.ab12ef12

2.abcdef12

3. ab12efcd

4.none of the mentioned

Posted Date:-2021-12-30 10:27:43


Question:
 What will be the output of the following Python code snippet?

print('abef'.replace('cd', '12'))

1.abef

2.12

3.error

4.none of the mentioned

Posted Date:-2021-12-30 10:28:07


Question:
 What will be the output of the following Python code?

>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']
>>>print(names[-1][-1])

1.A

2.Daman

3.Error

4. n

Posted Date:-2021-12-30 22:17:54


Question:
 What will be the output of the following Python code?

print('cba'.maketrans('abc', '123'))

1.{97: 49, 98: 50, 99: 51}

2.{65: 49, 66: 50, 67: 51}

3.321

4.123

Posted Date:-2021-12-30 10:16:02


Question:
 Which of the following commands will create a list?

1. list1 = list()

2. list1 = list()

3. list1 = list([1, 2, 3])

4.all of the mentioned

Posted Date:-2021-12-30 22:13:36


Question:
Suppose list1 is [1, 3, 2], What is list1 * 2?

1.[2, 6, 4]

2. [1, 3, 2, 1, 3]

3.[1, 3, 2, 1, 3, 2]

4. [1, 3, 2, 3, 2, 1]

Posted Date:-2021-12-30 22:18:22


Question:
Suppose list1 is [1, 5, 9], what is sum(list1)?

1.1

2.9

3.15

4. Error

Posted Date:-2021-12-30 22:15:34


Question:
Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?

1.Error

2.None

3.25

4.2

Posted Date:-2021-12-30 22:16:54


Question:
Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?

1. [2, 33, 222, 14]

2. Error

3.25

4. [25, 14, 222, 33, 2]

Posted Date:-2021-12-30 22:17:24


Question:
Suppose list1 is [2445,133,12454,123], what is max(list1)?

1. 2445

2. 133

3.12454

4.123

Posted Date:-2021-12-30 22:14:47


Question:
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?

1. [3, 4, 5, 20, 5, 25, 1, 3]

2.[1, 3, 3, 4, 5, 5, 20, 25]

3.[25, 20, 5, 5, 4, 3, 3, 1]

4. [3, 1, 25, 5, 20, 5, 4, 3]

Posted Date:-2021-12-30 22:21:51


Question:
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?

1.0

2.4

3.1

4.2

Posted Date:-2021-12-30 22:21:04


Question:
Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?

1.0

2.1

3.4

4.2

Posted Date:-2021-12-30 22:20:46


Question:
Suppose list1 is [4, 2, 2, 4, 5, 2, 1, 0], Which of the following is correct syntax for slicing operation?

1. print(list1[0])

2. print(list1[:2])

3. print(list1[:-2])

4.all of the mentioned

Posted Date:-2021-12-30 22:16:26


Question:
Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5])?

1.[3, 4, 5, 20, 5, 25, 1, 3, 34, 5]

2.[1, 3, 3, 4, 5, 5, 20, 25, 34, 5]

3. [25, 20, 5, 5, 4, 3, 3, 1, 34, 5]

4.[1, 3, 4, 5, 20, 5, 25, 3, 34, 5]

Posted Date:-2021-12-30 22:22:13


Question:
Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop(1)?

1.[3, 4, 5, 20, 5, 25, 1, 3]

2.[1, 3, 3, 4, 5, 5, 20, 25]

3.[3, 5, 20, 5, 25, 1, 3]

4.[1, 3, 4, 5, 20, 5, 25]

Posted Date:-2021-12-30 22:22:38


Question:
To add a new element to a list we use which command?

1. list1.add(5)

2.list1.append(5)

3.list1.addLast(5)

4. list1.addEnd(5)

Posted Date:-2021-12-30 22:19:36


Question:
To remove string “hello” from list1, we use which command?

1. list1.remove(“hello”)

2. list1.remove(“hello”)

3.list1.removeAll(“hello”)

4. list1.removeOne(“hello”)

Posted Date:-2021-12-30 22:20:23


Question:
To shuffle the list(say list1) what function do we use?

1. list1.shuffle()

2. shuffle(list1)

3. random.shuffle(list1)

4. random.shuffleList(list1)

Posted Date:-2021-12-30 22:15:59


Question:
What is the output when we execute list(“hello”)?

1.[‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

2. [‘hello’]

3. [‘llo’]

4. [‘olleh’]

Posted Date:-2021-12-30 22:13:59


Question:
What will be the output of the following Python code snippet?

print('ab cd ef'.title())

1.Ab cd ef

2.Ab cd eF

3.Ab Cd Ef

4.none of the mentioned

Posted Date:-2021-12-30 10:37:25


Question:
What will be the output of the following Python code snippet?

print('ab cd-ef'.title())

1.Ab cd-ef

2. Ab Cd-ef

3.Ab Cd-Ef

4.none of the mentioned

Posted Date:-2021-12-30 10:38:06


Question:
What will be the output of the following Python code snippet?

print('Ab!2'.swapcase())

1. AB!@

2. ab12

3.aB!2

4.aB1@

Posted Date:-2021-12-30 10:37:02


Question:
What will be the output of the following Python code snippet?

print('abcd'.translate('a'.maketrans('abc', 'bcd')))

1.bcde

2.abcd

3.error

4.bcdd

Posted Date:-2021-12-30 10:38:26


Question:
What will be the output of the following Python code snippet?

print('abcdefcdghcd'.split('cd', -1))

1. [‘ab’, ‘ef’, ‘gh’]

2.[‘ab’, ‘ef’, ‘gh’, ”]

3.(‘ab’, ‘ef’, ‘gh’)

4.(‘ab’, ‘ef’, ‘gh’, ”)

Posted Date:-2021-12-30 10:33:31


Question:
What will be the output of the following Python code snippet?

print('abcdefcdghcd'.split('cd', 0))

1. [‘abcdefcdghcd’]

2.‘abcdefcdghcd’

3. error

4.none of the mentioned

Posted Date:-2021-12-30 10:31:23


Question:
What will be the output of the following Python code snippet?

print('abcdefcdghcd'.split('cd', 2))

1. [‘ab’, ‘ef’, ‘ghcd’]

2. [‘ab’, ‘efcdghcd’]

3. [‘abcdef’, ‘ghcd’]

4.none of the mentioned

Posted Date:-2021-12-30 10:36:10


Question:
What will be the output of the following Python code snippet?

print('abcdefcdghcd'.split('cd'))

1. [‘ab’, ‘ef’, ‘gh’]

2.[‘ab’, ‘ef’, ‘gh’, ”]

3.(‘ab’, ‘ef’, ‘gh’)

4.(‘ab’, ‘ef’, ‘gh’, ”)

Posted Date:-2021-12-30 10:30:23


Question:
What will be the output of the following Python code snippet?

print('abcefd'.replace('cd', '12'))

1.ab1ef2

2.abcefd

3.ab1efd

4. ab12ed2

Posted Date:-2021-12-30 10:28:33


Question:
What will be the output of the following Python code snippet?

print('abef'.partition('cd'))

1.(‘abef’)

2.(‘abef’, ‘cd’, ”)

3. (‘abef’, ”, ”)

4.error

Posted Date:-2021-12-30 10:26:41


Question:
What will be the output of the following Python code snippet?

print('cd'.partition('cd'))

1.(‘cd’)

2.(”)

3.(‘cd’, ”, ”)

4.(”, ‘cd’, ”)

Posted Date:-2021-12-30 10:25:09


Question:
What will be the output of the following Python code snippet?

print('Hello World'.istitle())

1. True

2.False

3.None

4.Error

Posted Date:-2021-12-30 08:19:58


Question:
What will be the output of the following Python code snippet?

print('xyyxyyxyxyxxy'.replace('xy', '12', 0))

1. xyyxyyxyxyxxy

2.12y12y1212x12

3.12yxyyxyxyxxy

4.xyyxyyxyxyx12

Posted Date:-2021-12-30 10:29:12


Question:
What will be the output of the following Python code snippet?

print('xyyxyyxyxyxxy'.replace('xy', '12', 100))

1.xyyxyyxyxyxxy

2.12y12y1212x12

3. none of the mentioned

4.error

Posted Date:-2021-12-30 10:29:37


Question:
What will be the output of the following Python code?

>>>list1 = [11, 2, 23]
>>>list2 = [11, 2, 2]
>>>list1 < list2

1. True

2.False

3.Error

4.None

Posted Date:-2021-12-30 22:19:11


Question:
What will be the output of the following Python code?

print('''
 	foo'''.lstrip())

1. foo

2.foo

3. foo

4.none of the mentioned

Posted Date:-2021-12-30 08:23:00


Question:
What will be the output of the following Python code?

print('''
 	foo'''.lstrip())

1. foo

2.foo

3. foo

4.none of the mentioned

Posted Date:-2021-12-30 10:14:41


Question:
What will be the output of the following Python code?

print('1Rn@'.lower())

1. n

2.1rn@

3.rn

4.r

Posted Date:-2021-12-30 08:21:43


Question:
What will be the output of the following Python code?

print('a'.maketrans('ABC', '123'))

1.{97: 49, 98: 50, 99: 51}

2.{65: 49, 66: 50, 67: 51}

3.{97: 49}

4.1

Posted Date:-2021-12-30 10:16:30


Question:
What will be the output of the following Python code?

print('abcd'.partition('cd'))

1. (‘ab’, ‘cd’, ”)

2.(‘ab’, ‘cd’)

3.error

4.none of the mentioned

Posted Date:-2021-12-30 10:24:31


Question:
What will be the output of the following Python code?

print('abcdef'.partition('cd'))

1. (‘ab’, ‘ef’)

2.(‘abef’)

3.(‘ab’, ‘cd’, ‘ef’)

4.2

Posted Date:-2021-12-30 10:23:33


Question:
What will be the output of the following Python code?

print('abcdefcdgh'.partition('cd'))

1.(‘ab’, ‘cd’, ‘ef’, ‘cd’, ‘gh’)

2.(‘ab’, ‘cd’, ‘efcdgh’)

3. (‘abcdef’, ‘cd’, ‘gh’)

4.error

Posted Date:-2021-12-30 10:24:07


Question:
What will be the output of the following Python code?

print('Hello!2@#World'.istitle())

1. True

2. False

3. None

4.error

Posted Date:-2021-12-30 08:21:12


Question:
What will be the output of the following Python code?

print('xyxxyyzxxy'.lstrip('xyy'))

1.zxxy

2.xyxxyyzxxy

3.xyxzxxy

4.none of the mentioned

Posted Date:-2021-12-30 10:15:39


Question:
What will be the output of the following Python code?

print('xyyzxxyxyy'.lstrip('xyy'))

1.error

2. zxxyxyy

3.z

4.zxxy

Posted Date:-2021-12-30 10:15:15


More MCQS

  1. Python MCQS - Function
  2. Python MCQS - GUI in python
  3. Python MCQS - Operators
  4. Python MCQS - Data type in python
  5. Python MCQS - loops in python
  6. Python MCQS - Numpy
  7. Python MCQS - sqlite3
  8. Python MCQS - Library
  9. Python MCQS - Pandas
  10. Python MCQs
  11. Dictionary Python MCQ set 1
  12. Dictionary Python MCQ set 2
  13. MCQ For Python Fundamentals
  14. MCQ Introduction to Python Section 1
  15. MCQ Introduction to Python Section 2
  16. MCQ Introduction to Python Section 3
  17. MCQ on Flow of Control in Python Set 1
  18. MCQ on Flow of Control in Python Set 2
  19. MCQ on Python String Set 1
  20. File Handling in Python section 1
  21. File Handling in Python section 2
  22. Python Functions MCQS Set 1
  23. Python Functions MCQS Set 2
  24. MCQ on List in Python
  25. Pandas MCQ Questions Set 1
  26. Pandas MCQ Questions Set 2
  27. Tuple MCQ in Python
  28. Python dataframe MCQ
  29. Python Mcq Set 1
  30. Python Mcq Set 2
  31. Python Mcq Set 3
  32. Python Mcq Set 4
  33. Python Mcq Set 5
  34. Python Mcq Set 6
  35. Python Mcq Set 7
  36. Python Mcq Set 8
  37. Python Mcq Set 9
  38. Python Mcq Set 10
  39. Python Mcq Set 11
  40. Python Mcq Set 12
  41. Python Mcq Set 13
  42. Python Mcq Set 14
  43. Python Mcq Set 15
  44. Python Mcq Set 16
  45. Python Mcq Set 17
  46. Python Mcq Set 18
  47. Python Mcq Set 19
  48. Python Mcq Set 20
  49. Python Mcq Set 21
  50. Python MCQ
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!