wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Grade 6 Revision - Unit 3 Python

Total questions: 70

Worksheet time: 35mins

Name
Class
Date
1.

How can you print multiple values on the same line in Python?

a)

Using the print() function with multiple arguments

b)

Using the input() function with multiple arguments

c)

Using the format() function to concatenate strings

d)

Both a and c

2.

How can you get input from the user and store it in multiple variables in Python?

a)

Using the input() function with multiple arguments

b)

Using the input() function with a comma-separated list of variable names

c)

Using the input() function and splitting the input by a specified separator

d)

Both b and c

3.

Which of the following is not a valid assignment operator in Python?

a)

=

b)

+=

c)

-=

d)

**=

4.

What is the purpose of the assignment operators in Python?

a)

To perform mathematical operations on operands

b)

To compare operands

c)

To assign values to variables

d)

To manipulate the logical state of operands

5.

What is the purpose of the arithmetic operators in Python?

a)

To perform mathematical operations on operands

b)

To compare operands

c)

To assign values to variables

d)

To manipulate the logical state of operands

6.

What data type is the input from the user in Python by default?

a)

Integer

b)

Float

c)

String

d)

Boolean

7.

Which keyword do you use to start a for loop in Python?

a)

for

b)

while

c)

if

d)

repeat

8.

What is the purpose of the comparison operators in Python?

a)

To perform mathematical operations on operands

b)

To compare operands

c)

To assign values to variables

d)

To manipulate the logical state of operands

9.

What word do you use to start an if statement in Python?

a)

if

b)

then

c)

else

d)

switch

10.

Which of these is the correct way to write an if statement in Python?

a)

if (condition):

code

b)

if condition:

code

c)

if (condition) then:

code

d)

if condition then:

code

11.

What is the purpose of the logical operators in Python?

a)

To perform mathematical operations on operands

b)

To compare operands

c)

To assign values to variables

d)

To manipulate the logical state of operands

12.

Which of these is the correct way to write an if-else statement in Python?

a)

if (condition):

code

else: code

b)

if condition then:

code

else:

code

c)

if (condition) then: code

else:

code

d)

if condition:

code

else:

code

13.

What does the range() function do in a for loop in Python?

a)

It sets the start and end of the loop

b)

It sets the step size of the loop

c)

It creates a list of numbers to loop through

d)

Both a and c

14.

Which of these is a common way to exit a while loop?

a)

Using the break statement

b)

Using the continue statement

c)

Using the return statement

d)

All of the above

15.

How can you exit a for loop early in Python?

a)

by using the break keyword

b)

by using the continue keyword

c)

by using the return keyword

d)

by using the exit() function

16.

What is the purpose of a while loop?

a)

To execute a block of code a specific number of times

b)

To execute a block of code until a certain condition is met

c)

To execute a block of code for each item in a list

d)

To execute a block of code only once

17.

How can you combine multiple conditions in an if statement in Python?

a)

Use the and and or operators

b)

Use the if, elif, and else keywords

c)

Use the switch statement

d)

Both a and b

18.

What happens if the condition in an if statement is false?

a)

The code inside the if statement runs

b)

The code inside the if statement does not run

c)

An error happens

d)

The program stops

19.

Which of the following is the correct syntax for a while loop in Python?

a)

for i in range(10):

b)

while i < 10:

c)

if i < 10:

d)

while i:

20.

What does the not operator do in Python?

a)

It makes the statement true if the condition is true

b)

It makes the statement false if the condition is true

c)

It makes the statement true if the condition is false

d)

It makes the statement false if the condition is false

21.

What is the purpose of the elif statement in an if statement in Python?

a)

To run a piece of code if the previous condition is true

b)

To run a piece of code if the previous condition is false

c)

To add another condition to the if statement

d)

To stop the if statement

22.

What is the result of the expression 5 > 3 or 2 > 4 in Python?

a)

True

b)

False

c)

1

d)

0

23.

What is the purpose of the else statement in an if statement in Python?

a)

To run a piece of code if the previous condition is true

b)

To run a piece of code if the previous condition is false

c)

