Preskoči na glavni sadržaj
Prijava
Sign up for FREE
arrow_back
Biblioteka

Unit 7 Pretest - Selection and Logical Expressions

star
star
star
star
star
Posljednje ažuriranje 6 months ago
25
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Obavezno
1
Pitanje 1
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?

Pitanje 2
2.

What will this program output?

Pitanje 3
3.

What will this program output?

Pitanje 4
4.

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

Pitanje 5
5.

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

Pitanje 6
6.

What does a decision diamond in a flowchart typically contain?

Pitanje 7
7.

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

Pitanje 8
8.

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

Pitanje 9
9.

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

Pitanje 10
10.

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

Pitanje 11
11.

What will this program print?


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

Pitanje 12
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?

Pitanje 13
13.

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

Pitanje 14
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?

Pitanje 15
15.

What will this program output?

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

print("Low")

Pitanje 16
16.

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

Pitanje 17
17.

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

Pitanje 18
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")

Pitanje 19
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?

Pitanje 20
20.

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

Pitanje 21
21.

What does the or operator do?

Pitanje 22
22.

What is the result of this expression?

(5 > 3) and (2 > 4)

Pitanje 23
23.

What does the not operator do?

Pitanje 24
24.

What is the result of this expression?

not (4 < 6)

Pitanje 25
25.

What is the result of this expression?

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