Python Questions

0 votes, 0 avg
44

Python Questions

1 / 15

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

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

2 / 15

2. Loops are known as ___ in programming.

3 / 15

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

4 / 15

4. Which of the following Python code will print True?

a = foo(2)
b = foo(3)
print(a < b)

5 / 15

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

6 / 15

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

7 / 15

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

8 / 15

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

9 / 15

9. How can assertions be disabled in Python?

10 / 15

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

11 / 15

11. Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:python.txt''?

12 / 15

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

def solve(a):
   a = [1, 3, 5]
a = [2, 4, 6]
print(a)
solve(a)
print(a)

13 / 15

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

string = "my name is x"
for i in string.split():
    print (i, end=", ")

14 / 15

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

def unpack(a,b,c,d):
    print(a+d)
x = [1,2,3,4]
unpack(*x)

15 / 15

15. What is the order of namespaces in which Python looks for an identifier?

Your score is

The average score is 35%

0%