Python Questions

0 votes, 0 avg
656

Python Questions

1 / 15

1. Which of the following is a feature of DocString?

2 / 15

2. 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)

3 / 15

3. Which of the following are valid string manipulation functions in Python?

4 / 15

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

    x = 50

    def func():

        global x

        print('x is', x)

        x = 2

        print('Changed global x to', x)

    func()

    print('Value of x is', x)

5 / 15

5. What is called when a function is defined inside a class?

6 / 15

6. Which of the following is used to define a block of code in Python language?

7 / 15

7. How can assertions be disabled in Python?

8 / 15

8. In Python, ___ defines a block of statements.

9 / 15

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

    x = 50

    def func(x):

        print('x is', x)

        x = 2

        print('Changed local x to', x)

    func(x)

    print('x is now', x)

10 / 15

10. 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)

11 / 15

11. 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)  

12 / 15

12. Consider the results of a medical experiment that aims to predict whether someone is going to develop myopia based on some physical measurements and heredity. In this case, the input dataset consists of the person’s medical characteristics and the target variable is binary: 1 for those who are likely to develop myopia and 0 for those who aren’t. This can be best classified as

13 / 15

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

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

14 / 15

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

15 / 15

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

 class test:
     def __init__(self,a):
         self.a=a
 
     def display(self):
         print(self.a)
obj=test()
obj.display()

Your score is

The average score is 40%

0%

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.

Scroll to Top