☰ Contents · Computing

Text and logical functions

Lessons 9–10 · 2 lessons · N. I. Taylaqov (general editor), A. B. Akhmedov, M. D. Pardayeva, A. A. Abdug‘aniyev, U. M. Mirsanov. Informatics and Information Technologies, Grade 10, 1st edition. “Extremum-Press”, Tashkent, 2017
10

Logical functions

Textbook: pp. 26–28
GoalPerforms condition-based calculations with IF, AND and OR and writes nested IF.
New words
IF: gives one value if the condition is true and another if it is false · IF funksiyasiAND: true only when all its conditions are true · AND funksiyasiOR: true when at least one condition is true · OR funksiyasinested IF: an IF placed in the true or false part of another IF · ichma-ich IF
Explanation

Some calculations depend on a condition: if the condition is met one result should appear, otherwise another. For this IF(condition, value_if_true, value_if_false) is used. A condition is written with comparison signs: =, <>, <, >, <=, >=. To combine several conditions, AND(c1, c2, …) gives TRUE when all are true, OR(c1, c2, …) gives TRUE when at least one is true, and NOT(c) reverses a condition. With more than two outcomes another IF is written inside the IF: the conditions are checked starting from the strictest. In newer Excel the IFS function shortens such a chain, but nested IF works in every version. Text results are written in quotation marks.

Worked examples
A grading scale: =IF(B2>=90,5,IF(B2>=75,4,IF(B2>=60,3,2))). If B2 = 82, the first condition is false, the second (82 ≥ 75) is true, so the result is 4. B2 = 90 gives 5 and B2 = 59 gives 2.
Two exams: =IF(AND(B2>=60,C2>=60),"qabul","rad"). If B2 = 72 and C2 = 58, the second condition is false, AND is false and the result is “rad”. With OR, =IF(OR(B2>=60,C2>=60),"qabul","rad") gives “qabul”.
Class activity

“Line up by condition”: students stand up if they meet the condition on a card (for example, “taller than 165 AND the name starts with A”); the class sees the difference between AND and OR in action.

Practice
1
What does =IF(AND(7>3,2>4),"A","B") give?
2
In the grading scale above, what is the result for B2 = 82?
3
A seller gets a 7% bonus if sales are at least 5 000 000 so‘m, otherwise 3%. What is the bonus on sales of 8 000 000 so‘m?
4
Why are the conditions in a nested IF written starting from the strictest?