To add another condition to the if statement

d)

To stop the if statement

24.

What is the purpose of an if statement in Python?

a)

To run a piece of code if a condition is true

b)

To run a piece of code if a condition is false

c)

To repeat a piece of code

d)

To create a function

25.

What happens if the condition in a while loop is always True?

a)

The loop will execute once and then stop

b)

The loop will never execute

c)

The loop will execute indefinitely

d)

The loop will execute 10 times

26.

What is the purpose of an if-else statement?

a)

To execute a block of code only if a certain condition is true

b)

To execute a block of code a specific number of times

c)

To create a loop that continues until a certain condition is met

d)

Both a) and c)

27.

Which of the following is not a valid comparison operator in Python?

a)

>

b)

=

c)

>=

d)

!=

28.

What does the and operator do in Python?

a)

It makes the statement true if both parts are true

b)

It makes the statement true if at least one part is true

c)

It makes the statement false if both parts are false

d)

Both a and c

29.

How can you make a for loop go through a list in Python?

a)

by using the range() function

b)

by using the list() function

c)

by using the for i in list_name: syntax

d)

by using the for each keyword

30.

Which of these statements is true about the condition in a while loop?

a)

The condition must be a numerical value

b)

The condition must be a boolean expression

c)

The condition must be a string

d)

The condition can be any type of expression

31.

What is the result of the expression 10 / 3 in Python?

a)

3

b)

3.0

c)

3.33

d)

3.333333333

32.

Which of the following is the correct way to get input from the user in Python?

a)

x = input("Enter a number: ")

b)

x = input(Enter a number: )

c)

x = input(int("Enter a number: "))

d)

Both a and c

33.

What is the purpose of a for loop in Python?

a)

To run a piece of code once

b)

To run a piece of code a certain number of times

c)

To run a piece of code until a condition is met

d)

To create a function

34.

What is the result of the expression 5 > 3 and 2 < 4 in Python?

a)

True

b)

False

c)

1

d)

0

35.

What is the result of the expression for i in range(3) in Python?

a)

The loop runs 0 times

b)

The loop runs 1 time

c)

The loop runs 3 times

d)

The loop runs 4 times

36.

How can you add another condition to an if statement in Python?

a)

Use the else keyword

b)

Use the elseif keyword

c)

Use the elif keyword

d)

Use the otherwise keyword

37.

When would you use logical operators in a Python program?

a)

When you need to check if multiple conditions are true

b)

When you need to check if at least one condition is true

c)

When you need to check if a condition is false

d)

All of the above

38.

Which of the following is not a valid arithmetic operator in Python?

a)

+

b)

-

c)

*

d)

%/

39.

What does the or operator do in Python?

a)

It makes the statement true if both parts are true

b)

It makes the statement true if at least one part is true

c)

It makes the statement false if both parts are false

d)

Both b and c

40.

What is the purpose of a for loop in Python?

a)

To run a piece of code once

b)

To run a piece of code a certain number of times

c)

To run a piece of code until a condition is met

d)

To create a function

41.

How many times will the code inside a for loop run if the loop goes from 0 to 4?

a)

0 times

b)

1 time

c)

4 times

d)

5 times

42.

What is the correct way to write a for loop in Python?

a)

for i = 0 to 5:

code

b)

for (i = 0; i < 5; i++):

code

c)

for i in range(5):

code

d)

for i from 0 to 5:

code

43.

What happens if the condition in an if statement is False?

a)

The code block inside the if statement will be executed

b)

The code block inside the else statement will be executed

c)

Nothing happens, the program will continue to the next line

d)

The program will crash

44.

What is the result of the expression x = 5; x += 2 in Python?

a)

x = 7

b)

x = 2

c)

x = 10

d)

x = 5

45.

What is the name of the the programming language you learned in Unit 3?

a)

Java

b)

C++

c)

Python

d)

JavaScript

46.

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

a)

if condition:

# code block

else:

# code block

b)

if (condition):

# code block

else:

# code block

c)

if condition:

# code block

else

if condition:

# code block

d)

if (condition):

# code block

elif condition:

# code block

