Start with a prediction, then test it in a coding game. The first three rounds can be played right here. Give yourself one point for each correct prediction before opening the answer.

Round 1

A loop adds the seats in two rooms. What total will it print?

total = 0
for seats in [3, 5]:
    total += seats
print(total)
Reveal the answer

8. After the first room the total is 3; the second adds 5.

Round 2

Will the last seat be offered?

const seats = 1;
console.log(seats > 1 ? "Open" : "Full");
Reveal the answer

Full. The expression 1 > 1 is false. Use seats > 0 to offer the last seat.

Round 3

A bookings table holds seat counts 2, 4 and 4. How many rows match?

SELECT COUNT(*) FROM bookings WHERE seats >= 4;
Reveal the answer

2. Both rows containing 4 meet the condition. COUNT(*) counts matching rows.

Play the coding games

Choose a challenge in the practice area or open the full-screen DevStudyHub games hub.

Choose a language

logoblog

No comments:

Post a Comment

Please do not enter any spam link in the comment box.