Log in
Sign up for FREE
arrow_back
Library

Unit 7 Pretest - Selection and Logical Expressions

star
star
star
star
star
Last updated 5 months ago
25 questions
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Required
1
Question 1
1.

Question 2
2.

Question 3
3.

Question 4
4.

Question 5
5.

Question 6
6.

Question 7
7.

Question 8
8.

Question 9
9.

Question 10
10.

Question 11
11.

Question 12
12.

Question 13
13.

Question 14
14.

Question 15
15.

Question 16
16.

Question 17
17.

Question 18
18.

Question 19
19.

Question 20
20.

Question 21
21.

Question 22
22.

Question 23
23.

Question 24
24.

Question 25
25.

What will this program output?

A
Nothing
B
What will this program output?

Low
High
Error message
High Low
Consider this code: age = 16 if age >= 18: print("Adult") else: print("Minor") Why does the program print "Minor" instead of "Adult"?
The if statement is written incorrectly
The program has a syntax error
The else statement overrides the if statement
In a flowchart, which shape represents a decision point where the program must choose between different paths?
Rectangle
Instructions for user input
Output commands to display on screen
A calculation or mathematical operation
Which flowchart structure best represents this logic: "If the temperature is above 75, display 'Hot.' Otherwise, display 'Cool.'"?
A decision diamond with two different paths based on the condition
A straight sequence with no branching
Two separate start points leading to different programs
A loop that repeats the temperature check
What is the result of evaluating the condition: 5 >= 5?
True
Error
False
None
Why must the condition inside an if statement evaluate to either True or False?
Because False conditions cause errors
Because Python requires all statements to be boolean
Because True and False are the only words Python recognizes
What is the primary purpose of an else statement in a program?
To repeat code multiple times
To stop a program from running
To check multiple conditions at the same time
To handle all remaining cases when previous conditions are False
B
A
C
You need to write a program that assigns letter grades based on test scores: A for 90+, B for 80-89, C for 70-79, D for 60-69, and F for below 60. Which control structure is best suited for this task?
An if/else structure
A single if statement
An if/elif/else structure
A while loop
In an if/elif/else structure, how many code blocks can actually execute when the program runs?
As many as there are elif statements
Two or three depending on the conditions
All of them
Only one
Consider this scenario: A program needs to check if a number is positive, negative, or zero. Why would if/elif/else be better than using three separate if statements?
It allows all conditions to be checked simultaneously
It uses less memory
It runs faster
It prevents unnecessary checks once a condition is found to be True
Medium and Low
Medium
Low
Very High
If you want to check whether a student's grade is between 80 and 90 (inclusive), which condition would work?
grade == 80 or grade == 90
grade >= 80 and grade <= 90
grade > 80 and grade < 90
grade between 80 and 90
What is the key difference between how an if/else structure and an if/elif/else structure handle multiple conditions?
if/else can only handle two cases while if/elif/else can handle many
if/elif/else stops checking after the first True condition, while if/else always checks both
They work exactly the same way
if/else is faster than if/elif/else
Hot
Cold
Cool
Comfortable
Consider this code: password = "secret123" if password == "secret123": print("Access Granted") else: print("Access Denied") Why is the == operator used instead of = in the condition?
Because the password needs to be assigned a value
Because == is faster than =
Because = is used for assignment and == is used for comparison