Python Questions

0 votes, 0 avg
686

Python Questions

1 / 15

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

a = 3
b = 1 
print(a, b)
a, b = b, a 
print(a, b)

2 / 15

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

3 / 15

3. Is Python code compiled or interpreted?

4 / 15

4. What happens if the file is not found in the following Python code?

a=False
while not a:
    try:
        f_n = input("Enter file name")
        i_f = open(f_n, 'r')
    except:
        print("Input file not found")

5 / 15

5. Which of the following is false regarding conditional statement in Python?

6 / 15

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

7 / 15

7. What is the order of precedence in python?

8 / 15

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

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

9 / 15

9. Which of the following is true for variable names in Python?

10 / 15

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

print('abcdef'.partition('cd'))

11 / 15

11. Set makes use of __________
Dictionary makes use of ____________

12 / 15

12. Which of the following is the proper syntax to check if a particular element is present in a list?

13 / 15

13. Which of the following expressions can be used to multiply a given number ‘a’ by 4?

14 / 15

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

15 / 15

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

Your score is

The average score is 40%

0%

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

Scroll to Top