Python Questions

0 votes, 0 avg
277

Python Questions

1 / 15

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

2 / 15

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

3 / 15

3. Which of the following blocks will always be executed whether an exception is encountered or not in a program?

4 / 15

4. Which of the following best describes inheritance?

5 / 15

5. Which of the following is the use of id() function in python?

6 / 15

6. time.time() returns ________

7 / 15

7. To add a new element to a list we use which Python command?

8 / 15

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

9 / 15

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

10 / 15

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

11 / 15

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

12 / 15

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

a = [1, 2, 3, 4]
b = [3, 4, 5, 6]
c = [x for x in a if x not in b]
print(c)

13 / 15

13.

What will be the output of the following code snippet?

def thrive(n):
 if n % 15 == 0:
   print("thrive", end = “ ”)
 elif n % 3 != 0 and n % 5 != 0:
   print("neither", end = “ ”)
 elif n % 3 == 0:
   print("three", end = “ ”)
 elif n % 5 == 0:
   print("five", end = “ ”)
thrive(35)
thrive(56)
thrive(15)
thrive(39)

14 / 15

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

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

15 / 15

15. 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

Your score is

The average score is 34%

0%