Open In App

Python Quiz

Last Updated : 13 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Python is one of the most widely-used and popular programming languages, was developed by Guido van Rossum and released first on February 20, 1991. Python is a free and open-source language with a very simple and clean syntax which makes it easy for developers to learn Python.

In this article, we’ve compiled a series of Python Quizzes. These Python quiz questions are designed to help you become more familiar with Python and test your knowledge across various topics. From Python basics to advanced concepts, these topic-specific quizzes offer a comprehensive way to practice and assess your understanding of Python concepts.

These Python Quizzes are designed for both beginners and experienced Python professionals. No registration is required to start the test. Simply choose a test and begin your Python journey!

Try our Python Self Paced course ! It’s perfect for beginners. You’ll learn all the fundamentals of the Python so it will help you in this Python Quiz.

Applications of Python

  • Web Development : Python is widely used for web development, thanks to frameworks like Django and Flask. These frameworks provide tools and libraries for building robust and scalable web applications.
  • Data Analysis and Visualization : Python has become the go-to language for data analysis and visualization. Libraries such as NumPy, pandas, and Matplotlib provide powerful tools for processing, analyzing, and visualizing data.
  • Machine Learning and Artificial Intelligence : Python is extensively used in the field of machine learning and AI. Libraries like TensorFlow, Keras, and PyTorch offer high-level abstractions for building and training machine learning models.
  • Scientific Computing : Python’s rich ecosystem of scientific libraries, such as SciPy and sci-kit-learn, make it popular for scientific computing tasks. It is used in areas such as physics, chemistry, biology, and astronomy for simulations, data analysis, and modelling.
  • Automation and Scripting : Python’s simplicity and ease of use make it a preferred choice for automation and scripting tasks. It can be used to automate repetitive tasks, process files, interact with operating system APIs, and more.
  • Game Development : Python has libraries like Pygame that facilitate game development. While it may not be as performant as other languages, Python’s ease of use makes it suitable for prototyping and developing 2D games.

FAQs on Python Quiz

1. What is a Python quiz?

A Python quiz is a set of questions or problems designed to test your knowledge and understanding of the Python programming language.

2. What are the benefits of taking a Python quiz?

There are a number of benefits to taking a Python quiz. Here are a few of the most important benefits:

  • You can assess your understanding of Python:
  • You can identify your strengths and weaknesses:
  • You can learn new things

3. Where can I find Python quizzes?

There are a number of places where you can find Python quizzes. Here are a few of the most popular sources for Python quizzes:

  • Online websites : There are a number of websites that offer free or paid Python quizzes like GeeksforGeeks, RealPython and more.
  • Books : There are a number of books that contain Python quizzes. Some of the most popular books include the following:
    Python for Beginners by Mark Lutz
    -Python Cookbook by David Beazley and Brian Jones
    -Fluent Python by Luciano Ramalho

4. How do I prepare for a Python quiz?

There are a number of things you can do to prepare for a Python quiz. Here are a few tips:

  • Learn the basics of Python
  • Practice coding in Python
  • Take practice quizzes

5. I am a beginner in Python. Should I take a Python quiz?

Yes, even if you are a beginner in Python, you should take a Python quiz. Python quizzes can be a great way to assess your understanding of the language and to identify areas where you need more practice.

6. I am an experienced Python programmer. Should I take a Python quiz?

Yes, even if you are an experienced Python programmer, you should take a Python quiz. Python quizzes can be a great way to keep your skills sharp and to learn about new features of the language.


Similar Reads

