Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

S3 Code Comments & Variables

Total questions: 1

Worksheet time: 33mins

Name
Class
Date
1-62.
1.

Why is it important to add comments to code?

a)

To make the code run faster

b)

To add more lines of code

c)

To improve the readability of code

d)

To change the functionality of the code

2.

What can happen as programs grow and expand?

a)

They can become easier to read

b)

They require fewer comments

c)

They can become complicated to read

d)

They become shorter

3.

What is the purpose of comments in code?

a)

To cause errors in the program

b)

To be executed as part of the program

c)

To explain what the program is doing and how it is doing it

d)

To change the flow of the program

4.

Who benefits from comments in the code?

a)

The computer

b)

The programmer and others reading the code

c)

External devices interacting with the code

d)

The program's execution speed

5.

What is NOT a function of comments in code?

a)

Ignored by the computer

b)

Highlights important sections of code

c)

Can remind the programmer of how their code works

d)

Increases the execution speed of the program

6.

Where is it considered good practice to insert multi-line comments in a program?

a)

At the bottom of the program

b)

In the middle of the program

c)

At the top of the program

d)

Outside the program file

7.

What information should multi-line comments contain?

a)

Only the name of the program

b)

Only the author's name and date

c)

The name of the program, author, date, and description of what the program will do

d)

Random notes and reminders

8.

How are multi-line comments in a program typically started and ended?

a)

With a single quotation mark

b)

With a hash symbol (#)

c)

With a double slash (//)

d)

With three quotation marks

9.

What symbol is used to add single line comments in code?

a)

//

b)

