Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz 1 : Python Basics

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which function outputs text to the terminal?

a)

write()

b)

print()

c)

output()

d)

type()

2.

What is Python syntax for creating a variable and assigning the number 10 to it?

a)

def variable_name = 10

b)

variable_name == 10

c)

variable_name = 10

d)

new variable_name = 10

3.

How do you combine two strings?

a)

string1.concatenate(string2)

b)

string1.combine(string2)

c)

string1 + string2

4.

What is the value of total_cost that gets printed?

total_cost = 5

total_cost += 10

print(total_cost)

a)

15

b)

5

c)

10

5.

What is the output of the following code?

cool_number = 12 + 30

cool_number * 5

print(cool_number)

a)

210

b)

42

c)

cool_number

6.

What happens when running the following code?


message = What a cool message!

print(message)

a)

"message" is printed

b)

"What a cool message!" is printed

c)

Python throws a SyntaxError

7.

Which of the following will produce a SyntaxError?

a)

answer = "Is this an error"

b)

answer = "Is this an error'

c)

answer = is_this_an_error

8.

Which of the following defined variables is a string?


cool_variable_1 = 23.18

cool_variable_2 = 9

cool_variable_3 = "Important Message!"

cool_variable_4 = 14 ** 3

a)

cool_variable1

b)

cool_variable2

c)

cool_variable3

d)

cool_variable4

9.

What is the difference between a float and an int?

a)

A float is a whole number. An int has a decimal point

b)

A float represents decimal numbers. An int is a whole number

c)

A float contains text. An int is any number

10.

Which character is used to specify a comment in Python?

a)

"

b)

*

c)

/

d)

#