Which of the following follow PEP8? Please select 2 correct answers
Correct
Incorrect
Question 4 of 15
4. Question
What will this code print? >>> a=7 >>> print(a+1)
Correct
Incorrect
Question 5 of 15
5. Question
What is the maximum value for an integer in Python 3?
Correct
Incorrect
Question 6 of 15
6. Question
How do you denote the end of a block in Python 3?
Correct
Incorrect
Question 7 of 15
7. Question
Which of these if-statements work? Please select 2 correct answers
Correct
Incorrect
Question 8 of 15
8. Question
In this list, how will you access the letter ‘t’ in ‘bat’? list = [1, [‘a’, ‘b’, [‘kill’, ‘bat’, ‘cup’], ‘c’], 3]
Correct
Incorrect
Question 9 of 15
9. Question
How will you turn the list a = [1, 2, 7, 8] into [1, 2, 3, 4, 5, 6, 7, 8]? Please select 2 correct answers
Correct
Incorrect
Question 10 of 15
10. Question
What is the value of y? >>> x, y, z = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)[2::3]
Correct
Incorrect
Question 11 of 15
11. Question
What is the result of {1, 2, 3} & {4, 5, 6}?
Correct
Incorrect
Question 12 of 15
12. Question
Which statements delete the value ‘milk’ from the set s = {‘milk’, ‘cheese’, ‘butter’, ‘buttermilk’}? Please select 4 correct answers
Correct
Incorrect
Question 13 of 15
13. Question
In the following code, how many objects and references does Python create? name = ‘Ayushi’ fname = name
Correct
Incorrect
Question 14 of 15
14. Question
According to PEP 8, what case should you use for variable names with more than one word?
Correct
Incorrect
Question 15 of 15
15. Question
What is the output of the following code? >>> nums = [[val for val in range(num)] for num in range(3)] >>> for num in nums: for val in num: if val < 2: print(‘*’, end=”)
Correct
Incorrect
This was all in the Python quiz. Hope you enjoyed answering it.
Do share your experience and score of the Python quiz in the comment section.
Did you like this article?
If Yes, please give DataFlair 5 Stars on Google
DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.
It’s ok, you just need to learn more about Python then you will be able to give correct answers for all the questions. Here we are providing you a series of 240+ free Python tutorials which will help you to gain expertise.
will take every third item starting from position 2 and put the first one in x, second in y and third in z That means, x=3 # First item from the starting position (second position) y=6 # Second item (Third from the first item) z =9 # Third item (Third from second item)
Thank you, Kostiantyn, for expressing interest in DataFlair.It’s possible that an indentation error occurs while copying the text. I request you to execute the code again and give it another try.
14 correct answer
You scored really well in Python Quiz. Do not forget to check Python Interview Questions by DataFlair before you appear in interviews.
Q. 4 Ans will be 8 .It is showing Wrong
Kindly check
Thanks
Gautam
We have done the required changes. Thanks for correcting us.
No, this code will raise an exception – The print() function is needlessly indented.
Correct. print() should not be indented.
Missing closing parenthesis in Q12
We have done the correction. Thanks for pointing it out.
7 out of 15
Hi Lokesh,
Practice the Python concepts in which your answers got wrong from the Python Tutorial Home.
can anyone elaborate the 15th
It’s very awful for me I was able to do give only 6 right answer
Hi Vikas,
It’s ok, you just need to learn more about Python then you will be able to give correct answers for all the questions. Here we are providing you a series of 240+ free Python tutorials which will help you to gain expertise.
14 answers correct
You scored really well in Python Quiz. Do not forget to check Python Interview Questions by DataFlair before you appear in interviews.
a=7
print (a+1)
Correct ans is 8 ,but its showing me wrong,
Kindly check all.
No, this code will raise an exception – The print() function is needlessly indented.
14/15 are I scored
You scored really well in Python Quiz. Do not forget to check Python Interview Questions by DataFlair before you appear in interviews.
8/15
Check the Free Python Course by DataFlair for more learning.
10 / 15
10 / 15 I scored
can just explain que. 10 Ans.
How it is 6
the code
x,y,z = (1,2,3,4,5,6,7,8,9,10)[2::3]
will take every third item starting from position 2 and put the first one in x, second in y and third in z
That means,
x=3 # First item from the starting position (second position)
y=6 # Second item (Third from the first item)
z =9 # Third item (Third from second item)
I scored 11/15
15 correct!!! yayyyyy i guess teaching well!! thank you lol
Awesum.. You are ready to appear in Python Interviews but before that, do not forget to check Free Python Interview Questions by DataFlair
14/15
You scored really well in Python Quiz. Do not forget to check Python Interview Questions by DataFlair before you appear in interviews.
13/15 xD
You scored really well in Python Quiz. Do not forget to check Python Projects by DataFlair for complete hands-on knowledge.
7 out of 15, and I want to say it is a great platform for data science!!
Q.2 anwers 2 and 3 will cause syntax error (Python 3.11.1):
Cell In[1], line 1
a={1, 2, \ #comment 3, 4}
^
SyntaxError: unexpected character after line continuation character
Cell In[25], line 1
a={1, 2, #comment 3, 4}
^
SyntaxError: incomplete input
Thank you, Kostiantyn, for expressing interest in DataFlair.It’s possible that an indentation error occurs while copying the text. I request you to execute the code again and give it another try.
13 of 15 Questions answered correctly..
Thank you
10/10