Font size
WorksheetsCoding with Python Programming Final Exam
Total questions: 3
Worksheet time: 52mins
What type of programming language is Python?
Low-level, compiled
High-level, interpreted
Low-level, interpreted
High-level, compiled
What is the correct syntax to assign a value to a variable in Python?
variable_name == value
variable_name = value
variable_name := value
variable_name => value
Which of the following is an example of a variable assignment in Python?
x == 10
x := 10
x = 10
x => 10
What is an integer in Python?
A number with a fractional part
A whole number without a fractional part
A string of characters
A boolean value
What is an example of an integer in programming?
3.14
Hello, World!
25
98.6
What is a float in programming?
A sequence of characters enclosed in quotes
A number with a decimal point
A comment in the code
An integer
Which of the following is an example of a float?
2024
Alice
3.14
25
What should you be aware of when working with floats?
String concatenation
Integer division
Precision issues with floating-point arithmetic
Escaping characters
What is a string in programming?
A number with a decimal point
A sequence of characters enclosed in quotes
An integer
A comment in the code
Which of the following is an example of a string?
98.6
2024
Hello, World!
25
What is the purpose of comments in code?
To execute additional code
To understand the code better
To increase the speed of the program
To create errors in the code
Which of the following is the correct syntax for a single-line comment in Python?
// This is a single-line comment
/* This is a single-line comment */
# This is a single-line comment
Which of the following is the correct syntax for a multi-line comment in Python?
/* This is a multiline comment */
# This is a multiline comment
""" This is a multiline comment """
What should comments in code be used for?
To explain complex logic
To increase the file size
To make the code run faster
To create syntax errors
What is the purpose of conditional statements in programming?
To create loops
To control the flow of the program based on conditions
To define variables
To print output to the console
Which of the following is the correct syntax for an if-else statement in Python?
if condition: # code to execute if condition is true else: # code to execute if condition is false
if condition { # code to execute if condition is true } else { # code to execute if condition is false }
if (condition) { # code to execute if condition is true } else { # code to execute if condition is false }
if (condition): # code to execute if condition is true else: # code to execute if condition is false
In the given example, what will be printed if the variable age is 18?
Minor
Adult
Teenager
Child
Which logical operators should be understood for using conditional statements effectively?
and, or, not
add, subtract, multiply
if, else, elif
for, while, do
What is the purpose of loops in programming?
To execute a block of code repeatedly
To execute a block of code once
To stop the execution of a program
To debug a program
Which type of loop iterates over a sequence like a list or a range?
While Loop
For Loop
Do-While Loop
Infinite Loop
What is the correct syntax for a 'for' loop in Python?
for item in sequence: # code to execute
while item in sequence: # code to execute
for item: # code to execute
while item: # code to execute
What does the following 'for' loop do?
Prints numbers from 1 to 5
Prints numbers from 0 to 4
Prints numbers from 0 to 5
Prints numbers from 1 to 4
Which type of loop executes as long as a condition is true?
For Loop
While Loop
Do-While Loop
Infinite Loop
What is the correct syntax for a 'while' loop in Python?
while condition: # code to execute
for condition: # code to execute
while item in sequence: # code to execute
for item in sequence: # code to execute
What does the following 'while' loop do?
Prints numbers from 1 to 5
Prints numbers from 0 to 4
Prints numbers from 0 to 5
Prints numbers from 1 to 4
What is the purpose of the print() function in programming?
To capture user input
To output data to the console
To perform mathematical calculations
To store data in a variable
Which of the following is the correct syntax for the print() function?
print("Hello, World!")
input("Hello, World!")
output("Hello, World!")
console("Hello, World!")
What is the purpose of the input() function in programming?
To output data to the console
To capture user input
To perform mathematical calculations
To store data in a variable
Which of the following is the correct syntax for capturing user input using the input() function?
user_input = print("Prompt message: ")
user_input = input("Prompt message: ")
user_input = output("Prompt message: ")
user_input = console("Prompt message: ")
What is an infinite loop?
A. A loop that runs a fixed number of times
B. A loop that runs indefinitely unless explicitly broken
C. A loop that runs only once
D. A loop that runs twice
Which statement can be used to break out of an infinite loop?
A. continue
B. pass
C. break
D. return
What is the purpose of a function in programming?
A. To store data
B. To perform a specific task
C. To create variables
D. To define a class
What is the correct syntax to define a function in Python?
A. function function_name(parameters):
B. def function_name(parameters):
C. define function_name(parameters):
D. func function_name(parameters):
What does the following function return: def add(a, b): return a + b?
A. The product of a and b
B. The difference between a and b
C. The sum of a and b
D. The division of a by b
Which of the following is NOT a basic math operation?
A. Addition
B. Subtraction
C. Multiplication
D. Exponentiation
What is the result of the following operation in Python: x=10,y=5,print(x+y) ?
15
10
5
50
Which of the following operators is used for multiplication in Python?
+
-
*
/
What is the output of the following code: x=10,y=5,print(x/y) ?
2.0
5
50
15
Which of the following is the correct syntax for subtraction in Python?
a + b
a - b
a * b
a / b
Which of the following comparison operators means "greater than or equal to"?
==
!=
>
>=
Which of the following is used for function calls and grouping expressions in Python?
Curly braces {}
Square brackets []
Parentheses ()
Angle brackets <>
In Python, what is the purpose of indentation?
To make the code look neat
To define code blocks
To separate variables
To comment out code
Which symbol is used to start an indented block in control structures in Python?
Semicolon ;
Comma ,
Colon :
Period .
What will be the output of the following Python code if the variable 'name' is not defined?
Hello,
Hello, World!
Error
Hello, name
Which of the following is a best practice for naming variables in Python?
Use uppercase letters and numbers
Use descriptive names
Use reserved words
Use single letters
What is the recommended way to separate words in variable names in Python?
Using hyphens
Using spaces
Using underscores
Using periods
Which of the following is a recommended practice for coding?
Write large programs without testing.
Write small programs to apply each concept.
Avoid reading documentation.
Use abbreviations in naming conventions.
What should you do to familiarize yourself with Python for deeper understanding?
Ignore Python's official documentation.
Read Python's official documentation.
Only use online forums.
Avoid coding communities.
How much are you enjoying the IT/Coding course?
I don't like it
I like it
I love it
I want to become a programmer/coder
How do you feel about the Saturday program?
