Python Questions

0 votes, 0 avg
590

Python Questions

1 / 15

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

2 / 15

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

square = lambda x: x ** 2
a = []
for i in range(5):
   a.append(square(i))
   
print(a)

3 / 15

3. What is Instantiation in terms of OOP terminology?

4 / 15

4. Which of the following best describes inheritance?

5 / 15

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

6 / 15

6. What is the order of precedence in python?

7 / 15

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

for i in range(5):
    if i == 5:
        break
    else:
        print(i)
else:
    print("Here")

8 / 15

8. Which of the following concepts is not a part of Python?

9 / 15

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

l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

10 / 15

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

11 / 15

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

12 / 15

12. Study the following code:

x = [‘XX’, ‘YY’]
for i in a:
i.lower()
print(a)

What will be the output of this program?

13 / 15

13. 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()

14 / 15

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

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 37%

0%