else:

# code block

47.

What is the purpose of the len() function in Python?

a)

To get the length of a string

b)

To perform mathematical calculations

c)

To display output on the screen

d)

To get input from the user

48.

What is the output of the following code?

a)

1 1

1 2

2 1

2 2

3 1

3 2

b)

1 1

1 2

2 1

2 2

3 1

3 2

3 3

c)

1 1

1 2

2 1

2 2

3 1

3 3

d)

1 1

2 1

3 1

49.

What is the operator used to perform addition in Python?

a)

+

b)

-

c)

*

d)

/

50.

What is a variable in Python?

a)

A container that stores a value

b)

A block of code that can be reused

c)

A way to display output on the screen

d)

A way to get input from the user

51.

What is the output of the following code?

a)

Positive

b)

Negative

c)

Zero

d)

No output

52.

Which of these is a data type in Python?

a)

Integer

b)

String

c)

Boolean

d)

All of the above

53.

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

a)

To store a value in a variable

b)

To perform mathematical calculations

c)

To display output on the screen

d)

To get input from the user

54.

What function is used to get input from the user in Python?

a)

print()

b)

input()

c)

output()

d)

read()

55.

Which of these can be used as a condition in an if-else statement?

a)

A numerical value

b)

A boolean expression

c)

A string

d)

All of the above

56.

What is the purpose of a comment in Python code?

a)

To explain what the code does

b)

To make the code run faster

c)

To change the behavior of the code

d)

To display output on the screen

57.

What is the purpose of the elif statement in an if-else statement?

a)

To check an additional condition if the first condition is False

b)

To create a loop that continues until a certain condition is met

c)

To execute a block of code a specific number of times

d)

To create a nested if-else statement

58.

Which of these is a valid variable name in Python?

a)

my_variable

b)

1_variable

c)

variable-name

d)

both a) and b)

59.

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

a)

function my_function()

b)

def my_function()

c)

create my_function()

d)

function: my_function()

60.

How can you check if two conditions are both true in an if-else statement?

a)

Use the and operator

b)

Use the or operator

c)

Use the not operator

d)

Use the ==operator

61.

What is the output of the following code?

a)

You can vote!

b)

You can't vote yet.

c)

No output

d)

Both a) and b)

62.

Suppose you want to check if a number is even or odd. Which of these if-else statements would be the best way to do this?

a)

if num % 2 == 0: print("Even")

else:

print("Odd")

b)

if num % 2: print("Odd")

else:

print("Even")

c)

if num % 2 == 1: print("Odd")

else:

print("Even")

d)

Both a) and c)

63.

Which of these is a good use case for an if-else statement?

a)

Checking the user's age to determine if they can vote

b)

Calculating the area of a circle

c)

Iterating through a list of numbers

d)

Both a) and b)

64.

Which of the following shapes is commonly used to represent a decision or branch in a Python flowchart?

a)

Oval

b)

Rectangle

c)

Diamond

d)

Parallelogram

65.

Which of the following Python statements is typically represented by the "process" shape in a flowchart?

a)

If-else statement

b)

For loop

c)

Function call

d)

All of the above

66.

In a Python flowchart, what does the "terminator" shape (e.g., oval) typically represent?

a)

The start or end of the program

b)

A decision point

c)

A process or operation

d)

Input/output

67.

Which of the following symbols is used to represent the input or output of data in a Python flowchart?

a)

Rectangle

b)

Parallelogram

c)

Diamond

d)

Cylinder

68.

How can a Python flowchart help in the debugging process?

a)

It can identify logic errors in the code

b)

It can speed up the execution of the program

c)

It can automatically fix errors in the code

d)

It can generate test cases

69.

What is the main advantage of using a flowchart in Python programming?

a)

It makes the code more concise

b)

It improves the readability and understanding of the program

c)

It reduces the need for comments in the code

d)

It automatically optimizes the program's performance

70.

Which of the following Python constructs is typically represented by a decision shape (e.g., diamond) in a flowchart?

a)

Variable assignment

b)

Function definition

c)

If-elif-else statements

d)

Print statements