# Python Online Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to Python. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Q 1 - What is output for −

'search'. find('S') ?

A - s

B - -1

C - ‘ ‘

D - None of the above

### Explanation

The method find() is case sensitive.

Q 2 - What is output for following code −

```y = [4, 5,1j]
y.sort()
```

A - [1j,4,5]

B - [5,4,1j]

C - [4,5,1j]

D - Type Error

### Explanation

we cannot compare complex numbers with numbers, so the output results in type error stating that complex numbers cannot be compared with <,>,=.

Q 3 - Which operator is right-associative

A - *

B - =

C - +

D - %

### Explanation

‘=‘ operator is right associative as assignment operators are right associative.

### Explanation

since there is no such element in the set, so key error is raised.

Q 5 - Find the output of the code?

```def f(a, b = 1, c = 2):
print('a is: ',a, 'b is: ', b, 'c is: ', c)
f(2, c = 2)
f(c = 100, a = 110)
```

A - a is: 2 b is: 1 c is: 2

a is: 110 b is: 1 c is: 100

B - a is: 2 b is: 2 c is: 2

a is: 110 b is: 2 c is: 100

C - a is: 0 b is: 2 c is: 2

a is: 110 b is: 0 c is: 100

D - a is: 110 b is: 0 c is: 100

a is: 110 b is: 0 c is: 100

### Explanation

Value of Arguments is passed to the parameters in order of their sequence.

Q 6 - What is the output of the code?

```try:
list = 5*[0]+5*[10]
x = list[9]
print(''Done!'')
except IndexError:
print(''Index out of Bond! '')
else:
print(''Nothing is wrong!'')
finally:
print(''Finally block!'')
```

A - ‘Finally Block!’

B - ‘Done!’ follow by ‘Nothing is wrong!’

C - ‘Nothing is wrong!’ followed by ‘Finally block!’

D - ‘Done!’ follow by ‘Nothing is wrong!’ followed by ‘Finally block’.

### Explanation

In the above Try block we make a list of total 10 elements by adding 5 times zero and 5 times 10. Thus when we try to find out the element at index 9 no error is raised by Python.

### Explanation

Checkbutton method is used to make a checkbox. In the parameters we need to pass the values as asked in the question. Here it should bind to v1 thus variable is set to v1 and frame should be under frame1 thus frame1 mentioned in the code.

### Explanation

Text is created in the canvas by using create_text method of canvas. Color of the text can be set according to the user which is specified under ‘filled’.

Q 10 - What will be the output of the following code?

```print(type(1/2))
```

A - <class 'float'>

B - <class 'int'>

C - NameError: ‘½’ is not defined.

D - 0.5