Python Questions

0 votes, 0 avg
599

Python Questions

1 / 15

1. Which of these is the definition for packages in Python?

2 / 15

2. The following python program can work with ____ parameters.

def f(x):
    def f1(*args, **kwargs):
           print("JAVA")
           return x(*args, **kwargs)
    return f1

3 / 15

3. 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')

4 / 15

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

def foo(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

5 / 15

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

    def func(a, b=5, c=10):

        print('a is', a, 'and b is', b, 'and c is', c)

     

    func(3, 7)

    func(25, c = 24)

    func(c = 50, a = 100)

6 / 15

6. Which of the following Python code will print True?

a = foo(2)
b = foo(3)
print(a < b)

7 / 15

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

8 / 15

8. Which of the following Boolean expressions is not logically equivalent to the other three?

9 / 15

9. Which of the following statements are used in Exception Handling in Python?

10 / 15

10. Which of the following functions can help us to find the version of python that we are currently working on?

11 / 15

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

    def printMax(a, b):

        if a > b:

            print(a, 'is maximum')

        elif a == b:

            print(a, 'is equal to', b)

        else:

            print(b, 'is maximum')

    PrintMax(3, 4)

12 / 15

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

import re
s = 'abc123 xyz666 lmn-11 def77'
re.sub(r'b([a-z]+)(d+)', r'21:', s)

13 / 15

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

l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)

14 / 15

14. Which of the following best describes inheritance?

15 / 15

15. What will be the datatype of the var in the below code snippet?

var = 10
print(type(var))
var = "Hello"
print(type(var))

Your score is

The average score is 37%

0%