Python Questions

0 votes, 0 avg
569

Python Questions

1 / 15

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

2 / 15

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

s1 = {1, 2, 3, 4, 5}
s2 = {2, 4, 6}
print(s1 ^ s2)

3 / 15

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

a=[1,2,3]
b=a.append(4)
print(a)
print(b)

4 / 15

4. Is Python code compiled or interpreted?

5 / 15

5. What will be the output of the following Python code if the input entered is 6?

valid = False
while not valid:
    try:
        n=int(input("Enter a number"))
        while n%2==0:
            print("Bye")
        valid = True
    except ValueError:
        print("Invalid")

6 / 15

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

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

7 / 15

7. The % operator returns the ___.

8 / 15

8. Which of the following best describes inheritance?

9 / 15

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

    class tester:

        def __init__(self, id):

            self.id = str(id)

            id="224"

     

    >>>temp = tester(12)

    >>>print(temp.id)

10 / 15

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

a=[13,56,17]
a.append([87])
a.extend([45,67])
print(a)

11 / 15

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

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

12 / 15

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

13 / 15

13. Conditional statements are also known as ___ statements.

14 / 15

14. Which keyword is used for function in Python language?

15 / 15

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

Your score is

The average score is 37%

0%