Font size
WorksheetsS3 Python to Arrays
Total questions: 59
Worksheet time: 30mins
Why is it important to add comments to code?
To make the code run faster
To change the functionality of the code
To improve the readability of code
To increase the number of lines of code
What can happen to programs as they grow and expand?
They can become less complicated to read
They can become shorter
They can become more complicated to read
They can require fewer comments
Where is it considered good practice to insert multi-line comments in a program?
At the bottom of the program
In the middle of the program
At the top of the program
Outside the program file
What should multi-line comments contain?
Only the name of the program
Only the date and description of what the program will do
The name of the program, author, date, and description of what the program will do
Random notes and reminders
How are multi-line comments started and ended in a program?
With a single quotation mark
With a hash symbol (#)
With three quotation marks
With a slash and asterisk (/* */)
What symbol is used to add single line comments in code?
//
/*
#
What is the purpose of using single line comments in code?
To change the functionality of the code
To compile the code faster
To explain certain aspects of the code
To create a new variable
Single line comments are also used to:
Execute a specific line of code
Highlight different sections
Import external libraries
Define functions
What is a variable in the context of programming?
A. A constant value that does not change throughout the program
B. A storage location reserved in memory to store a value used within a program
C. A type of function that performs operations on data
D. A label for a fixed memory address
Can a variable's value change during the execution of a program?
Yes
No
What should all variables be given to describe their contents?
A. A unique number and color code
B. A data type and suitable identifier
C. A complex algorithm
D. A fixed memory location
How many particular types of data can a variable store when created?
A. Multiple types, depending on the program's requirements
B. Only one particular type of data
C. As many as the memory allows
D. Two types, if they are related
What data type would you use to represent whole numbers in programming?
Float
String
Boolean
Integer
Which data type is used to represent decimal or floating point numbers?
Char
Boolean
Integer
Float
What is the data type used to represent individual letters and symbols?
String
Boolean
Char
Integer
If you want to store a sequence of characters, which data type should you choose?
Boolean
Char
Integer
String
What data type can only have the values True or False?
String
Boolean
Float
Integer
What must a variable name begin with in Python?
A number
A special character other than underscore
A letter (a-z, A-Z) or an underscore
Any character is acceptable
Which of the following is true about the characters that can be used in a Python variable name after the first character?
Only letters (a-z, A-Z)
Only numbers
Letters, numbers or underscore
Any special characters
Are Python variable names case sensitive?
No, they are not case sensitive
Yes, they are case sensitive
Only the first character is case sensitive
Case sensitivity depends on the Python version
Can reserved words in Python be used as variable names?
Yes, you can use reserved words as variable names
No, you cannot use reserved words as variable names
Only if they are written in uppercase
Reserved words can be used if prefixed with an underscore
When naming variables, why is 'student_no' considered better than 'sn'?
Because 'sn' is more meaningful
Because 'student_no' is shorter and saves space
Because 'student_no' is more meaningful
Because 'sn' is too long
Which of the following variable names is NOT recommended based on the best practices for naming variables?
student_no
age_in_years
length_in_meters
roll_no_of_a_student
What is important to maintain when naming variables?
The complexity of the variable name
The length of the variable name
The uniqueness of each variable name
The number of underscores in the variable name
According to best practices, how should you be when naming variables?
Inconsistent to avoid confusion
Consistent to avoid confusion
Creative to make the names interesting
Complex to show advanced knowledge
Why is it recommended to include units in variable names?
To make the names longer
To avoid confusion
To comply with programming language standards
To make the names more complex
According to best practices, where should you declare all the variables you plan to use in your program?
At the bottom of your program
Just under the multi-line comments at the top of your program
In the middle of your program
Outside of your program file
What should each variable in a program be given?
A random identifier and any variable type
A useful identifier and a specific variable type
The same identifier and variable type
No identifier until the program is complete
What is another term for converting a variable type?
Type conversion
Type casting
Type changing
Type modification
Why might it be necessary to change the data type of a variable in a program?
To make the program run faster
To correct syntax errors
To match the data type expected by a function
To convert user input from a string to a numeric type
What is the default data type when a user enters a number from the keyboard, according to the image?
int
float
string
double
What Python function is used to convert a string input to an integer?
str()
int()
float()
input()
Which line of code will output a float number after conversion?
number = int(input("Please enter a number using the keyboard: "))
number = 5
newNumber = float(number)
newString = str(number)
How do you convert an integer to a string in Python?
number = int("16")
newNumber = float(16)
print(number)
newString = str(number)
Which symbol is used for addition?
*
+
/
=
What symbol represents subtraction?
+
*
-
=
Which symbol stands for division?
-
+
=
/
What is the symbol for multiplication?
=
/
+
*
What symbol is used for assignment, for example, assigning a value to a variable?
+
-
*
=
Why is it good practice to identify the inputs, process, and outputs before coding a program on the computer?
To make the program run faster
To reduce the complexity of the user interface
To organize the program structure before implementation
To increase the size of the program
What do IF statements allow a program to do?
Repeat a set of instructions
Make a decision based on certain conditions
Define a function
Store data
What must all IF statements have?
A loop
A variable
A condition that can be True or False
An array
IF statements can be based on which of the following?
Only user input
Only a variable changing value
Both user input and a variable changing value
Neither user input nor a variable changing value
What does the operator "==" represent?
Greater than
Less than
Equals to
Not equal to
Which operator is used to check if two values are not equal?
>
<=
==
!=
What is the meaning of the "<=" operator?
Greater than
Less than or equal to
Equals to
Not equal to
How many equals signs (=) should be used when you want to change the value of a variable?
Zero
One
Two
Three
How many equals signs (=) are needed when you want to compare the value of a variable?
Zero
One
Two
Three
When should a line of code be indented?
All code should be indented
When it is contained within a construct
When it is a comment
When it is the last line of code
What is the effect of indenting multiple lines of code?
It causes a syntax error
It runs those lines of code when that branch is followed
It comments out those lines of code
It has no effect
What is Simple Selection?
When there are two or more conditions
When there is only one condition
When the conditions are linked using AND or OR
When multiple IF statements are combined
What is Complex Selection?
When there is only one condition
When multiple IF statements are combined
When there are two or more conditions
When the conditions cannot be linked
How can the conditions in a Complex Selection be linked?
Using NOT only
Using AND only
Using XOR only
Using either AND or OR
What does Multiple Selection allow the programmer to do?
Combine three or more IF Statements together
Combine two or more IF Statements together
Create a long list of separate IF Statements
Use only one condition in IF Statements
Why is Multiple Selection more efficient?
It requires more code
It is easier to read
It allows for more conditions
It avoids having a long list of separate IF Statements
Why is a multiple IF statement considered more efficient than using separate IF statements?
It uses more of the processor's resources
It is easier to write
It uses less of the processor's resources
It can handle more conditions
What should programmers strive for when writing code according to the learning material?
To make their programs as complicated as possible
To use as many IF statements as possible
To make their programs as efficient as possible
To use separate IF statements for each condition
Match the following
Integer
7
String
Hello
Float
3.14
Boolean
True
Char
T
An (a) uses indices to access the data stored in it