/*

c)

#

10.

What is the purpose of using single line comments in code?

a)

To change the functionality of the code

b)

To compile the code faster

c)

To explain certain aspects of the code

d)

To create a new variable

11.

Single line comments are also used to:

a)

Execute a specific line of code

b)

Highlight different sections

c)

Import external libraries

d)

Define functions

12.

What is a variable in the context of programming?

a)

A. A constant value that does not change throughout the program

b)

B. A storage location reserved in memory that stores a value used within a program

c)

C. A function that performs a specific task within a program

d)

D. A type of programming language

13.

Can a variable's value change during the execution of a program?

a)

No, it remains constant

b)

Yes, but only at the beginning

c)

Yes, it can change throughout the process of the program

d)

No, it can only change when the program ends

14.

What should all variables be given to describe their contents?

a)

A. A unique number and color code

b)

B. A data type and suitable identifier

c)

C. A complex algorithm

d)

D. A fixed position in the memory

15.

Are variables able to store multiple types of data at once?

a)

A. Yes, they can store as many types as needed

b)

B. No, they are only able to store one particular type of data

c)

C. Yes, but only two types of data simultaneously

d)

D. No, they cannot store any data

16.

What data type would you use to represent whole numbers?

a)

Float

b)

String

c)

Integer

d)

Boolean

17.

Which data type is used to represent individual letters and symbols?

a)

Boolean

b)

Char

c)

Integer

d)

Float

18.

If you need to store a decimal number, which data type should you choose?

a)

Char

b)

Boolean

c)

String

d)

Float

19.

What is a String data type used to represent?

a)

True or False values

b)

Collection of characters

c)

Whole numbers

d)

Decimal numbers

20.

What must a variable name begin with in Python?

a)

A) A number

b)

B) A special character other than underscore

c)

C) A letter (a-z, A-Z) or an underscore

d)

D) Any character is acceptable

21.

Which of the following is true about the characters that can be used in a Python variable name after the first character?

a)

A) Only letters and numbers

b)

B) Only letters, numbers, and special characters

c)

C) Only letters, numbers, or underscore

d)

D) Any characters without restriction

22.

Are variable names in Python case sensitive?

a)

A) No, they are not case sensitive

b)

B) Yes, they are case sensitive

c)

C) Only the first character is case sensitive

d)

D) Case sensitivity depends on the version of Python

23.

Can reserved words in Python be used as variable names?

a)

A) Yes, but it is not recommended

b)

B) Yes, without any restrictions

c)

C) No, because Python uses them for other things

d)

D) Only if they are written in uppercase

24.

When naming variables, why is 'student_no' considered better than 'sn'?

a)

Because 'sn' is more meaningful

b)

Because 'student_no' is shorter and easier to type

c)

Because 'student_no' is more meaningful

d)

Because 'sn' maintains the length of a variable name

25.

Which of the following variable names is too long according to best practices?

a)

student_no

b)

age_in_years

c)

length_in_meters

d)

roll_no_of_a_student

26.

What is important to include in variable names to avoid confusion?

a)

The type of programming language used

b)

The color of the variable name

c)

Units of measurement

d)

The name of the programmer

27.

According to best practices, how should you be when naming variables?

a)

Inconsistent

b)

Consistent

c)

Complicated

d)

Vague

28.

According to best practices, where should you declare all the variables you are planning to use in your program?

a)

At the bottom of your program

b)

Just under the multi-line comments at the top of your program

c)

In the middle of your program

d)

After every function

29.

What must you type first when declaring a variable?

a)

The value you want to assign to the variable

b)

The identifier you have chosen along with the variable type

c)

A comment explaining the variable

d)

The variable type only

30.

What is a good practice when determining how many variables a program needs?

a)

Guess the number of variables needed

b)

Look at the program specification and underline the information that needs to be stored

c)

Always use a fixed number of variables for every program

d)

Avoid using variables to make the program simpler

31.

How many variables are needed for a program that calculates the area of a rectangle and displays it to the user?

a)

1

b)

2

c)

3

d)

4

32.

What should each variable in a program be given?

a)

A random identifier and any data type

b)

The same identifier and data type

c)

A useful identifier and an appropriate variable type

d)

No identifier until the program is completed

33.

What are the three main components involved in all programs according to the learning material?

a)

Input, Storage, Output

b)

Input, Processing, Output

c)

Input, Processing, Storage

d)

Storage, Processing, Output

34.

When writing basic programs in Python, what is necessary to know?

a)

How to take in information from the user, how to store that information, and how to display information to the user

b)

How to take in information from the user, how to manipulate that information, and how to display information to the user

c)

How to manipulate information from the user, how to store that information, and how to process information to the user

d)

How to process information from the user, how to manipulate that information, and how to store information for the user

35.

Which Python function is used to get input from the user?

a)

print()

b)

type()

c)

input()

d)

int()

36.

How is the input for the 'age' variable processed in the code?

a)

It is taken as a string and then converted to an integer.

b)

It is directly taken as an integer.

c)

It is taken as a float and then converted to an integer.

d)

It is not processed and remains a string.

37.

What is the output of the code snippet: print("Hello World!")?

a)

Hello World!

b)

Hello + World!

c)

"Hello World!"

d)

print Hello World!

38.

What does the '+' character do in the context of the code snippet: print("Hello " + name + " it is nice to meet you.")?

a)

Adds a numerical value to the name

b)

Subtracts the string "name" from "Hello "

c)

Concatenates the strings "Hello ", name, and " it is nice to meet you."

d)

Causes a syntax error

39.

According to the comment in the code, what must be done before concatenating a number to a string?

a)

The number must be divided by a string

b)

The number must be converted to a string

c)

The number must be multiplied by a string

d)

The number can be concatenated without any conversion

40.

What is another term for changing the data type of a variable in programming?

a)

Type conversion

b)

Variable morphing

c)

Data typing

d)

Type casting

41.

Why might it be necessary to change the data type of a variable in a program?

a)

To increase the speed of the program

b)

To reduce the memory usage

c)

To match the data type expected by a function or operation

d)

To make the code look cleaner

42.

When a user enters a number from the keyboard, what is the default data type of that input in many programming environments?

a)

Integer

b)

Float

c)

String

d)

Character

43.

What data types might you want to convert keyboard input into for processing in a program?

a)

String and Character

b)

Integer and Double

c)

Integer and Float

d)

Boolean and Array

44.

What Python function is used to convert a string input to an integer?

a)

str()

b)

int()

c)

float()

d)

input()

45.

Which line of code will output a float number after conversion?

a)

number = int(input("Please enter a number using the keyboard: "))

b)

number = float(input("Please enter a number using the keyboard: "))

c)

newNumber = float(number)

d)

newString = str(number)

46.

If the variable 'number' is set to 16, what will be the type of 'newString' after the following operation: newString = str(number)?

a)

Integer

b)

Float

c)

String

d)

List

47.

How often do most programs need to carry out calculations?

a)

At least once

b)

Only for complex operations

c)

Rarely ever

d)

Never

48.

Which symbol is used for addition in the syntax provided?

a)

*

b)

+

c)

/

d)

=

49.

What symbol represents subtraction in the given syntax?

a)

+

b)

*

c)

-

d)

=

50.

Which symbol stands for division in the syntax shown?

a)

+

b)

-

c)

*

d)

/

51.

What is the symbol for multiplication in the syntax used?

a)

+

b)

-

c)

*

d)

/

52.

What symbol is used to denote equals or assignment in the syntax?

a)

+

b)

-

c)

*

d)

=

53.

What does the letter 'B' in BODMAS stand for?

a)

Base

b)

Brackets

c)

Binary

d)

Balance

54.

According to BODMAS, which of the following should be performed first in a calculation?

a)

Addition

b)

Division

c)

Brackets

d)

Subtraction

55.

What does 'DM' in BODMAS represent?

a)

Decimal and Modulus

b)

Division and Multiplication

c)

Diameter and Mean

d)

Distance and Mass

56.

What is the correct order of operations in BODMAS?

a)

Addition, Subtraction, Division, Multiplication, Orders, Brackets

b)

Brackets, Orders, Division, Multiplication, Addition, Subtraction

c)

Division, Multiplication, Addition, Subtraction, Brackets, Orders

d)

Orders, Brackets, Addition, Subtraction, Multiplication, Division

57.

What does the letter 'O' in BODMAS stand for?

a)

Output

b)

Origin

c)

Orders

d)

Opportunity

58.

What is the result of the expression 4 x 3 + 2?

a)

A) 14

b)

B) 20

c)

C) 10

d)

D) 12

59.

What is the result of the expression 4 x (3 + 2)?

a)

A) 14

b)

B) 20

c)

C) 10

d)

D) 12

60.

What should be identified before attempting to code a program on the computer as it becomes more complicated?

a)

Inputs, processes, and outputs

b)

Errors and bugs

c)

Programming language and IDE

d)

User interface design

61.

What is often involved in the process applied to variables in programming?

a)

A calculation or a decision

b)

A loop or an array

c)

A function or a class

d)

A variable declaration or assignment

62.

What is the purpose of identifying variables for output in programming?

a)

To optimize the program's performance

b)

To display the final information to the user

c)

To debug the program

d)

To choose the appropriate data type