wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Coding with Python Programming Final Exam

Total questions: 3

Worksheet time: 52mins

Name
Class
Date
1-48.
1.

What type of programming language is Python?

a)

Low-level, compiled

b)

High-level, interpreted

c)

Low-level, interpreted

d)

High-level, compiled

2.

What is the correct syntax to assign a value to a variable in Python?

a)

variable_name == value

b)

variable_name = value

c)

variable_name := value

d)

variable_name => value

3.

Which of the following is an example of a variable assignment in Python?

a)

x == 10

b)

x := 10

c)

x = 10

d)

x => 10

4.

What is an integer in Python?

a)

A number with a fractional part

b)

A whole number without a fractional part

c)

A string of characters

d)

A boolean value

5.

What is an example of an integer in programming?

a)

3.143.14

b)

Hello, World!\text{Hello, World!}

c)

2525

d)

98.698.6

6.

What is a float in programming?

a)

A sequence of characters enclosed in quotes

b)

A number with a decimal point

c)

A comment in the code

d)

An integer

7.

Which of the following is an example of a float?

a)

20242024

b)

Alice\text{Alice}

c)

3.143.14

d)

2525

8.

What should you be aware of when working with floats?

a)

String concatenation

b)

Integer division

c)

Precision issues with floating-point arithmetic

d)

Escaping characters

9.

What is a string in programming?

a)

A number with a decimal point

b)

A sequence of characters enclosed in quotes

c)

An integer

d)

A comment in the code

10.

Which of the following is an example of a string?

a)

98.698.6

b)

20242024

c)

Hello, World!\text{Hello, World!}

d)

2525

11.

What is the purpose of comments in code?

a)

To execute additional code

b)

To understand the code better

c)

To increase the speed of the program

d)

To create errors in the code

12.

Which of the following is the correct syntax for a single-line comment in Python?

a)

// This is a single-line comment

b)

/* This is a single-line comment */

c)

# This is a single-line comment

d)

13.

Which of the following is the correct syntax for a multi-line comment in Python?

a)

/* This is a multiline comment */

b)

c)

# This is a multiline comment

d)

""" This is a multiline comment """

14.

What should comments in code be used for?

a)

To explain complex logic

b)

To increase the file size

c)

To make the code run faster

d)

To create syntax errors

15.

What is the purpose of conditional statements in programming?

a)

To create loops

b)

To control the flow of the program based on conditions

c)

To define variables

d)

To print output to the console

16.

Which of the following is the correct syntax for an if-else statement in Python?

a)

if condition: # code to execute if condition is true else: # code to execute if condition is false

b)

if condition { # code to execute if condition is true } else { # code to execute if condition is false }

c)

if (condition) { # code to execute if condition is true } else { # code to execute if condition is false }

d)

if (condition): # code to execute if condition is true else: # code to execute if condition is false

17.

In the given example, what will be printed if the variable age is 18?

a)

Minor

b)

Adult

c)

Teenager

d)

Child

18.

Which logical operators should be understood for using conditional statements effectively?

a)

and, or, not

b)

add, subtract, multiply

c)

if, else, elif

d)

for, while, do

19.

What is the purpose of loops in programming?

a)

To execute a block of code repeatedly

b)

To execute a block of code once

c)

To stop the execution of a program

d)

To debug a program

20.

Which type of loop iterates over a sequence like a list or a range?

a)

While Loop

b)

For Loop

c)

Do-While Loop

d)

Infinite Loop

21.

What is the correct syntax for a 'for' loop in Python?

a)

for item in sequence: # code to execute

b)

while item in sequence: # code to execute

c)

for item: # code to execute

d)

while item: # code to execute

22.

What does the following 'for' loop do?

a)

Prints numbers from 1 to 5

b)

Prints numbers from 0 to 4

c)

Prints numbers from 0 to 5

d)

Prints numbers from 1 to 4

23.

Which type of loop executes as long as a condition is true?

a)

For Loop

b)

While Loop

c)

Do-While Loop

d)

Infinite Loop

24.

What is the correct syntax for a 'while' loop in Python?

a)

while condition: # code to execute

b)

for condition: # code to execute

c)

while item in sequence: # code to execute

d)

for item in sequence: # code to execute

25.

