Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Comments and Variables in Python Programming

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the purpose of comments in Python programming?

a)

Comments in Python programming are used to explain the code logic, make the code more readable, and provide additional information to other developers.

b)

Comments in Python programming are used to store data

c)

Comments in Python programming are used to create loops

d)

Comments in Python programming are used to execute code

2.

How do you denote a single-line comment in Python?

a)

// This is a single-line comment

b)

/* This is a single-line comment */

c)

# This is a single-line comment

d)

''' This is a single-line comment '''

3.

What is the symbol used to start a comment in Python?

a)

!

b)

//

c)

/*

d)

#

4.

Why are comments important in programming?

a)

Comments provide clarity and context to the code.

b)

Comments reveal sensitive information about the code.

c)

Comments are only for experienced programmers and not beginners.

d)

Comments are unnecessary and slow down the code execution.

5.

What are variables in Python?

a)

Variables in Python are identifiers that can hold different types of data such as numbers, strings, lists, etc.

b)

Variables in Python are reserved keywords that cannot be changed

c)

Variables in Python are used to perform mathematical operations only

d)

Variables in Python are not necessary for writing code

6.

How do you declare a variable in Python?

a)

value = variable_name

b)

variable_name : value

c)

variable_name = value =

d)

variable_name = value

7.

What are the rules for naming variables in Python?

a)

Variable names in Python can only contain letters, numbers, and underscores. They cannot start with a number and cannot be a reserved keyword. Variable names are case-sensitive.

b)

Variable names in Python can start with a number

c)

Variable names in Python must be at least 10 characters long

d)

Variable names in Python can contain special characters like @, $, and %

8.

Can variable names start with a number in Python?

a)

No

b)

Yes

c)

Sometimes

d)

Maybe

9.

What is the difference between declaring and initializing a variable?

a)

Declaring a variable is specifying its type and name, while initializing a variable is assigning a value to it.

b)

Declaring a variable is assigning a type to it, while initializing a variable is specifying its value.

c)

Declaring a variable is assigning a value to it, while initializing a variable is specifying its type and name.

d)

Declaring a variable is specifying its value, while initializing a variable is assigning a type to it.

10.

Why is it important to choose meaningful variable names?

a)

Meaningful variable names are only important for beginners

b)

Meaningful variable names increase the file size of the code

c)

Meaningful variable names make the code run faster

d)

Meaningful variable names improve code readability, understandability, and maintainability.