# 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-31 05: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-31 05: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-31 05: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)

4. list1.append(3, 5)

Posted Date:-2021-12-31 05: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 17: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 17: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 17: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-31 05: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 17: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05: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-31 05:22:38

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

2.list1.append(5)

Posted Date:-2021-12-31 05: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-31 05: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-31 05: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-31 05: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 17: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 17: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 17: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 17:38:26

## 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 17:30:23

## 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 17: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 17: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 17:36:10

## 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 17: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 17: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 17: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 15: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 17: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 17: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-31 05: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 17:14:41

## 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 15:23:00

## 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 15: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 17: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 17: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 17: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 17: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 15: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 17: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 17:15:15

## More MCQS

##### 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!