wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

S3 Python to Arrays

Total questions: 59

Worksheet time: 30mins

Name
Class
Date
1.

Why is it important to add comments to code?

a)

To make the code run faster

b)

To change the functionality of the code

c)

To improve the readability of code

d)

To increase the number of lines of code

2.

What can happen to programs as they grow and expand?

a)

They can become less complicated to read

b)

They can become shorter

c)

They can become more complicated to read

d)

They can require fewer comments

3.

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

4.

What should multi-line comments contain?

a)

Only the name of the program

b)

Only the date and description of what the program will do

c)

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

d)

Random notes and reminders

5.

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

a)

With a single quotation mark

b)

With a hash symbol (#)

c)

With three quotation marks

d)

With a slash and asterisk (/* */)

6.

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

a)

//

b)

/*

c)

#

d)

7.

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

8.

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

9.

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 to store a value used within a program

c)

C. A type of function that performs operations on data

d)

D. A label for a fixed memory address

10.

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

a)

Yes

b)

No

11.

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 memory location

12.

How many particular types of data can a variable store when created?

a)

A. Multiple types, depending on the program's requirements

b)

B. Only one particular type of data

c)

C. As many as the memory allows

d)

D. Two types, if they are related

13.

What data type would you use to represent whole numbers in programming?

a)

Float

b)

String

c)

Boolean

d)

Integer

14.

Which data type is used to represent decimal or floating point numbers?

a)

Char

b)

Boolean

c)

Integer

d)

Float

15.

What is the data type used to represent individual letters and symbols?

a)

String

b)

Boolean

c)

Char

d)

Integer

16.

If you want to store a sequence of characters, which data type should you choose?

a)

Boolean

b)

Char

c)

Integer

d)

String

17.

What data type can only have the values True or False?

a)

String

b)

Boolean

c)

Float

d)

Integer

18.

What must a variable name begin with in Python?

a)

A number

b)

A special character other than underscore

c)

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

d)

Any character is acceptable

19.

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

a)

Only letters (a-z, A-Z)

b)

Only numbers

c)

Letters, numbers or underscore

d)

Any special characters

20.

Are Python variable names case sensitive?

a)

No, they are not case sensitive

b)

Yes, they are case sensitive

c)

Only the first character is case sensitive

d)

Case sensitivity depends on the Python version

21.

Can reserved words in Python be used as variable names?

a)

Yes, you can use reserved words as variable names

b)

No, you cannot use reserved words as variable names

c)

Only if they are written in uppercase

d)

Reserved words can be used if prefixed with an underscore

22.

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

a)

Because 'sn' is more meaningful

b)

Because 'student_no' is shorter and saves space

c)

Because 'student_no' is more meaningful

d)

Because 'sn' is too long

23.

Which of the following variable names is NOT recommended based on the best practices for naming variables?

a)

student_no

b)

age_in_years

c)

length_in_meters

d)

roll_no_of_a_student

24.

What is important to maintain when naming variables?

a)

The complexity of the variable name

b)

The length of the variable name

c)

The uniqueness of each variable name

d)

The number of underscores in the variable name

25.

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

a)

Inconsistent to avoid confusion

b)

Consistent to avoid confusion

c)

Creative to make the names interesting

d)

Complex to show advanced knowledge

26.

Why is it recommended to include units in variable names?

a)

To make the names longer

b)

To avoid confusion

c)

To comply with programming language standards

d)

To make the names more complex

27.

According to best practices, where should you declare all the variables you plan 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)

Outside of your program file

28.

What should each variable in a program be given?

a)

A random identifier and any variable type

b)

A useful identifier and a specific variable type

c)

The same identifier and variable type

d)

No identifier until the program is complete

29.

What is another term for converting a variable type?

a)

Type conversion

b)

Type casting

c)

Type changing

d)

Type modification

30.

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

a)

To make the program run faster

b)

To correct syntax errors

c)

To match the data type expected by a function

d)

To convert user input from a string to a numeric type

31.

What is the default data type when a user enters a number from the keyboard, according to the image?

a)

int

b)

float

c)

string

d)

double

32.

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

a)

str()

b)

int()

c)

float()

d)

input()

33.

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

a)

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

b)

number = 5

c)

newNumber = float(number)

d)

newString = str(number)

34.

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

a)

number = int("16")

b)

newNumber = float(16)

c)

print(number)

d)

newString = str(number)

35.

Which symbol is used for addition?

a)

*

b)

+

c)

/

d)

=

36.

What symbol represents subtraction?

a)

+

b)

*

c)

-

d)

=

37.

Which symbol stands for division?

a)

-

b)

+

c)

=

d)

/

38.

What is the symbol for multiplication?

a)

=

b)

/

c)

+

d)

*

39.

What symbol is used for assignment, for example, assigning a value to a variable?

a)

+

b)

-

c)

*

d)

=

40.

Why is it good practice to identify the inputs, process, and outputs before coding a program on the computer?

a)

To make the program run faster

b)

To reduce the complexity of the user interface

c)

To organize the program structure before implementation

d)

To increase the size of the program

41.

What do IF statements allow a program to do?

a)

Repeat a set of instructions

b)

Make a decision based on certain conditions

c)

Define a function

d)

Store data

42.

What must all IF statements have?

a)

A loop

b)

A variable

c)

A condition that can be True or False

d)

An array

43.

IF statements can be based on which of the following?

a)

Only user input

b)

Only a variable changing value

c)

Both user input and a variable changing value

d)

Neither user input nor a variable changing value

44.

What does the operator "==" represent?

a)

Greater than

b)

Less than

c)

Equals to

d)

Not equal to

45.

Which operator is used to check if two values are not equal?

a)

>

b)

<=

c)

==

d)

!=

46.

What is the meaning of the "<=" operator?

a)

Greater than

b)

Less than or equal to

c)

Equals to

d)

Not equal to

47.

How many equals signs (=) should be used when you want to change the value of a variable?

a)

Zero

b)

One

c)

Two

d)

Three

48.

How many equals signs (=) are needed when you want to compare the value of a variable?

a)

Zero

b)

One

c)

Two

d)

Three

49.

When should a line of code be indented?

a)

All code should be indented

b)

When it is contained within a construct

c)

When it is a comment

d)

When it is the last line of code

50.

What is the effect of indenting multiple lines of code?

a)

It causes a syntax error

b)

It runs those lines of code when that branch is followed

c)

It comments out those lines of code

d)

It has no effect

51.

What is Simple Selection?

a)

When there are two or more conditions

b)

When there is only one condition

c)

When the conditions are linked using AND or OR

d)

When multiple IF statements are combined

52.

What is Complex Selection?

a)

When there is only one condition

b)

When multiple IF statements are combined

c)

When there are two or more conditions

d)

When the conditions cannot be linked

53.

How can the conditions in a Complex Selection be linked?

a)

Using NOT only

b)

Using AND only

c)

Using XOR only

d)

Using either AND or OR

54.

What does Multiple Selection allow the programmer to do?

a)

Combine three or more IF Statements together

b)

Combine two or more IF Statements together

c)

Create a long list of separate IF Statements

d)

Use only one condition in IF Statements

55.

Why is Multiple Selection more efficient?

a)

It requires more code

b)

It is easier to read

c)

It allows for more conditions

d)

It avoids having a long list of separate IF Statements

56.

Why is a multiple IF statement considered more efficient than using separate IF statements?

a)

It uses more of the processor's resources

b)

It is easier to write

c)

It uses less of the processor's resources

d)

It can handle more conditions

57.

What should programmers strive for when writing code according to the learning material?

a)

To make their programs as complicated as possible

b)

To use as many IF statements as possible

c)

To make their programs as efficient as possible

d)

To use separate IF statements for each condition

58.

Match the following

a)

Integer

1.

7

b)

String

2.

Hello

c)

Float

3.

3.14

d)

Boolean

4.

True

e)

Char

5.

T

59.

An (a)   uses indices to access the data stored in it

Choose from the below words
Array
String
Integer
Boolean