Twa kɔ nsɛm atitiriw so
Log in
Sign up for FREE
arrow_back
Laabri

Unit 7 Pretest - Selection and Logical Expressions

star
star
star
star
star
Last updated 7 months ago
25 Nsɛmmisa
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Ɛhia
1
Asemmisa {{asɛmmisaAhyɛnsode}}
1.

Flow charts – Clayton CafieroFlowchart Description

  1. Start

  2. Input a number

  3. Is the number greater than 0?

    • If Yes, display "Positive"

    • If No, go to the next decision

  4. Is the number less than 0?

    • If Yes, display "Negative"

    • If No, display "Zero"

  5. End

Question: If the user enters 0, what will the program display?

Asemmisa {{asɛmmisaAhyɛnsode}}
2.

What will this program output?

Asemmisa {{asɛmmisaAhyɛnsode}}
3.

What will this program output?

Asemmisa {{asɛmmisaAhyɛnsode}}
4.

Consider this code: age = 16 if age >= 18: print("Adult") else: print("Minor") Why does the program print "Minor" instead of "Adult"?

Asemmisa {{asɛmmisaAhyɛnsode}}
5.

In a flowchart, which shape represents a decision point where the program must choose between different paths?

Asemmisa {{asɛmmisaAhyɛnsode}}
6.

What does a decision diamond in a flowchart typically contain?

Asemmisa {{asɛmmisaAhyɛnsode}}
7.

Which flowchart structure best represents this logic: "If the temperature is above 75, display 'Hot.' Otherwise, display 'Cool.'"?

Asemmisa {{asɛmmisaAhyɛnsode}}
8.

What is the result of evaluating the condition: 5 >= 5?

Asemmisa {{asɛmmisaAhyɛnsode}}
9.

Why must the condition inside an if statement evaluate to either True or False?

Asemmisa {{asɛmmisaAhyɛnsode}}
10.

What is the primary purpose of an else statement in a program?

Asemmisa {{asɛmmisaAhyɛnsode}}
11.

What will this program print?


score = 85
if score >= 90:
print("A")
elif score >= 80:
print("B")
else:
print("C")

Asemmisa {{asɛmmisaAhyɛnsode}}
12.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
13.

In an if/elif/else structure, how many code blocks can actually execute when the program runs?

Asemmisa {{asɛmmisaAhyɛnsode}}
14.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
15.

What will this program output?

num = 10 if num > 5: if num > 15: print("Very High") else: print("Medium") else:

print("Low")

Asemmisa {{asɛmmisaAhyɛnsode}}
16.

If you want to check whether a student's grade is between 80 and 90 (inclusive), which condition would work?

Asemmisa {{asɛmmisaAhyɛnsode}}
17.

What is the key difference between how an if/else structure and an if/elif/else structure handle multiple conditions?

Asemmisa {{asɛmmisaAhyɛnsode}}
18.

What will this program output?

temp = 72 if temp > 80: print("Hot") elif temp > 60: print("Comfortable") elif temp > 40: print("Cool") else:

print("Cold")

Asemmisa {{asɛmmisaAhyɛnsode}}
19.

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?

Asemmisa {{asɛmmisaAhyɛnsode}}
20.

Which condition will be True only if both comparisons are True?

Asemmisa {{asɛmmisaAhyɛnsode}}
21.

What does the or operator do?

Asemmisa {{asɛmmisaAhyɛnsode}}
22.

What is the result of this expression?

(5 > 3) and (2 > 4)

Asemmisa {{asɛmmisaAhyɛnsode}}
23.

What does the not operator do?

Asemmisa {{asɛmmisaAhyɛnsode}}
24.

What is the result of this expression?

not (4 < 6)

Asemmisa {{asɛmmisaAhyɛnsode}}
25.

What is the result of this expression?

(10 >= 10) and (5 != 3)