Python Questions

0 votes, 0 avg
654

Python Questions

1 / 15

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

2 / 15

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

3 / 15

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

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

4 / 15

4. What are the two main types of functions in Python?

5 / 15

5. What is the order of precedence in python?

6 / 15

6. The % operator returns the ___.

7 / 15

7. As what datatype are the *kwargs stored, when passed into a function?

8 / 15

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

9 / 15

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

10 / 15

10. Which of the following functions can help us to find the version of python that we are currently working on?

11 / 15

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

a = [1, 2, 3]
a = tuple(a)
a[0] = 2
print(a)

12 / 15

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

13 / 15

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

14 / 15

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

15 / 15

15. Which of the following is used to define a block of code in Python language?

Your score is

The average score is 40%

0%

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

Scroll to Top