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%)

Here is the complete list of test quizzes on Python.

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

print(math.isinf(float('-inf')))

Question 1 of 50 (sanfoundry.com)

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

x = [12, 34]
print(len(''.join(list(map(int, x)))))

Question 2 of 50 (sanfoundry.com)

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

class demo():
    def __repr__(self):
        return '__repr__ built-in function called'
    def __str__(self):
        return '__str__  built-in function called'
s=demo()
print(s)

Question 3 of 50 (sanfoundry.com)

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

def foo(i, x=[]):
    x.append(i)
    return x
for i in range(3):
    print(foo(i))

Question 4 of 50 (sanfoundry.com)

5. _______________________ exceptions are raised as a result of an error in opening a particular file.

Question 5 of 50 (sanfoundry.com)

6. Choose the option wherein the two choices do not refer to the same option.

Question 6 of 50 (sanfoundry.com)

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

list1 = [1, 2, 3, 4]
list2 = [5, 6, 7, 8]

print(len(list1 + list2))

Question 7 of 50 (sanfoundry.com)

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

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

Question 8 of 50 (sanfoundry.com)

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

a={5,6,7}
print(sum(a,5))

Question 9 of 50 (sanfoundry.com)

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

Question 10 of 50 (sanfoundry.com)

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

print('a'.maketrans('ABC', '123'))

Question 11 of 50 (sanfoundry.com)

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

print('*', "abcde".center(6), '*', sep='')

Question 12 of 50 (sanfoundry.com)

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

import time
t=(2010, 9, 20, 8, 45, 12, 6, 0, 0)
print(time.asctime(t))

Question 13 of 50 (sanfoundry.com)

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

names1 = ['Amir', 'Bala', 'Chales']

if 'amir' in names1:
    print(1)
else:
    print(2)

Question 14 of 50 (sanfoundry.com)

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

d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
    print(d[x])

Question 15 of 50 (sanfoundry.com)

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

my_string = "hello world"
k = [print(i) for i in my_string if i not in "aeiou"]

Question 16 of 50 (sanfoundry.com)

17. What is the difference between r+ and w+ modes?

Question 17 of 50 (sanfoundry.com)

18. What will be the output of the following Python statement?

print('x\97\x98')

Question 18 of 50 (sanfoundry.com)

19. To read the entire remaining contents of the file as a string from a file object infile, we use ____________

Question 19 of 50 (sanfoundry.com)

20. What is returned by math.ceil(3.4)?

Question 20 of 50 (sanfoundry.com)

21. Overriding means changing behaviour of methods of derived class methods in the base class.

Question 21 of 50 (sanfoundry.com)

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

s1={3, 4}
s2={1, 2}
s3=set()
i=0
j=0
for i in s1:
    for j in s2:
        s3.add((i,j))
        i+=1
        j+=1
print(s3)

Question 22 of 50 (sanfoundry.com)

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

Question 23 of 50 (sanfoundry.com)

24. Which of the following is the use of id() function in python?

Question 24 of 50 (sanfoundry.com)

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

def f(x):
    def f1(*args, **kwargs):
        print("*", 5)
        x(*args, **kwargs)
        print("*", 5)
    return f1
@f
def p(m):
    p(m)
print("hello")

Question 25 of 50 (sanfoundry.com)

26. Which module in the python standard library parses options received from the command line?

Question 26 of 50 (sanfoundry.com)

27. Which of the following is a Python tuple?

Question 27 of 50 (sanfoundry.com)

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

import turtle
t=turtle.Pen()
t.color(1,1,1)
t.begin_fill()
for i in range(0,3):
	t.forward(100)
	t.right(120)
              t.end_fill()

Question 28 of 50 (sanfoundry.com)

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

print("Hello {1} and {0}".format('bin', 'foo'))

Question 29 of 50 (sanfoundry.com)

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

x = 5 
def f1():
    global x
    x = 4
def f2(a,b):
    global x
    return a+b+x
f1()
total = f2(1,2)
print(total)

Question 30 of 50 (sanfoundry.com)

31. What will be the value of X in the following Python expression?

X = 2+9*((3*12)-8)/10
print(X)

Question 31 of 50 (sanfoundry.com)

32. How many except statements can a try-except block have?

Question 32 of 50 (sanfoundry.com)

33. Suppose list1 is [2445,133,12454,123], what is max(list1)?

Question 33 of 50 (sanfoundry.com)

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

x = ['ab', 'cd']
for i in x:
    i.upper()
print(x)

Question 34 of 50 (sanfoundry.com)

35. What does the function re.match do?

Question 35 of 50 (sanfoundry.com)

36. Which of the following statements is false about recursion?

Question 36 of 50 (sanfoundry.com)

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

l=[1, 0, 2, 0, 'hello', '', []]
print(list(filter(bool, l)))

Question 37 of 50 (sanfoundry.com)

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 (sanfoundry.com)

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

import re
print(re.subn('A', 'X', 'AAAAAA', count=4))

Question 39 of 50 (sanfoundry.com)

40. Operators with the same precedence are evaluated in which manner?

Question 40 of 50 (sanfoundry.com)

41. The output of the following Python code will result in a shape similar to the alphabet ___________

import turtle
t=turtle.Turtle()
t1=turtle.Turtle()
t.left(45)
t1.left(135)
t.forward(100)
t1.forward(100)

Question 41 of 50 (sanfoundry.com)

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

a=(1,2)
b=(3,4)
c=a+b
print(c)

Question 42 of 50 (sanfoundry.com)

43. Which of the following Python code creates an empty class?

Question 43 of 50 (sanfoundry.com)

44. Which of the following will not be returned by random.choice("1 ,")?

Question 44 of 50 (sanfoundry.com)

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

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

Question 45 of 50 (sanfoundry.com)

46. Which of these definitions correctly describes a module?

Question 46 of 50 (sanfoundry.com)

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

a={1,2,3}
b=a.add(4)
print(b)

Question 47 of 50 (sanfoundry.com)

48. Which of the following expressions is an example of type conversion?

Question 48 of 50 (sanfoundry.com)

49. Which are the advantages of functions in python?

Question 49 of 50 (sanfoundry.com)

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

myList = [1, 5, 5, 5, 5, 1]
max = myList[0]
indexOfMax = 0
for i in range(1, len(myList)):
    if myList[i] > max:
        max = myList[i]
        indexOfMax = i

print(indexOfMax)

Question 50 of 50 (sanfoundry.com)


 

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
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.