wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics for Beginners

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the correct file extension for Python files?

a)

.py

b)

.pyth

c)

python.file

d)

.pyt

2.

How do you create a variable in Python?

a)

Create a variable by writing 'value -> variable_name'.

b)

Assign a variable with 'variable_name : value'.

c)

Declare a variable using 'value = variable_name'.

d)

Use the syntax 'variable_name = value' to create a variable.

3.

What keyword is used to define a function in Python?

a)

method

b)

def

c)

function

d)

define

4.

Which of the following is a valid list in Python?

a)

(1, 2, 3)

b)

{1, 2, 3}

c)

[1, 2, 3]

d)

[1; 2; 3]

5.

What is the output of print(2 ** 3)?

a)

4

b)

8

c)

6

d)

9

6.

How do you start a comment in Python?

a)

Start comments using the '/*' symbol.

b)

Use the '#' symbol to start a comment.

c)

Use the '@' symbol to start a comment.

d)

Begin a comment with '//' in Python.

7.

What data type is used to represent text in Python?

a)

str

b)

string

c)

char

d)

text

8.

Which function is used to read input from the user?

a)

read()

b)

getInput()

c)

fetchInput()

d)

input()

9.

What is the purpose of the 'if' statement in Python?

a)

The 'if' statement in Python is for creating loops.

b)

The 'if' statement in Python is meant for importing modules.

c)

The 'if' statement in Python is used to define functions.

d)

The purpose of the 'if' statement in Python is to execute code conditionally based on a boolean expression.

10.

How do you create a loop that runs 5 times in Python?

a)

for i in range(5): pass

b)

while i < 5: pass

c)

repeat 5 times: pass

d)

for i in range(10): pass