Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python

Total questions: 26

Worksheet time: 19mins

Name
Class
Date
1.

What is the difference between the data types "int" and "float"?

a)

'int' represents whole numbers, while 'float' represents sequences of characters.

b)

'int' represents characters, while 'float' represents numbers.

c)

'int' represents whole numbers, while 'float' represents decimal numbers.

d)

'int' represents positive numbers, while 'float' represents negative numbers.

2.

What are variables in Python?

a)
Variables in Python are used to control the flow of a program.
b)

Variables in Python are used to look cool and awesome.

c)
Variables in Python are used to store data values.
d)
Variables in Python are used to define functions.
3.

What are booleans?

a)
Numbers between 1 and 10
b)
Strings of text
c)
Arrays of values
d)
True or false values
4.

How do you check if two values are equal in Python?

a)
==
b)
<>
c)
is
d)
!=
5.

What is the difference between "=" and "==" in Python?

a)
The '=' operator is used for assignment, while the '==' operator is used for comparison.
b)
The '=' operator is used for assignment, while the '==' operator is used for arithmetic operations.
c)
The '=' operator is used for comparison, while the '==' operator is used for logical operations.
d)
The '=' operator is used for comparison, while the '==' operator is used for assignment.
6.

What is the output to the python code?
X = 5

Y = 5

print(X == Y)

a)
Error
b)
True
c)
None
d)
False
7.

What is the output to this Python code?

X = 5

Y = 3

print(X == Y)

a)
False
b)
3
c)
5
d)
True
8.

What is the purpose of Conditional statements in Python?

a)
The purpose of Conditional statements in Python is to make decisions and execute different code blocks based on different conditions.
b)
The purpose of Conditional statements in Python is to perform mathematical calculations.
c)
The purpose of Conditional statements in Python is to repeat a block of code multiple times.
d)
The purpose of Conditional statements in Python is to define variables and assign values to them.
9.
A type that represents sequences of characters.
a)
string
b)
value
c)
constant
d)
expression
10.
A type that represents numbers with fractional parts.
a)
string
b)
value
c)
integer
d)
floating - point
11.
A name that refers to a value.
a)
value
b)
constant
c)
variable
d)
expression
12.
A type that represents whole numbers. A type that represents whole numbers.
a)
string
b)
value
c)
integer
d)
floating - point
13.
A special symbol that represents a simple computation like addition, multiplication, or string concatenation.
a)
operator
b)
operand
c)
precedence
d)
evaluate
14.
The set of rules governing the order in which expressions involving multiple operators and operands are evaluated.
a)
operator
b)
concatenation
c)
precedence
d)
evaluate
15.

These are long sets of characters in quotation marks.

a)
string
b)
list
c)
tuple
d)
dictionary
16.
Information in a program that is meant for other programmers (or anyone reading the source code) and has no effect on the execution of the program.
a)
value
b)
keywords
c)
comment
d)
expression
17.

Which of the following operators is used to check if two values are not equal in Python?

a)

!=

b)

==

c)

<>

d)

>

18.

How do you write an if statement to check if `x` is greater than 10?

a)

if x > 10:

b)

if x is > 10:

c)

if x >> 10:

d)

if x gt 10:

19.

Which logical operator is used in Python to combine two boolean conditions and returns True if both conditions are true?

a)

OR

b)

AND

c)

NOT

d)

XOR

20.

In Python, what is the correct way to write an if statement that checks if `x` is either 10 or 20?

a)

if x == 10 or x == 20:

b)

if x = 10 || x = 20:

c)

if x == 10 | x == 20:

d)

if x == (10 or 20):

21.

Which of the following is a valid comparison operator in Python for checking greater than or equal to?

a)

>=

b)

=>

c)

>+

d)

=<

22.

What is the correct way to use logical operators for combining conditions in Python?

a)

if condition1 && condition2:

b)

if condition1 and condition2:

c)

if condition1 & condition2:

d)

if condition1 + condition2:

23.

In Python, how do you write an if statement to check if `x` is between 5 and 10, inclusive?

a)

if x > 5 and x < 10:

b)

if 5 <= x <= 10:

c)

if x >= 5 or x <= 10:

d)

if x == 5 and x == 10:

24.

Which of the following is the correct way to define a function in Python?

a)

myFunction() = def:

b)

function myFunction():

c)

define myFunction:

d)

def myFunction():

25.

What is the purpose of the 'return' statement in a function?

a)

To print output to the console

b)

To end the program

c)

To return a value from a function

d)

To define a function

26.

What is the purpose of the 'break' statement in a loop?

a)

To continue to the next iteration

b)

To exit the loop immediately

c)

To skip the current iteration

d)

To pause the loop for a moment