Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming Basics Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is a variable in programming?

a)

A fixed value

b)

A storage location identified by a name

c)

A type of loop

d)

A function that returns a value

2.

Which of the following is NOT a data type?

a)

Integer

b)

String

c)

Float

d)

Loop

3.

What is an example of a String data type?

a)

123

b)

12.34

c)

"Hello, World!"

d)

True

4.

How do you declare an integer variable in Python?

a)

int x = 5

b)

x = 5

c)

declare x as integer = 5

d)

x: int = 5

5.

Which operator is used for addition in programming?

a)

+

b)

&

c)

*

d)

/

6.

What is the output of the following code? print(3 + 2 * 2)

a)

10

b)

7

c)

8

d)

5

7.

Which of the following is a correct way to create a list in Python?

a)

list = (1, 2, 3)

b)

list = [1, 2, 3]

c)

list = {1, 2, 3}

d)

list = 1, 2, 3

8.

What is the purpose of the input() function?

a)

To output data to the console

b)

To read data from the user

c)

To initialize variables

d)

To store data in a file

9.

What data type is returned by the input() function?

a)

Integer

b)

String

c)

Float

d)

Boolean

10.

How can you convert a string to an integer in Python?

a)

int("123")

b)

str(123)

c)

float("123")

d)

convert("123")

11.

What is the result of the following expression: 5 != 5?

a)

True

b)

False

c)

0

d)

1

12.

Which symbol is used for the modulus operation in Python?

a)

/

b)

%

c)

*

d)

+

13.

What does the following code output? print("Hello" + " World")

a)

Hello World

b)

HelloWorld

c)

Hello + World

d)

Error

14.

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

a)

1st_variable

b)

first-variable

c)

first_variable

d)

first variable

15.

What will be the output of the following code? print(10 // 3)

a)

3.33

b)

3

c)

4

d)

3.0

16.

What is the function of the len() function in Python?

a)

To find the length of a string or list

b)

To count the number of variables

c)

To convert data types

d)

To create a new variable

17.

How do you create a dictionary in Python?

a)

dict = { "key": "value" }

b)

dict = [ "key": "value" ]

c)

dict = ( "key", "value" )

d)

dict = < "key": "value" >

18.

Which of the following statements is true about comments in Python?

a)

They are ignored by the interpreter

b)

They start with #

c)

Both A and B

d)

They must be at the end of a line

19.

What will the following code output? x = 5; y = x + 2; print(y)

a)

5

b)

7

c)

2

d)

0

20.

Which statement is used to check a condition in Python?

a)

if

b)

check

c)

condition

d)

evaluate