What does the following 'while' loop do?

a)

Prints numbers from 1 to 5

b)

Prints numbers from 0 to 4

c)

Prints numbers from 0 to 5

d)

Prints numbers from 1 to 4

26.

What is the purpose of the print() function in programming?

a)

To capture user input

b)

To output data to the console

c)

To perform mathematical calculations

d)

To store data in a variable

27.

Which of the following is the correct syntax for the print() function?

a)

print("Hello, World!")

b)

input("Hello, World!")

c)

output("Hello, World!")

d)

console("Hello, World!")

28.

What is the purpose of the input() function in programming?

a)

To output data to the console

b)

To capture user input

c)

To perform mathematical calculations

d)

To store data in a variable

29.

Which of the following is the correct syntax for capturing user input using the input() function?

a)

user_input = print("Prompt message: ")

b)

user_input = input("Prompt message: ")

c)

user_input = output("Prompt message: ")

d)

user_input = console("Prompt message: ")

30.

What is an infinite loop?

a)

A. A loop that runs a fixed number of times

b)

B. A loop that runs indefinitely unless explicitly broken

c)

C. A loop that runs only once

d)

D. A loop that runs twice

31.

Which statement can be used to break out of an infinite loop?

a)

A. continue

b)

B. pass

c)

C. break

d)

D. return

32.

What is the purpose of a function in programming?

a)

A. To store data

b)

B. To perform a specific task

c)

C. To create variables

d)

D. To define a class

33.

What is the correct syntax to define a function in Python?

a)

A. function function_name(parameters):

b)

B. def function_name(parameters):

c)

C. define function_name(parameters):

d)

D. func function_name(parameters):

34.

What does the following function return: def add(a, b): return a + b?

a)

A. The product of a and b

b)

B. The difference between a and b

c)

C. The sum of a and b

d)

D. The division of a by b

35.

Which of the following is NOT a basic math operation?

a)

A. Addition

b)

B. Subtraction

c)

C. Multiplication

d)

D. Exponentiation

36.

What is the result of the following operation in Python: x=10,y=5,print(x+y)x = 10, y = 5, print(x + y) ?

a)

15

b)

10

c)

5

d)

50

37.

Which of the following operators is used for multiplication in Python?

a)

+

b)

-

c)

*

d)

/

38.

What is the output of the following code: x=10,y=5,print(x/y)x = 10, y = 5, print(x / y) ?

a)

2.0

b)

5

c)

50

d)

15

39.

Which of the following is the correct syntax for subtraction in Python?

a)

a + b

b)

a - b

c)

a * b

d)

a / b

40.

Which of the following comparison operators means "greater than or equal to"?

a)

==

b)

!=

c)

>

d)

>=

41.

Which of the following is used for function calls and grouping expressions in Python?

a)

Curly braces {}

b)

Square brackets []

c)

Parentheses ()

d)

Angle brackets <>

42.

In Python, what is the purpose of indentation?

a)

To make the code look neat

b)

To define code blocks

c)

To separate variables

d)

To comment out code

43.

Which symbol is used to start an indented block in control structures in Python?

a)

Semicolon ;

b)

Comma ,

c)

Colon :

d)

Period .

44.

What will be the output of the following Python code if the variable 'name' is not defined?

a)

Hello,

b)

Hello, World!

c)

Error

d)

Hello, name

45.

Which of the following is a best practice for naming variables in Python?

a)

Use uppercase letters and numbers

b)

Use descriptive names

c)

Use reserved words

d)

Use single letters

46.

What is the recommended way to separate words in variable names in Python?

a)

Using hyphens

b)

Using spaces

c)

Using underscores

d)

Using periods

47.

Which of the following is a recommended practice for coding?

a)

Write large programs without testing.

b)

Write small programs to apply each concept.

c)

Avoid reading documentation.

d)

Use abbreviations in naming conventions.

48.

What should you do to familiarize yourself with Python for deeper understanding?

a)

Ignore Python's official documentation.

b)

Read Python's official documentation.

c)

Only use online forums.

d)

Avoid coding communities.

49.

How much are you enjoying the IT/Coding course?

a)

I don't like it

b)

I like it

c)

I love it

d)

I want to become a programmer/coder

50.

How do you feel about the Saturday program?

4 lines