Python for Beginners
This quiz is meant for beginners to teach and quiz on the basic concepts of Python
1 min
Per question
Average time
Contest Score
Community Rating
Swift Boar judge
This test may have a higher chance of receiving a reward. Nominated for:

Educational explanations. 👍
Explanations cover why the correct answers are correct.
E.g.: #q1, #q2, #q3, #q9, etc
Cool Bear author
Thank you very much for this. I really appreciate the kind words :)
Cool Bear author
If you see any error in my quiz, please comment here so I can rectify it. Thank you.
Calm Quokka
This quiz is good but has one big issue :

Question has no correct option :
One of the question has image with following code :

mylist = []
print(mylist[0]) # print 1
print(mylist[1]) # print 2
print(mylist[2]) # print 3

# prints out 1,2,3
for x in mylist:

and we are asked : What will be printed on the console when the code is ran ?

Given answer is 1 2 3
But correct answer should be 1 2 3 1 2 3 (in separate line but this feature is not possible in option)
Cool Bear author
Hi. Thank you very much for pointing out the mistake on the quiz :) You are right the final answer should be 1 2 3 is separate lines (top to bottom). Unfortunately, this was caused by the Telegram text editor in the quiz bot. It currently doesn't allow one to move to a new line when typing so I had to resort to using one linear line.
Calm Quokka
Cool Bear Your answer is 1 2 3 but correct answer should be 1 2 3 1 2 3 which is not there in option.
Cool Bear author
Calm Quokka yes, you are right. I just double-checked. The correct answer is 1 2 3 1 2 3 instead of 1 2 3. I will correct this in the next version of the quiz.
Calm Quokka
Cool Bear okay..It is good that u got my comment and I hope so your next version of quiz will not have any issues.
Humble Fox
Most of the questions are good, but red background is really frustrating.
Additionally, some questions have answers inside the given image.

I don't agree with answers like were you have to choose between this kind of options:
–  srennigeb rof nohtyP
– "srennigeb rof nohtyP"
because `print()` returns string and so both of them are correct.

Also, question 9. How many types of functions are there in Python?
your answer is 2, but it's wrong. Built-in, UDFs and lambdas. Overall to arguable question.

Explanations have typos and not informative, imho.
Cool Bear author
1. The red background colour can be a bit irritating. I will look into choosing a more "neutral" colour that is not terrible to the eyes.
2. The comments on the code in the images were meant to give hints rather than correct answers. I will revise that to see if they can be completely taken out or just modified so they give the correct answer.
3. In both Python 2 & 3 the print function returns a string without the double inverted commas. There are ways to make it return the string with inverted commas. The simplest being:
word = 'hello'
print '"' + word + '"'
Humble Fox
Cool Bear Thanks for the reply! Agree about 3d bullet. Overall, keep doing good things!
Cool Bear author
Cool Bear Question 9 was based on the statement that is written on the image and it was regarding loops. That is to say how many loops are there in python. There are 3 loops next, for, and while loops. The class that I was teaching using these slides was only taught about the two types of loops: for and while loops. So the question was based on that.
Humble Fox
Cool Bear I think order of questions are randomized, I meant the question about types of function
Cool Bear author
Humble Fox Oh yeah. They are randomized. I will definitely check it out. And thank you very much for the feedback. It's been really helpful.
Tsholofelo Raphiri
The answer for Question 30 is actually not 1 2 3 but 1 2 3 1 2 3
Cool Bear author
Thank you for the feedback. I will be modifying this on the next version of the quiz.
Quick Boar
Hi there, nice job with this quiz, but I did notice a typo in this question:
The answer should be "x equals two!" with an exclamation point, because it has an exclamation point in the print statement.

I also agree that the red background with white text is difficult to read on some of the images. Other than that, most of the questions are good.
Cool Bear author
Hi Thank you for this. I noticed it. The way it is now, technically means, none of the options are correct. I will surely modify it in the next iteration of the quiz.
Pali M
Hello there. I also noticed that the answer for question 13 is missing an exclamation mark. the quiz was informative. Thanks
Cool Bear author
Thank you very much for the feedback.
Cool Bear author
The mistake will be corrected in the next iteration
Small Lizard
Question with swapping values
Explanation: In Python the format() is used to swap the values of each element
It is incorrect, you swapped values using variable temp. format() is used to formatting strings
Cool Bear author
The question you are referring is this one: as you will notice "temp" is the variable that I defined which in this case means temporary. So it is used to temporarily hold the values of x and y respectively as shown in the code. The format() method in Python is, by definition, used to swap the values of a user-defined variable. So the variable temp was not used to swap, but format() was the one used in this case.
Small Lizard
Cool Bear Let's read Python documentation about format():
str.format(*args, **kwargs)
Perform a string formatting operation. The string on which this method is called can contain literal text or replacement fields delimited by braces {}. Each replacement field contains either the numeric index of a positional argument, or the name of a keyword argument. Returns a copy of the string where each replacement field is replaced with the string value of the corresponding argument.
>>> "The sum of 1 + 2 is {0}".format(1+2)
'The sum of 1 + 2 is 3'

Let's consider this code:
x = 5
y = 10
# Now x = 5 and y = 10
print(' x : {}'.format(x)) # x : 5
print(' y : {}'.format(y)) # y : 10

' x : {}'.format(x) evaluates to ' x : 5' ({} replaced with value of x)
' y : {}'.format(y) evaluates to ' y : 10' ({} replaced with value of y)
As you can see, variables didn't swap. So format() is used to formatting strings, not to swap the values of user-defined variables.
Cool Bear author
Small Lizard Oh yes. My mistake. I believe I didn't understand your initial comment. You are right. The variable temp was used to swap the variables. which means the explanation of this particular question is wrong. This will be corrected. Thank you.

I also did look at another code that can swap the values with using any temporary variables which can be found here:
Small Lizard
Question with languages
You said that correct answer is: (Updated language set: English, French)
Actually the correct answer is: Updated language set: {'English', 'French'}
I removed round brackets and added braces and quotes
Cool Bear author
Hi You are right about the languages question. The correct answer is indeed Updated language set: {'English', 'French'} as shown here: Thank you for spooting that. I will make changes in the next iteration.
Cool Bear author
Hi You are right about the languages question. The correct answer is indeed Updated language set: {'English', 'French'} as shown here: Thank you for spooting that. I will make changes in the next iteration.
Take the quiz to leave a comment