Unlock hundreds more features
Save your Quiz to the Dashboard
View and Export Results
Use AI to Create Quizzes and Analyse Results

Sign inSign in with Facebook
Sign inSign in with Google

Ace Your Python Quiz Practice Test

Sharpen your coding skills with Python quizzes

Difficulty: Moderate
Grade: Grade 10
Study OutcomesCheat Sheet
Colorful paper art promoting Python Power Quiz for high school and early college students.

Easy
Which of the following file extensions is used for Python files?
.pt
.py
.python
.pyt
Python files use the .py extension, which is the standard recognized by the interpreter and various development tools. This naming convention helps the system correctly identify Python scripts.
Which symbol is used for single-line comments in Python?
/* */
//
--
#
In Python, the '#' symbol is used to denote single-line comments. This tells the interpreter to ignore all text following the '#' on that line.
What is the purpose of the print() function in Python?
It reads user input
It outputs text to the console
It generates random numbers
It terminates a program
The print() function in Python sends output to the console, which is essential for displaying results and debugging. It is a basic yet vital function for any Python program.
Which keyword is used to define a function in Python?
function
define
def
func
In Python, 'def' is the keyword used to define a function. It signals the start of a function block and is followed by the function name and parameters.
Which of the following data types is immutable in Python?
Dictionary
Set
List
Tuple
Tuples are immutable in Python, meaning once they are created, their contents cannot be changed. In contrast, lists, dictionaries, and sets are mutable data types.
Medium
Which of the following will correctly create a list of numbers from 0 to 4 in Python?
[1, 2, 3, 4]
range(5)
list(range(5))
[0, 1, 2, 3, 4, 5]
Using list(range(5)) converts the range object into a list containing numbers from 0 to 4. The range(5) by itself returns a range object, not a list, in Python 3.
Given the code snippet: x = 5 if x > 3: print('High') else: print('Low') What is the output?
Nothing
High
Error
Low
Since x is 5 and the condition x > 3 is true, the code executes the first branch, printing 'High'. The else block is ignored in this case.
Which operator is used to compute the remainder of a division in Python?
/
**
//
%
The modulus operator '%' returns the remainder of a division between two numbers. It is commonly used for operations involving divisibility and looping.
What will be the output of the expression: print(2 ** 3)?
6
9
5
8
The expression 2 ** 3 raises 2 to the power of 3, which equals 8. The print() function then displays this result on the console.
Which of the following is used to handle exceptions in Python?
catch-throw
error handling
if-else
try-except
Python uses the try-except block to handle exceptions, allowing programs to handle errors gracefully. This structure ensures that errors do not cause the program to crash unexpectedly.
How do you import a module named 'math' in Python?
require math
using math
include math
import math
The correct syntax for importing a module in Python is to use the import statement. 'import math' makes the functions and constants of the math module accessible in your code.
What data structure does {} represent in Python?
Empty set
Empty list
Empty tuple
Empty dictionary
In Python, {} creates an empty dictionary by default. To create an empty set, you must use the set() function.
What is the result of the expression: 10 // 3 in Python?
3.33
3
10/3
4
The floor division operator '//' divides and returns the integer part of the quotient. Thus, 10 // 3 evaluates to 3, discarding the remainder.
Which of the following statements correctly creates a string variable in Python?
string s = 'Hello'
var s = 'Hello'
s = 'Hello'
s = Hello
In Python, strings are created by enclosing text in quotes. The assignment s = 'Hello' properly initializes a string variable.
What does the len() function do when applied to a list?
Changes the list's length
Returns the first item
Returns the number of items in the list
Returns the last item
The len() function returns the total number of elements in a list, allowing you to determine its size. It is commonly used in loops and conditional expressions.
Hard
What is the output of the following Python code? numbers = [1, 2, 3, 4] squares = [x**2 for x in numbers if x % 2 == 0] print(squares)
[1, 16]
[1, 4, 9, 16]
[2, 4]
[4, 16]
The list comprehension iterates through the 'numbers' list and processes only the even numbers (2 and 4) by squaring them. Consequently, the output is [4, 16].
What is a lambda function in Python?
An anonymous function defined using the lambda keyword
A named function defined with def
A function that returns another function
A recursive function
A lambda function is a small anonymous function defined with the 'lambda' keyword. It is typically used for short, simple operations and is defined without a name.
Which of the following assignments does NOT create an independent copy of the list 'my_list'?
new_list = list(my_list)
new_list = my_list
new_list = copy.copy(my_list)
new_list = my_list[:]
The assignment 'new_list = my_list' does not create a new list; it only creates a reference to the same list. The other methods create a shallow copy, yielding an independent list object.
What will be the result of the slice operation on the list: my_list = [0, 1, 2, 3, 4] when performing my_list[1:4]?
[1, 2, 3]
[0, 1, 2]
[2, 3, 4]
[1, 2, 3, 4]
Slicing a list using [1:4] extracts elements starting from index 1 up to, but not including, index 4. Thus, the resulting list is [1, 2, 3].
Consider the following Python function: def func(a, b=2): return a * b What is the output of func(3)?
3
6
5
2
When func(3) is called, the parameter b uses its default value of 2. The function then computes 3 multiplied by 2, resulting in an output of 6.
0
{"name":"Which of the following file extensions is used for Python files?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Easy, Which of the following file extensions is used for Python files?, Which symbol is used for single-line comments in Python?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}

Study Outcomes

  1. Understand key Python syntax and semantics for effective programming.
  2. Apply fundamental Python constructs to write and debug code.
  3. Analyze code snippets to identify logical errors and inefficiencies.
  4. Evaluate the use of data structures like lists, dictionaries, and loops.
  5. Create simple programs that demonstrate core Python concepts.

Python Quiz Review Cheat Sheet

  1. Understand Python's Syntax and Structure - Python uses indentation to define code blocks, keeping syntax clean and legible. Practice declaring variables and basic data types to build solid foundations. Official Python Guide
  2. Master Control Flow Statements - Control flow lets you branch logic with if, elif, and else statements. Loop through data with for and while loops to automate tasks. Intro to Python Flow
  3. Work with Functions - Functions group reusable code into named blocks for clarity and maintainability. Define parameters, return values, and use docstrings to document functionality. Function Fundamentals
  4. Explore Python's Data Structures - Lists, tuples, dictionaries, and sets are your go-to data structures for storing and accessing collections. Get hands-on experience to pick the right type for your tasks. Data Structures 101
  5. Handle File Input and Output - Reading from and writing to files helps your programs persist data and process real-world information. Use with statements for safer file handling and automatic resource cleanup. File I/O Handbook
  6. Implement Error Handling - Handle exceptions gracefully using try, except, and finally blocks to prevent crashes. Raising custom errors also helps signal issues clearly when unwanted inputs occur. Exception Handling Guide
  7. Understand Object-Oriented Programming (OOP) - Object-oriented programming models real-world entities with classes and objects for modular code. Explore inheritance and encapsulation to build flexible, reusable components. OOP Essentials
  8. Utilize Python Libraries - Built-in libraries like math, random, and datetime can save you time and effort. Familiarize yourself with popular modules to extend functionality without reinventing the wheel. Standard Library Overview
  9. Practice Debugging Techniques - Debugging skills help you identify and fix code issues quickly. Use print statements, logging, and tools like pdb or built-in IDE debuggers to step through execution. Debugging Tools & Tips
  10. Engage in Hands-On Projects - Solidify your skills by building projects: try simple games, data analysis scripts, or web scrapers. Sharing code on platforms like GitHub boosts your portfolio and confidence. Project Ideas & Challenges
Powered by: Quiz Maker