Python Questions

0 votes, 0 avg
512

Python Questions

1 / 15

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

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 will be the output of the following Python code?

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

4 / 15

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

    x = 50

    def func():

        global x

        print('x is', x)

        x = 2

        print('Changed global x to', x)

    func()

    print('Value of x is', x)

5 / 15

5. What will be the output of the following Python program?

z=set('abc')
z.add('san')
z.update(set(['p', 'q']))
Z

6 / 15

6. What keyword is used in Python to throw exceptions?

7 / 15

7. Is Python code compiled or interpreted?

8 / 15

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

9 / 15

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

10 / 15

10. Which one of the following is the use of function in python?

11 / 15

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

12 / 15

12. What will be the output of the following Python program?

    def addItem(listParam):

        listParam += [1]

     

    mylist = [1, 2, 3, 4]

    addItem(mylist)

    print(len(mylist))

13 / 15

13. Which of the following functions converts date to corresponding time in Python?

14 / 15

14. Which of the following types of loops are not supported in Python?

15 / 15

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

Your score is

The average score is 37%

0%