Python Questions

0 votes, 0 avg
24

Python Questions

1 / 15

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

2 / 15

2. Which of the following are valid escape sequences in Python?

3 / 15

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

4 / 15

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

5 / 15

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

6 / 15

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

7 / 15

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

8 / 15

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

l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)

9 / 15

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

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

10 / 15

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

11 / 15

11. Which of the following functions can be used to read data from a file using a file descriptor?

12 / 15

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

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

13 / 15

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

14 / 15

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

count = 0
while(True):
   if count % 3 == 0:
       print(count, end = " ")
   if(count > 15):
       break;
   count += 1

15 / 15

15. What will be the value of ‘result’ in following Python program?

list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
result = list()
result.extend(i for i in list1 if i not in (list2+list3) and i not in result)
result.extend(i for i in list2 if i not in (list1+list3) and i not in result)
result.extend(i for i in list3 if i not in (list1+list2) and i not in result)

Your score is

The average score is 34%

0%