My Report (&Account)

Python Online Test


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

Here is the complete list of test quizzes on Python.

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

>>> a={1,2,3}
>>> b=a
>>> b.remove(3)
>>> a

Question 1 of 50

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

import turtle()
t=turtle.Pen()
t.goto(50,60)
t1=t.clone()
t1.ycor()

Question 2 of 50

3. What will be the output of the following Python code snippet?

a={1:"A",2:"B",3:"C"}
a.setdefault(4,"D")
print(a)

Question 3 of 50

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

re.split(r'(n\d)=', 'n1=3.1, n2=5, n3=4.565')

Question 4 of 50

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

l1=[2,4,6]
l2=[-2,-4,-6]
for i in zip(l1, l2):
	print(i)

Question 5 of 50

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

>>> a={1,2,3}
>>> b=frozenset([3,4,5])
>>> a-b

Question 6 of 50

7. What will be the output of the following Python code snippet?

def example(a):
    a = a + '2'
     a = a*2
    return a
>>>example("hello")

Question 7 of 50

8. The output of the following Python code is similar to the alphabet _______________

import turtle
t=turtle.Pen()
t1=turtle.Pen()
t2=turtle.Pen()
t.forward(100)
t1.forward(100)
t2.forward(100)
t1.left(90)
t1.forward(75)
t2.right(90)
t2.forward(75)

Question 8 of 50

9. What will be the output of the following Python code, if the time module has already been imported?

def num(m):
	t1 = time.time()
	for i in range(0,m):
		print(i)
	t2 = time.time()
	print(str(t2-t1))

    num(3)

Question 9 of 50

10. Any odd number on being AND-ed with ________ always gives 1. Hint: Any even number on being AND-ed with this value always gives 0.

Question 10 of 50

11. Which of these is false about recursion?

Question 11 of 50

12. What is the default value of encoding in encode()?

Question 12 of 50

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

class A:
    def __init__(self):
        self._x = 5       
class B(A):
    def display(self):
        print(self._x)
def main():
    obj = B()
    obj.display()
main()

Question 13 of 50

14. Is Python code compiled or interpreted?

Question 14 of 50

15. Which of the following statements is true?

Question 15 of 50

16. Is the following Python code valid?

class B(object):
  def first(self):
    print("First method called")
  def second():
    print("Second method called")
ob = B()
B.first(ob)

Question 16 of 50

17. Given a string example="hello" what is the output of example.count('l')?

Question 17 of 50

18. What are the two main types of functions?

Question 18 of 50

19. To which of the following the "in" operator can be used to check if an item is in it?

Question 19 of 50

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

x = [34, 56]
print((''.join(list(map(str, x)))),)

Question 20 of 50

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

i = 5
while True:
    if i%0O9 == 0:
        break
    print(i)
    i += 1

Question 21 of 50

22. Which is the most appropriate definition for recursion?

Question 22 of 50

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

print('abcd'.partition('cd'))

Question 23 of 50

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

f = None
for i in range (5):
    with open("data.txt", "w") as f:
        if i > 2:
            break
print(f.closed)

Question 24 of 50

25. What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
    x[i].upper()
print (x)

Question 25 of 50

26. To obtain a list of all the functions defined under sys module, which of the following functions can be used?

Question 26 of 50

27. Which of the following is the use of function in python?

Question 27 of 50

28. Which of the following formatting options can be used in order to add ‘n’ blank spaces after a given string ‘S’?

Question 28 of 50

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

class Count:
    def __init__(self, count = 0):
       self.__count = count

c1 = Count(2)
c2 = Count(2)
print(id(c1) == id(c2), end = " ")

s1 = "Good"
s2 = "Good"
print(id(s1) == id(s2))

Question 29 of 50

30. The function pow(x,y,z) is evaluated as:

Question 30 of 50

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

class fruits:
    def __init__(self):
        self.price = 100
        self.__bags = 5
    def display(self):
        print(self.__bags)
obj=fruits()
obj.display()

Question 31 of 50

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

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

Question 32 of 50

33. What will be the output of the following Python code snippet?

print([[i+j for i in "abc"] for j in "def"])

Question 33 of 50

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

'{0:.2f}'.format(1.234)

Question 34 of 50

35. Which of the following functions results in case insensitive matching?

Question 35 of 50

36. What will be the output of the following Python code if the system date is: 6/19/2017

tday=datetime.date.today()
tdelta=datetime.timedelta(days=10)
print(tday+tdelta)

Question 36 of 50

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

class Truth:
	pass
x=Truth()
bool(x)

Question 37 of 50

38. What will be the output of the following Python code snippet?

print('The sum of {0:b} and {1:x} is {2:o}'.format(2, 10, 12))

Question 38 of 50

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

def change(i = 1, j = 2):
    i = i + j
    j = j + 1
    print(i, j)
change(j = 1, i = 2)

Question 39 of 50

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

x = [34, 56]
print(len(map(str, x)))

Question 40 of 50

41. Suppose d = {"john":40, "peter":45}, what happens when we try to retrieve a value using the expression d["susan"]?

Question 41 of 50

42. What is the use of tell() method in python?

Question 42 of 50

43. Which of the codes shown below results in a match?

Question 43 of 50

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

def C2F(c):
    return c * 9/5 + 32
print C2F(100)
print C2F(0)

Question 44 of 50

45. Which operator is overloaded by __invert__()?

Question 45 of 50

46. What will be the output of the following Python code snippet?

>>>import collections
>>> a=collections.Counter([1,1,2,3,3,4,4,4])
>>> a

Question 46 of 50

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

i = 2
while True:
    if i%3 == 0:
        break
    print(i)
    i += 2

Question 47 of 50

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

print("abcdef".find("cd"))

Question 48 of 50

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

d = {"john":40, "peter":45}
d["john"]

Question 49 of 50

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

A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]
[A[i][i] for i in range(len(A))]

Question 50 of 50


 

Topic wise Test Quizzes on Python

Python tests, quizzes, and exams are great ways to learn and test your Python programming skills. Whether you’re a beginner or experienced, challenge and boost your confidence with our engaging online quizzes on Python basics, operators, loops, strings, lists, tuples, sets, dictionaries, functions, modules, files, and exceptions. Start the Python online test now!



Python Programming Certification Test

Python Programming Certification Test is a free certification exam. However, you need to score an A grade in each of the "Certification Level Tests 1 to 10" to be eligible to take part in this certification test. So, take all the "10 Tests" starting from Certification Level 1 upto Level 10, before taking the final Certification test.


Level 1 to 10 Tests:
Total Questions: 25, Total Time: 30 min, Correct Answer: 2 points, Wrong Answer: -1 point

Certification Test:
Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Python Programming Internship Test

If you scored either Grade A* or Grade A in our Python Programming Internship Test, then you can apply for Internship at Sanfoundry in Python Programming.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Python Programming Job Test

It is designed to test and improve your skills for a successful career, as well as to apply for jobs.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Note: Before you get started on these series of online tests, you should practice our collection of 1000 MCQs on Python Programming .

Sanfoundry Scoring & Grading System

Sanfoundry tests and quizzes are designed to provide a real-time online exam experience. Here is what you need to know about them.

  • Scoring System: You get 2 points for each correct answer but lose 1 point for every wrong answer.
  • Grading System: Your grade depends on your final score and can be one of the following:

    • Grade A* - Genius (100%)
    • Grade A - Excellent (80% to 99%)
    • Grade B - Good (60% to 80%)
    • Grade C - Average (40% to 60%)
    • Grade D - Poor (0% to 40%)
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.