Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics Quiz

Total questions: 12

Worksheet time: 9mins

Name
Class
Date
1.

What is the purpose of a variable in Python?

a)

To store data

b)

To print text

c)

To perform calculations

d)

To comment on code

2.

How do you concatenate (add together) two strings in Python?

a)

str1 + str2

b)

str1 . str2

c)

str1, str2

d)

concatenate(str1, str2)

3.

What does the print() function do in Python?

a)

Takes user input

b)

Displays output to the console

c)

Performs mathematical operations

d)

Declares variables

4.

Which of the following is used to take user input in Python?

a)

get_input()

b)

read_input()

c)

input()

d)

user_input()

5.

Which of the following is a valid string in Python?

a)

"dog"

b)

dog

c)

(dog)

d)

^dog^

6.

What is the output of the following code?

x = "apple"

y = "banana"

z = x + y

print(z)

a)

x + y

b)
applebanana
c)

apple banana

d)

z

7.

What data type does the input() function return?

a)

Integer

b)

Float

c)

String

d)

Boolean

8.

What is the output of the following code?

big = "Apple"

little = "Grape"

mix = little + big

print(mix)

a)

GrapeApple

b)
littlebig
c)

AppleGrape

d)

mix

9.

Which of the following is the correct way to store the string "dog" in a variable called var?

a)

var = "dog"

b)

"dog" = var

c)

var := "dog"

d)

var -> "dog"

10.

What is the output of the following code?

fruit1 = "Mango"

fruit2 = "Pineapple"

result = fruit1 + fruit2

print(result)

a)

MangoPineapple

b)

PineappleMango

c)

fruit1fruit2

d)

result

11.

What is the output of the following code?

num1 = "5"

num2 = "7"

result = num1 + num2

print(result)

a)

57

b)

12

c)

num1num2

d)

result

12.

Which of the following is the correct way to store the string "cat" in a variable called animal?

a)

animal = "cat"

b)

"cat" = animal

c)

animal := "cat"

d)

animal -> "cat"