Python-Quizzes | Python String Quiz | Question 16
Question 16: What is the output of the following program? a = "GeeksforGeeks " b = 13 print (a + b) (A) GeeksforGeeks13 (B) 13GeeksforGeeks (C) GeeksforGeeks (D) Error Answer: (D) Explanation: As you can see the variable ‘b’ is of type integer and the variable ‘a’ is of type string. Also as Python is a strongly typed language we cannot si
1 min read
Python-Quizzes | Python Sets Quiz | Question 4
Question 4: What is the output of the following program? set1 = {1, 2, 3} set2 = set1.add(4) print(set2) (A) {1, 2, 3, 4} (B) {1, 2, 3} (C) Invalid Syntax (D) None Answer: (D) Explanation: The add method doesn’t return anything. Hence there will be no output.Quiz of this QuestionPlease comment below if you find anything wrong in the above post
1 min read
Python-Quizzes | Python Tuples Quiz | Question 8
Question 8: What is the output of the following program? T = 'geeks' a, b, c, d, e = T b = c = '*' T = (a, b, c, d, e) print(T) (A) (‘g’, ‘*’, ‘*’, ‘k’, ‘s’) (B) (‘g’, ‘e’, ‘e’, ‘k’, ‘s’) (C) (‘geeks’, ‘*’, ‘*’) (D) KeyError Answer: (A) Explanation: A tuple is created as T = (‘g’, ‘e’, ‘e’, ‘k’, ‘s’), then it is unpacked into a, b, c, d and e, mapp
1 min read
Python-Quizzes | Python Tuples Quiz | Question 9
Question 8: What is the output of the following program? L = [2e-04, 'a', False, 87] T = (6.22, 'boy', True, 554) for i in range(len(L)): if L[i]: L[i] = L[i] + T[i] else: T[i] = L[i] + T[i] break (A) [6.222e-04, ‘aboy’, True, 641] (B) [6.2202, ‘aboy’, 1, 641] (C) TypeError (D) [6.2202, ‘aboy’, False, 87] Answer: (C) Explanation: The for loop will
1 min read
Python-Quizzes | Python Tuples Quiz | Question 9
Question 9: What is the output of the following program? L = [3, 1, 2, 4] T = ('A', 'b', 'c', 'd') L.sort() counter = 0 for x in T: L[counter] += int(x) counter += 1 break print(L) (A) [66, 97, 99, 101] (B) [66, 68, 70, 72] (C) [66, 67, 68, 69] (D) ValueError Answer: (D) Explanation: After sort(L), L will be = [1, 2, 3, 4]. Counter = 0, L[0] i.e. 1
1 min read
Python-Quizzes | Python Tuples Quiz | Question 10
Question 10: What is the output of the following program? import sys L1 = tuple() print(sys.getsizeof(L1), end = " ") L1 = (1, 2) print(sys.getsizeof(L1), end = " ") L1 = (1, 3, (4, 5)) print(sys.getsizeof(L1), end = " ") L1 = (1, 2, 3, 4, 5, [3, 4], 'p', '8', 9.777, (1, 3)) print(sys.getsizeof(L1)) (A) 0 2 3 10 (B) 32
1 min read
Python-Quizzes | Python Tuples Quiz | Question 11
Question 11: What is the output of the following program? T1 = (1) T2 = (3, 4) T1 += 5 print(T1) (A) TypeError (B) (1, 5, 3, 4) (C) 1 TypeError (D) 6 Answer: (D) Explanation: T1 is an integer while T2 is tuple. Thus T1 will become 1 + 5 = 6.Quiz of this QuestionPlease comment below if you find anything wrong in the above post
1 min read
Python-Quizzes | Python Sets Quiz | Question 5
Question 5: What is the output of the following program? set1 = {1, 2, 3} set2 = {4, 5, 6} print(len(set1 + set2)) (A) 3 (B) 6 (C) Unexpected (D) Error Answer: (D) Explanation: The unsupported operand type(s) for +: ‘set’ and ‘set’.Quiz of this QuestionPlease comment below if you find anything wrong in the above post
1 min read
Python-Quizzes | Python List Quiz | Question 13
Find the output of the following program: C/C++ Code d2 = [1, 2, 3, 4, 5] subtracted = list() for d1, d2 in zip(d1, d2): item = d1 -d2 subtracted.append(item) print(subtracted) (A) [10, 20, 30, 40, 50] (B) [1, 2, 3, 4, 5] (C) [10, 20, 30, 40, 50,-1, -2, -3, -4, -5] (D) 9, 18, 27, 36, 45 Answer: (D)Explanation: The output will be-9, 18, 27, 36, 45 Q
1 min read
Python-Quizzes | Python List Quiz | Question 2
Find the output of the following program: C/C++ Code print (nameList[1][-1]) (A) r (B) b (C) D (D) k Answer: (D)Explanation: The index position -1 represents either the last element in a list or the last character in a String. In the above given list of names “nameList”, the index 1 represents the second element i.e, the second string “Pratik” and
1 min read
Python-Quizzes | Python Sets Quiz | Question 11
Question 11: What is the output of the following program? set1 = set([ 4, 5, (6, 7)]) set1.update([10, 11]) print(set1) (A) {4, 5, 6, 7, 10, 11} (B) {4, 5, 10, 11} (C) {4, 5, (6, 7), 10, 11} (D) None Answer: (C) Explanation: The update() method accepts lists, strings, tuples as well as other sets as its arguments. In all of these cases, duplicate e
1 min read
Python-Quizzes | Python Dictionary Quiz | Question 4
Question 4:Find the output of the following program: D = dict() for i in range (3): for j in range(2): D[i] = j print(D) (A) {0: 0, 1: 0, 2: 0} (B) {0: 1, 1: 1, 2: 1} (C) {0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1} (D) TypeError: Immutable object Answer: (B) Explanation: 1st loop will give 3 values to i 0, 1 and 2. In the empty dictionary, valued are adde
1 min read
Python-Quizzes | Python Dictionary Quiz | Question 23
Question 23:Find the output of the following program: dictionary = {} dictionary[1] = 1 dictionary['1'] = 2 dictionary[1] += 1 sum = 0 for k in dictionary: sum += dictionary[k] print (sum) (A) 4 (B) 3 (C) 2 (D) 1 Answer: (A) Explanation: In the above dictionary, the key 1 enclosed between single quotes and only 1 represents two different keys as on
1 min read
Python-Quizzes | Python List Quiz | Question 22
Find the output of the following program: C/C++ Code L1 = [1, 1.33, 'GFG', 0, 'NO', None, 'G', True] val1, val2 = 0,'' for x in L1: if(type(x) == int or type(x) == float): val1 += x elif(type(x) == str): val2 += x else: break print(val1, val2) (A) 2 GFGNO (B) 2.33 GFGNOG (C) 2.33 GFGNONoneGTrue (D) 2.33 GFGNO Answer: (D)Explanation: val1 will only
1 min read
Python-Quizzes | Python List Quiz | Question 1
Question 1: Find the output of the following program: nameList = ['Harsh', 'Pratik', 'Bob', 'Dhruv'] pos = nameList.index("GeeksforGeeks") print (pos * 3) (A) GeeksforGeeks GeeksforGeeks GeeksforGeeks (B) Harsh (C) Harsh Harsh Harsh (D) ValueError: 'GeeksforGeeks' is not in list Answer: (D) Explanation: The task of the index is to find th
1 min read
Python-Quizzes | Python List Quiz | Question 4
Find the output of the following program: C/C++ Code def addToList(listcontainer): listcontainer += [10] mylistContainer = [10, 20, 30, 40] addToList(mylistContainer) print (len(mylistContainer)) (A) 4 (B) 5 (C) 6 (D) 10 Answer: (B)Explanation: In Python, everything is a reference, and references are passed by value. Parameter passing in Python is
1 min read
Python-Quizzes | Python List Quiz | Question 5
Find the output of the following program: C/C++ Code check2 = check1 check3 = check1[:] check2[0] = 'Code' check3[1] = 'Mcq' count = 0 for c in (check1, check2, check3): if c[0] == 'Code': count += 1 if c[1] == 'Mcq': count += 10 print (count) (A) 4 (B) 5 (C) 11 (D) 12 Answer: (D)Explanation: When assigning check1 to check2, we create a second refe
1 min read
Python-Quizzes | Python List Quiz | Question 6
Find the output of the following program: C/C++ Code def gfg(x,l=[]): for i in range(x): l.append(i*i) print(l) gfg(3,[3,2,1]) (A) [3, 2, 1, 0, 1, 4] (B) [0, 1, 0, 1, 4] (C) [0, 1] (D) [ ] Answer: (A)Explanation: l is a name for a variable that points to a list stored in memory. The function call starts off by creating a new list in a new block of
1 min read
Python-Quizzes | Python List Quiz | Question 7
Find the output of the following program: C/C++ Code # statement 1 list1 = range(100, 110) # statement 2 print (list1.index(105)) (A) 105 (B) 5 (C) 106 (D) 104 Answer: (B)Explanation: Statement 1: will genetrate numbers from 100 to 110 and appent all these numbers in the list. Statement 2: will give the index value of 105 in the list list1. Quiz of
1 min read
Python-Quizzes | Python List Quiz | Question 8
Find the output of the following program: C/C++ Code list2 = list1 list2[0] = 0; print( list1) (A) [1, 2, 3, 4, 5, 0] (B) [0,1, 2, 3, 4, 5] (C) [0, 2, 3, 4, 5] (D) [1, 2, 3, 4, 0] Answer: (C)Explanation: In this problem, we have provided a reference to the list1 with another name list2 but these two lists are same which have two references(list1 an
1 min read
Python-Quizzes | Python List Quiz | Question 9
Find the output of the following program: C/C++ Code list2 = [2014, 2016] print ((list1 + list2)*2) (A) [1998, 2002, 2014, 2016, 1998, 2002, 2014, 2016] (B) [1998, 2002, 2014, 2016] (C) [1998, 2002, 1998, 2002] (D) [2014, 2016, 2014, 2016] Answer: (A)Explanation: When the addition(+) operator uses a list as its operands then the two lists will get
1 min read
Python-Quizzes | Python List Quiz | Question 10
Find the output of the following program: C/C++ Code print (list1[1][-1]) (A) p (B) y (C) 7 (D) 2 Answer: (B)Explanation: In python, we can slice a list but we can also slice an element within the list if it is a string. The declaration list[x][y] will mean that ‘x’ is the index of the element within a list and ‘y’ is the index of an entity within
1 min read
Python-Quizzes | Python List Quiz | Question 11
Find the output of the following program: C/C++ Code list = [1, 2, 3, None, (1, 2, 3, 4, 5), ['Geeks', 'for', 'Geeks']] print(len(list)) (A) 12 (B) 11 (C) 6 (D) 22 Answer: (C)Explanation: The beauty of python list datatype is that within a list, a programmer can nest another list, a dictionary, or a tuple. Since in the code, there are 6 items prese
1 min read
Python-Quizzes | Python List Quiz | Question 12
Question 12: Find the output of the following program: C/C++ Code print(list[0:6:2]) (A) ['python', '@', 'for'] (B) [\'Geeks\', \'Geeks\', \'learning\'] (C) [\'python\', \'learning\', \'@\', \'Geeks\', \'for\', \'Geeks\'] (D) [\'python\', \'Geeks\'] Answer: (A)Explanation: In python list slicing can also be done by using the syntax listName[x:y:z]
1 min read
Python-Quizzes | Python List Quiz | Question 14
Find the output of the following program: C/C++ Code print(list[10:] ) (A) [\'a\', \'b\', \'c\', \'d\', \'e\'] (B) [ \'c\', \'d\', \'e\'] (C) [ ] (D) [\'a\', \'b\'] Answer: (C)Explanation: As one would expect, attempting to access a member of a list using an index that exceeds the number of members (e.g., attempting to access list[10] in the list a
1 min read
Python-Quizzes | Python List Quiz | Question 15
Question 15: Find the output of the following program: C/C++ Code * -3 print(list) (A) [\'a\', \'b\', \'c\', \'a\', \'b\', \'c\', \'a\', \'b\', \'c\'] (B) [\'c\', \'b\', \'a\', \'c\', \'b\', \'a\', \'c\', \'b\', \'a\'] (C) [ ] (D) [\'a\', \'b\', \'c\'] Answer: (C)Explanation: An expression list[listelements]*N where N is an integer appends N copies
1 min read
Python-Quizzes | Python List Quiz | Question 16
Find the output of the following program: C/C++ Code temp = [[x for x in[data]] for x in range(3)] print (temp) (A) [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]] (B) [[2, 3, 9], [2, 3, 9], [2, 3, 9]] (C) [[[2, 3, 9]], [[2, 3, 9]]] (D) None of these Answer: (A)Explanation: [x for x in[data] returns a new list copying the values in the list data and the ou
1 min read
Python-Quizzes | Python List Quiz | Question 17
Find the output of the following program: C/C++ Code data = [x for x in range(5)] temp = [x for x in range(7) if x in data and x%2==0] print(temp) (A) [0, 2, 4, 6] (B) [0, 2, 4] (C) [0, 1, 2, 3, 4, 5] (D) Runtime error Answer: (B)Explanation: This statement checks whether the value lies in list data and if it does whether it’s divisible by 2. It do
1 min read
Python-Quizzes | Python List Quiz | Question 18
Find the output of the following program: C/C++ Code arr = [i[0].upper() for i in temp] print(arr) (A) [‘G’, ‘F’, ‘G’] (B) [‘GEEKS’, ‘FOR’, ‘GEEKS’] (C) [‘GEEKS’] (D) Compilation error Answer: (A)Explanation: The variable i is used to iterate over each element in list temp. i[0] represent the character at 0th index of i and .upper() function is use
1 min read
Python-Quizzes | Python List Quiz | Question 19
Question 19: Find the output of the following program: C/C++ Code temp = 'Geeks 22536 for 445 Geeks' data = [x for x in (int(x) for x in temp if x.isdigit()) if x%2 == 0] print(data) (A) [2, 2, 6, 4, 4] (B) Compilation error (C) Runtime error (D) [‘2’, ‘2’, ‘5’, ‘3’, ‘6’, ‘4’, ‘4’, ‘5’] Answer: (A)Explanation: This is an example of nested list comp
1 min read
Article Tags :
Practice Tags :