Python Questions

0 votes, 0 avg
13

Python Questions

1 / 15

1. Which of the following is not a valid set operation in python?

2 / 15

2. Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?

3 / 15

3. The % operator returns the ___.

4 / 15

4. What will be the output of the following Python code?

t = '%(a)s, %(b)s, %(c)s'
t % dict(a='hello', b='world', c='universe')

5 / 15

5. Which of the following functions can be used to read data from a file using a file descriptor?

6 / 15

6. What will be the output of the following Python function?

float(‘-infinity’)
float(‘inf’)

7 / 15

7. What will be the output of the following code snippet?

def tester(**kwargs):
   for key, value in kwargs.items():
       print(key, value, end = " ")
tester(Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4)

8 / 15

8. What will be the output of the following program?

i = 0  
while i < 5:  
    print(i)  
    i += 1  
    if i == 3:  
        break  
else:  
    print(0)  

9 / 15

9. Which of the following modules need to be imported to handle date time computations in Python?

10 / 15

10. In Python, the break and continue statements, together are called ___ statement.

11 / 15

11.

Set makes use of __________
Dictionary makes use of ____________

12 / 15

12.

What will be the output of the following code snippet?

a = "4, 5"
nums = a.split(',')
x, y = nums
int_prod = int(x) * int(y)
print(int_prod)

13 / 15

13. Which function is called when the following Python program is executed?

f = foo()
format(f)

14 / 15

14. What are the two main types of functions in Python?

15 / 15

15. What will be the output of the following Python code?

x = "abcdef"
i = "a"
while i in x:
    x = x[:-1]
    print(i, end = " ")

Your score is

The average score is 34%

0%