Greetings Readers! We have engineered this Python programming quiz with the most relevant and frequently asked questions. Both testers and Programmers can attempt this quiz to test their Python skills.

It doesn’t matter whether you are a fresher, a mid-level or a seasoned one, it’s worth going through this quiz. We hope to see you all enjoying this cool Python quiz and guarantee a hassle-free user experience.

Software testers who use Python for automation testing can also attempt this quiz and test their Python programming skills.

We’ve tried to touch upon different areas of Python in this quiz. So, it could be useful for all of our readers.

Next, we promise to come up with new quizzes and will continue updating the old ones.

Python Programming Quiz – Part1

Time limit: 0 Quiz-summary 0 of 20 questions completed Questions: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Information Please note that this Python programming quiz comprises of twenty single-choice questions. Read each question carefully and try to finish in optimum time. To begin, press the below <Start quiz> button to go ahead.

Please continue. You have already completed the quiz before. Hence you can not start it again. Quiz is loading... You must sign in or sign up to start the quiz. You have to finish following quiz, to start this quiz: Results 0 of 20 questions answered correctly Your time: Time has elapsed You have reached 0 of 0 points, (0) Categories Python 0% Hopefully, you have enjoyed the Python programming quiz. If it had helped you boost self-knowledge, then please share this post on facebook, twitter and other social media platforms of your choice. If you want to view the correct answers for this Python programming quiz, then please press the View questions button shown below. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Answered Review Question 1 of 20 1 . Question 10 points What does the below code intended to do? def a(b, c, d): pass defines a set and initializes it.

defines a function, which does nothing.

defines a method, which passes its parameters through.

defines an empty class. Correct

Incorrect

Question 2 of 20 2 . Question 10 points What is the output of the following code? def f(): pass print type(f()) <type 'function'>

<type 'tuple'>

<type 'NoneType'>

<type 'type'> Correct

Incorrect

Question 3 of 20 3 . Question 10 points what should the below code print? print type(1J) <type 'unicode'>

<type 'complex'>

<type 'float'>

<type 'dict'> Correct

Incorrect

Question 4 of 20 4 . Question 10 points Which of the following functions print the output to the console? echo

output

print

console.log Correct

Incorrect

Question 5 of 20 5 . Question 10 points What is the output of the below Python code? a = [1,2,3,None,(),[],] print len(a) syntax error

4

5

6 Correct

Incorrect

Question 6 of 20 6 . Question 10 points What is the value of colors[2]? colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] orange

yellow

indigo

blue Correct

Incorrect

Question 7 of 20 7 . Question 10 points Which module in Python supports regular expressions? re

regex

pyregex

None Correct

Incorrect

Question 8 of 20 8 . Question 10 points What does the function re.match do? matches a pattern at the start of the string

matches a pattern at any position in the string

such a function does not exist

none of the above Correct

Incorrect

Question 9 of 20 9 . Question 10 points What is the output of the following code? import re sentence = 'Learn Python Programming' test = re.match(r'(.*) (.*?) (.*)', sentence) print(test.group()) Learn Python Programming

(Learn, Python, Programming)

(‘Learn’, ‘Programming’)

‘Learn Python Programming’ Correct

Incorrect

Question 10 of 20 10 . Question 10 points What gets printed as the output of the below code? x = True y = False z = False if not x or y: print 1 elif not x or not y and z: print 2 elif not x or y or not y and x: print 3 else: print 4 1

2

3

4 Correct

Incorrect

Question 11 of 20 11 . Question 10 points Is the following statement correct? There are two types of values in Python: numbers and strings. True

False Correct

Incorrect

The correct answer is True.

The two types of values used are numbers and strings. A number can either be an integer (INT) or a floating point (float). A string may be any sequence of characters. Question 12 of 20 12 . Question 10 points Is the following statement correct? There are two types of numbers in Python: integers and assigned values. True

False Correct

Incorrect

The correct answer is False.

The two types of numbers in Python are integers and floating points.

For example- 3 and 7.3 respectively. Assigned values are not a type of number. Question 13 of 20 13 . Question 10 points If the following statement is run in Python, what will be the result? print abc abc

'abc'

=abc

NameError: name 'abc' is not defined Correct

Incorrect

Question 14 of 20 14 . Question 10 points If the following code is run in Python, what would be the result? num = '5'*'5' 9

27

333

TypeError: can't multiply sequence by non-int of type 'str' Correct

Incorrect

The correct answer is TypeError: can’t multiply sequence by non-int of type ‘str’.

As the operands are strings, they are unable to be multiplied together and hence the program produces a type error. Question 15 of 20 15 . Question 10 points Which of the following environment variable for Python is an alternative module search path? PYTHONPATH

PYTHONSTARTUP

PYTHONCASEOK

PYTHONHOME Correct

Incorrect

The correct answer is PYTHONHOME.

It is an alternative module search path. It is usually embedded in the PYTHONSTARTUP or PYTHONPATH directories to make switching module libraries easy. Question 16 of 20 16 . Question 10 points What is the output of the following Python code? tinytuple = (123, 'techbeamers') print tinytuple * 2 (123, 'techbeamers', 123, 'techbeamers')

(123, 'techbeamers') * 2

Error

None of the above Correct

Incorrect

The correct answer is (123, ‘techbeamers’, 123, ‘techbeamers’).

It will print the list two times. Question 17 of 20 17 . Question 10 points Which of the following function checks that all characters of a string are in upper case? isupper()

join(seq)

len(string)

ljust(width[, fillchar]) Correct

Incorrect

The correct answer is isupper().

The function returns True if string has at least 1 character and all characters are in upper case. Question 18 of 20 18 . Question 10 points Which function does in-place reversal of objects in a list? list.reverse()

list.sort([func])

list.pop(obj=list[-1])

list.remove(obj) Correct

Incorrect

The correct answer is list.reverse().

The function performs in-place reversal of objects in the list. Question 19 of 20 19 . Question 10 points What would be the result of the following expression in Python? print 3/5 0

0.6

6/10

None of the above Correct

Incorrect

The correct answer is 0.

The numerical values 3 and 5 are integers. That’s why integer division is computed and the program prints the remainder of the equation. If a floating point would’ve been used instead, i.e. 3.0/5, then the outcome would be 0.6 as expected. Question 20 of 20 20 . Question 10 points What is the output of following code? list = [ 'Tech', 404, 3.03, 'Beamers', 33.3 ] print list[1:3] [ 'Tech', 404, 3.03, 'Beamers', 33.3 ]

[404, 3.03]

['Tech', 'Beamers']

None of the above Correct

Incorrect

The correct answer is [404, 3.03].

It will print elements starting from 2nd till 3rd.

Note: You can find all the answers to this Python programming quiz in the end.

We hope the above quiz would have given you some good points to note and brush up your Python programming skills.

Enthusiastic software developers and automation engineers can find more interesting stuff related to Python. Please have a look at the below posts.

Recommended Posts:

1. Top Python Tips

2. Python Multithreading

3. Python Interview Questions

Finally, if our content has helped you in any way and you wish to appreciate our efforts. Then, help us reach more people by sharing it further.

All the Best,

TechBeamers