Quiz

Logical expressions - questions

What are all conditions equal to not (7 <= h and h <11)?

h < 7 and 11 <= h

h < 7 or 11 <= h

not(7 <= h) or not(h < 11)

h <= 7 or 11 < h

The state government is offering assistance to build a sports center. Settlements with up to 10,000 residents are eligible to apply, as well as settlements with more than 10,000 residents and an average income of up to 2000. Which of the conditions correctly checks whether a settlement can apply?

(population <= 10000) or (population > 10000 and income <= 2000)

population <= 10000 or income <= 2000

population <= 10000 and income <= 2000

(income <= 2000) or (income > 2000 and population <= 10000)

Logical expression - tasks

Task - numbers in order:

Write a program that takes integers a, b, c and answers the question whether these numbers are given in order from smallest to largest.

Task - middle number:

Write a program that takes integers a, b, c and answers the question whether b is medium in size.

Task - watching the dog:

Anna and Mark live together and have a dog named Bobby. The two are scheduled to travel the same month, Anna from day a1 to a2, and Mark from day m1 to m2. They both leave in the morning and return in the evening. Since they don’t want to leave Bobby alone, they wonder if their trips overlap.

Write a program that takes integers a1, a2, m1 and m2, and answers the question of whether Anna’s and Mark’s travels overlap.

Hint: trips overlap if Mark leaves before Ana returns (the day of Mark’s departure is less than or equal to the day of Ana’s return) or vice versa - if Ana leaves before Mark returns.