wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

9.1.4 Python Quiz 🐍

Total questions: 48

Worksheet time: 31mins

Name
Class
Date
1.

What will the following statement output? print("Hello, World!")

a)

a) Error

b)

b) Hello, World

c)

c) HelloWorld

d)

d) Hello, World!

2.

🖨️ Which of the following is the correct syntax to print a string in Python?

a)

a) print string("Hello")

b)

b) print(string: "Hello")

c)

c) print("Hello")

d)

d) echo("Hello")

3.

What will the following statement output? print(123)

a)

a) 123

b)

b) "123"

c)

c) Error

d)

d) 123.0

4.

📊 Which data type is 3.14 in Python?

a)

a) String

b)

b) Integer

c)

c) Float

d)

d) List

5.

What will the following statement output? print("Age: " + 20)

a)

a) Age: 20

b)

b) Error

c)

c) Age: +20

d)

d) 20Age:

6.

🌉 How can we fix the error in the previous question?

a)

a) print("Age: " + str(20))

b)

b) print("Age: " , 20)

c)

c) Both a and b

d)

d) print(20 + "Age: ")

7.

What will the following statement output? print(len("Python"))

a)

a) 5

b)

b) 6

c)

c) Error

d)

d) Python

8.

🛠️ Which of the following functions can be used to convert a string into an integer?

a)

a) str()

b)

b) int()

c)

c) float()

d)

d) char()

9.

After executing x = 10, what is the value of x?

a)

a) "10"

b)

b) 10.0

c)

c) x

d)

d) 10

10.

📦 Which of the following is a valid variable assignment?

a)

a) 1a = "Python"

b)

b) $var = "Python"

c)

c) _myVar = "Python"

d)

d) None of the above

11.

Given name = "Alice", what will the following statement output? print("Hello, " + name + "!")

a)

a) Hello, Alice!

b)

b) Hello, name!

c)

c) Error

d)

d) Hello, +name+!

12.

🖋️ True or False: To output a variable as part of a print statement, you can use the + operator to concatenate it with other strings.

a)

True

b)

False

13.

To output the string representation of an integer, you can use the (a)   function.

14.

The print function in Python is used to (a)   data to the console.

15.

The (a)   function can be used to find the length of a string.

16.

The value on the right side of the = operator is (a)   to the variable on the left.

17.

Variables are used to (a)   data values in Python.

18.

🎨 To combine a string and an integer in a print statement without causing an error, you can use the (a)   function to convert the integer to a string.

19.

The result of the function type(42) in Python is (a)   .

20.

🎭 When you assign a value to a variable, you are creating a (a)   for that value.

21.

Which of the following will output the string "Python" 5 times without a space in between?

a)

a) print("Python"5)

b)

b) print("Python"+5)

c)

c) print("Python", 5)

d)

d) print(5"Python")

22.

True or False: In Python, variable names are case-sensitive.

a)

True

b)

False

23.

Which of the following will produce the output 7?

a)

a) print("3+4")

b)

b) print(3+4)

c)

c) print(int("3")+4)

d)

d) Both b and c

24.

Given x = "Hello", what will print(x.upper()) output?

a)

a) hello

b)

b) HELLO

c)

c) Hello

d)

d) Error

25.

True or False: In the statement age = 25, "age" is a data and 25 is a variable.

a)

True

b)

False

26.

🍎 Fill in the blank: (a)   is a built-in Python function used to get the data type of a variable.

27.

Which function will convert a float to an integer?

a)

a) str()

b)

b) int()

c)

c) float()

d)

d) list()

28.

🧭 True or False: You can use the print function to display multiple items by separating them with commas.

a)

True

b)

False

29.

Given fruit = "apple", what will print(fruit[1]) output?

a)

a) a

b)

b) p

c)

c) pple

d)

d) apple

30.

🌟 Fill in the blank: In Python, variables are used as (a)   to store data.

31.

Which of the following will produce an error?

a)

a) print(10 + int("20"))

b)

b) print("10" + 20)

c)

c) print("10" + str(20))

d)

d) print(10 + 20)

32.

The print() function outputs data to the (a)   .

33.

To combine multiple strings, we use the (a)   operator.

34.

Which function should be used to round a floating point number?

a)

a) round()

b)

b) int()

c)

c) str()

d)

d) float()

35.

True or False: In Python, you can assign a single value to multiple variables simultaneously.

a)

True

b)

False

36.

Given x = 4.56, which function will produce the output 4 when applied to x?

a)

a) str(x)

b)

b) float(x)

c)

c) round(x)

d)

d) int(x)

37.

What will print("Hello", _______) output? print("Hello", _______) will output Hello World.

a)

"World"

b)

"World"

38.

Python allows you to print different data types by separating them with a + operator.

a)

True

b)

False

39.

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

a)

a) _data

b)

b) 1data

c)

c) data1

d)

d) data_var

40.

Given x = "5", which of the following will produce the value 10?

a)

a) x + 5

b)

b) int(x) + 5

c)

c) x + str(5)

d)

d) float(x) + 5

41.

True or False: In Python, strings are a data type.

a)

True

b)

False

42.

Which of the following is the correct way to print a backslash in Python?

a)

a) print("\\")

b)

b) print("\")

c)

c) print("\\\\")

d)

d) print("/")

43.

Given the variable food = "pizza", what will print(food[1:4]) output?

a)

a) piz

b)

b) zza

c)

c) izz

d)

d) pizza

44.

Which of the following is the correct way to print the percentage symbol in Python?

a)

a) print("%")

b)

b) print("\%")

c)

c) print("%%")

d)

d) print("%s")

45.

True or False: The following statement is a valid way to print multiple variables: print("The colors are", color1, "and", color2).

a)

True

b)

False

46.

Fill in the blank: The (a)   function is used to get the number of items in a list or the number of characters in a string.

47.

Which of the following will print the result of 7 divided by 3 rounded to 2 decimal places?

a)

a) print(round(7/3, 2))

b)

b) print(7//3)

c)

c) print(round(7/3))

d)

d) print(float(7/3))

48.

True or False: Variable names in Python can start with a number.

a)

True

b)

False