wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

02. Python Variables, Data Types, and User Input Quiz

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

What is a variable in Python?

a)

A function that performs calculations

b)

A type of data structure

c)

A storage location for data

d)

A fixed value that cannot change

2.

Which operator is used for modulus in Python?

a)

/

b)

*

c)

%

d)

-

3.

msg = "Welcome to the Data Science Class"

print ( msg.capitalize() )

The output of the code is ...

a)

Welcome to the data science class

b)

welcome to the data science class

c)

WELCOME TO THE DATA SCIENCE CLASS

d)

Welcome To The Data Science Class

e)

error

4.

name = input("Input name: ")

age = input("Input age: ")

print( name + "was born in" + (2021 - age) )

If the user enters Budi and 25 in the terminal, which is the correct output for the code above?

a)

Budi was born in 1996

b)

Budi was born in 25

c)

error

d)

Budi was born in (2021 - age)

e)

Budi was born in 2021-25

5.

x = "2.5"

x = int(x)

What the type of x ?

a)

error

b)

integer

c)

float

d)

string

e)

boolean

6.

What is the output of the following code: print(type(3.14))?

a)

error

b)

float

c)

int

d)

string

7.

msg = "Data Science Purwadhika"

print( msg[-4:].title() )

(a)  

8.

x = 10 % 2

x /= 5

print(x)

(a)  

9.

a, b = 5, 2

print(b+2, a-2)

a)

4 3

b)

7 4

c)

3 4

d)

4 7

e)

error

10.

Which is the correct way to write variables?

a)

myv4r

b)

_myvar

c)

myv@r

d)

1myvar

e)

my var