wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

Which of the following is a valid variable name in Python?

a)

A. 1variable

b)

B. my-variable

c)

C. _variablename

d)

D. variable name

2.

How do you print "Hello, World!" to the console in Python 3?

a)

A. print("Hello, World!")

b)

B. print "Hello, World!"

c)

C. echo "Hello, World!"

d)

D. System.out.println("Hello, World!")

3.

What is the result of the expression 5 + 3 * 2?

a)

A. 10

b)

B. 16

c)

C. 11

d)

D. 26

4.

Which symbol is used for single-line comments in Python?

a)

//

b)

--

c)

#

d)

/*

5.

How do you declare a variable in Python?

a)

A. var my_variable

b)

B. my_variable =

c)

C. variable my_variable

d)

D. my_variable = 10

6.

What is the output of print(5 + 2) in Python?

a)

A. 52

b)

B. 7

c)

C. "5 + 2"

d)

D. Error

7.

Which of the following is a valid string in Python?

a)

A. 'Hello, World!"

b)

B. "Hello, World!"

c)

C. Hello, World!

d)

D. "Hello, World!'

8.

Which operator is used for exponentiation in Python?

a)

A. ^

b)

B. **

c)

C. ^

d)

D. %

9.

How do you check if two variables have the same value in Python?

a)

A. x is y

b)

B. x == y

c)

C. x = y

d)

D. x != y

10.

What is the purpose of the if statement in Python?

a)

A. To declare a variable

b)

B. To define a function

c)

C. To conditionally execute code

d)

D. To loop through a sequence