wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Conditional Statements in Programming Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.
What is the primary purpose of a conditional statement in programming?
a)
To define function parameters
b)
To generate random numbers
c)
To create infinite loops
d)
To make decisions based on specific conditions
2.
What is the primary purpose of an if-else statement in programming?
a)
To generate random numbers
b)
To make decisions and execute different code blocks based on conditions
c)
To create infinite loops
d)
To define mathematical equations
3.
In the classroom activity 'Knowing your friends', how would an if-else statement be structured for determining where a student stands?
a)
if student.likesBasketball then stand right else stand left
b)
if student.age == 9 then stand right
c)
if classroom is full then stop
d)
if student.name is valid then move
4.
What happens in an if-else statement when the initial condition is false?
a)
The program repeats the condition
b)
Nothing happens
c)
The code under the 'else' block is executed
d)
The program crashes
5.
In the banana example from the presentation, what determines which animal eats the banana?
a)
The banana's color
b)
Time of day
c)
Random selection
d)
The animal's preference
6.
What coding concept does this lesson primarily focus on?
a)
If-else statements
b)
Function definitions
c)
Arrays
d)
For loops
7.
When writing an if-else statement, what does the computer do when evaluating the condition?
a)
It generates an error
b)
It skips the entire statement
c)
It always executes both code blocks
d)
It decides which block to execute based on whether the condition is true or false
8.
What is a key advantage of using an if-else statement?
a)
It ensures the computer knows what to do in both true and false scenarios
b)
It automatically fixes code errors
c)
It eliminates the need for programming logic
d)
It makes code run faster
9.
In the classroom activity, what type of questions were students asking?
a)
Complex mathematical questions
b)
Yes or no questions
c)
Technical programming queries
d)
Open-ended philosophical questions
10.
What platform were students instructed to use for completing challenges?
a)
Scratch
b)
Python IDLE
c)
CodeMonkey
d)
GitHub
11.
What specific challenges were students asked to complete?
a)
Challenges 1-5
b)
Challenges 200-205
c)
Challenges 50-55
d)
Challenges 116-121
12.
In the classroom activity 'Knowing Your Friends', what happened when a volunteer asked a question and received a 'no' answer?
a)
The volunteer was eliminated from the game
b)
The volunteer stopped asking questions
c)
The volunteer moved to the next friend
d)
The entire class sat down
13.
What programming language was used in the presentation's code examples?
a)
Java
b)
Python
c)
CoffeeScript
d)
JavaScript
14.
Which of the following best describes the basic structure of an 'if' statement?
a)
A condition that determines which action to take
b)
A way to define function parameters
c)
A loop that repeats forever
d)
A method for creating variables
15.
In the presentation's example, what was the context for using conditional statements?
a)
Creating mathematical equations
b)
Generating random colors
c)
Sorting numbers
d)
Dealing with frozen bananas
16.
What does the syntax 'if score > 90' represent in programming?
a)
A mathematical inequality
b)
A conditional statement checking a condition
c)
A function definition
d)
A variable assignment
17.
What was the primary goal of Activity 2 in the presentation?
a)
To complete CodeMonkey challenges 106-116
b)
To learn drawing
c)
To create a new programming language
d)
To design a video game
18.
How do conditionals help in programming?
a)
By making code run slower
b)
By preventing any code execution
c)
By allowing different actions based on different conditions
d)
By eliminating the need for functions
19.
In the first classroom activity, what determined whether a friend would join a volunteer?
a)
The friend's age
b)
The volunteer's mood
c)
Random selection
d)
The answer to a yes or no question
20.
What coding concept was the primary focus of this lesson?
a)
Conditional statements
b)
Functions
c)
Loops
d)
Object-oriented programming