NEW
Font size
Worksheets67 Quiz Q2 y7
Total questions: 67
Worksheet time: 34mins
What is the main purpose of using loops in programming?
To perform tasks only once
To repeat tasks many times
To stop tasks from repeating
To make tasks more complicated
Which type of loop is used in Python for counting iterations?
Forever loop
Counter loop
Conditional loop
Infinite loop
What type of loop is represented by "while" in Python?
Forever loop
Counter loop
Conditional loop
Repeat loop
What does the operator "<" mean in Python?
Greater than
Less than
Equal to
Not equal to
Which operator is used to check if two values are equal in Python?
!=
<
==
>
What is the meaning of the operator ">=" in Python?
Less than
Greater than
Less than or equal to
Greater than or equal to
In Scratch, which operator would you use to add two numbers?
-
*
/
+
What is a key advantage of using loops in programming?
They make the code run slower
They require more code to be written
They reduce the chance of errors
They increase the complexity of the code
When should you use a 'for loop' in programming?
When you want to repeat an action an unknown number of times
When you want to repeat an action a specific number of times
When you want to repeat an action until a condition is met
When you want to repeat an action randomly
What is the purpose of a "for" loop in programming?
To execute a block of code a specific number of times
To execute a block of code only once
To execute a block of code indefinitely
To execute a block of code based on a condition
In a "for" loop, what does the "range" function do?
It creates a list of numbers
It checks a condition
It prints a message
It stops the loop
What is the role of indentation in a "for" loop?
It marks the end of the loop
It indicates the start of the loop
It defines the block of code to be repeated
It is used to comment the code
What is the correct syntax to start a "for" loop in Python?
for i in range(number):
for each i in range(number)
for i range(number):
for i in range number:
What is the output of the following code snippet?
1 2 3 4
4 3 2 1
1 3 2 4
2 3 4 5
What does the 'range' function do in programming?
It generates a sequence of numbers starting from 0.
It sorts a list of numbers.
It reverses a list of numbers.
It multiplies a list of numbers by 2.
What does the function range(5) return in Python?
[0, 1, 2, 3, 4]
[1, 2, 3, 4, 5]
[5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5]
If you use range(5, 10) in a loop, what will be the first number printed?
5
6
10
0
What is the output of the following code? for num in range(5): print("Number:", num)
Number: 0, Number: 1, Number: 2, Number: 3, Number: 4
Number: 1, Number: 2, Number: 3, Number: 4, Number: 5
Number: 0, Number: 1, Number: 2, Number: 3
Number: 5, Number: 6, Number: 7, Number: 8, Number: 9
What will be the output of the following code snippet?
This is loop number 2 This is loop number 3 This is loop number 4
This is loop number 3 This is loop number 4 This is loop number 5
This is loop number 1 This is loop number 2 This is loop number 3
This is loop number 2 This is loop number 3 This is loop number 4 This is loop number 5
What is the formula to calculate the average of a set of numbers?
Sum of numbers × number of times
Total ÷ number of times
Total + number of times
Sum of numbers - number of times
If you have the numbers 2 and 2, what is their average?
2
3
4
5
In the given code example, what is the initial value of the variable 'total'?
1
2
0
10
What is the average of the numbers 10 and 20 in the provided code example?
10
15
20
25
What is the purpose of rounding a number?
To increase the number of digits
To make calculations more complex
To get a shorter answer
To make numbers harder to read
In the given code, what is the purpose of the line "birds=int(birds)"?
To convert the input into a string
To convert the input into an integer
To add the input to the total
To print the number of birds
What is the output of the code "print(round(4.6))"?
4.5
4
5
6
Why do we use the "round" function in programming?
To make numbers more complex
To simplify numbers using fewer digits
To increase the number of decimal places
To make numbers less readable
Image of a code snippet calculating the average number of birds
Calculating the average number of birds
Finding the maximum number of birds
Counting the total number of birds
Sorting the number of birds
How many values will the user enter?
1
2
3
4
Change it to calculate the average value of the user input and round the total number.
Use the sum function
Use the round function
Use the average function
Use the multiply function
What is the starting value of x in the given code?
0
1
3
5
How many values will the user enter according to the code?
1
2
3
4
What happens to variable x in each loop iteration?
It is multiplied by the input value.
It is divided by the input value.
It adds each new input value to x.
It subtracts the input value from x.
What does the code calculate after the loop ends?
The sum of the values
The average of the values
The product of the values
The difference of the values
What is the purpose of a conditional loop in programming?
To execute a block of code a fixed number of times
To execute a block of code as long as a condition is true
To execute a block of code only once
To execute a block of code in reverse order
What is an infinite loop?
A loop that runs a fixed number of times
A loop that never starts
A loop that never stops
A loop that runs backwards
In the given code snippet, what is the initial value of the variable 'total'?
1
3
0
10
What should you do to stop a 'while' loop from becoming infinite?
Never change the condition
Change the condition to false at some point
Use a 'for' loop instead
Remove the loop entirely
What is the purpose of asking the user if they want to continue in a loop?
To make the loop run forever
To stop the loop if the user says 'no'
To change the loop to a 'for' loop
To print a message
What is the initial value of 'cupcakes' in the given while loop?
0
1
5
6
How many times will the message "yummy" be printed in the given loop?
3 times
4 times
5 times
6 times
What happens when the value of 'cupcakes' becomes 6 in the loop?
The loop continues
The loop stops
The loop restarts
The loop prints an error
What type of loop is this?
For loop
While loop
Do-while loop
Infinite loop
What comparison operator is used in the header? What is its meaning?
==
!=
<
<
Give an example of an input that will stop the loop.
"yes"
"no"
"continue"
"stop"
Write a code to stop when x is less than 10.
while x < 10:
while x > 10:
if x < 10:
if x > 10:
What is the purpose of the "if" block in the given code?
To repeat actions indefinitely
To make decisions based on conditions
To store data
To create a loop
In the block-based code, what happens when the condition is true?
The program stops
The program plays a sound
The program moves 10 steps
The program waits
What is the role of the "else" block in the code?
To execute code when the condition is false
To repeat the previous action
To end the program
To store a variable
What will the following code print if the weather is 'Sunny'?
Wear sunglasses
Wear a coat
Wear a hat
Wear boots
What is the purpose of the following code snippet?
To check if someone can drive
To check if someone can vote
To check if someone can drink
To check if someone can work
If the weather is cold, what should you wear according to the diagram?
T-shirt
Sweater
Sunglasses
Shorts
What will the following code print?
Nothing
hurray!
Error
10
What is Artificial Intelligence (AI)?
A computer system that thinks and makes decisions like humans.
A type of animal that can talk.
A new kind of smartphone.
A video game character.
What is an example of Artificial Intelligence?
Siri and face recognition.
A bicycle.
A refrigerator.
A pencil.
What is an expert system?
A computer program that thinks like an expert to help people make decisions or find answers.
A type of robot that cleans houses.
A video game console.
A new kind of television.
How does an expert system help people?
By asking questions and providing answers like a smart helper.
By cooking food.
By playing music.
By painting pictures.
What is one advantage of using an Expert System?
It requires constant human supervision.
It helps people find answers quickly.
It forgets information easily.
It is slow and unreliable.
What does bias in a system mean?
The system is always accurate.
The system is fair and balanced.
The system is not fair due to wrong or limited information.
The system is based on complete information.
Which component is NOT part of an Expert System?
Knowledge Base
Inference Engine
Interface
Random Access Memory
What is a decision tree compared to?
A list of items
A map that helps you choose
A book of rules
A set of instructions
Why is it called a "tree" in a decision tree?
Because it grows leaves
Because it branches out
Because it is green
Because it has roots
In a decision tree, what does each question represent?
A leaf
A branch
A root
A trunk
What question does the decision tree start with?
Does the bird have white feather?
Does the bird have a beak?
Does the bird fly?
Does the bird sing?
According to the decision tree, what bird is identified if it does not have white feathers and is not a sparrow?
Crow
Seagull
Sparrow
Parrot
In the example code, what is printed if the animal has 4 legs and barks?
It's a dog!
It's a cat!
It's a bird!
It's a fish!
What does the example code print if the animal does not have wings?
It's a fish!
It's a bird!
It's a dog!
It's a cat!
