160 likes | 409 Views
Conditionals. Belinda Kerchmar 3.1.11. Operators. What are the operators we discussed last time? This time -- Conditional Operators: IF SUMIF COUNTIF. IF in the real world. IF you get 8 hours of sleep THEN you’ll feel fresh in the morning ELSE you’ll feel tired in the morning
E N D
Conditionals Belinda Kerchmar 3.1.11
Operators • What are the operators we discussed last time? • This time-- Conditional Operators: • IF • SUMIF • COUNTIF
IF in the real world... IF you get 8 hours of sleep THEN you’ll feel fresh in the morning ELSE you’ll feel tired in the morning IF you’re a Carolina fan on game day THEN you’ll wear Carolina blue ELSE you will wear whatever you feel like
IF in excel… • IF (logical_test, value_if_true, value_if_false) • Logical test: the thing we’re checking for true or false • Value_if_true: what should happen if our test was true? • Value_if_false: what should happen if our test was false?
Simple IF Example… • Is the number in the cell greater than seven?
More complicated IF example Let’s assign letter grades to the students! 90 - 100 – A 80 - 89 – B 70 - 79 – C 60 - 69 – D <60 – F
COUNTIF in the real world • How many brunettes are in class?
COUNTIF in excel… • COUNTIF(range, criteria) • range – a collection of cells that we’re checking against our criteria • range example: I2:I9 • criteria some logical test for our range • Criteria example: “>=60” • criteria needs to be in quotes
COUNTIF example • How many courses is each student passing? • How many courses did at least one student pass?
SUMIF in excel • SUMIF (range, criteria, sum_range) • This function will add things up, depending on the criteria given. • range – a range of cells • ex. I2:I9 • criteria – the criteria we’re checking against • sum_range – the range of cells to add up
SUMIF example • How much would it cost to buy one of every kind of vegetable? • How much would it cost to buy one of every kind of fruit?
On your own (or in groups) • Buy the grocery item if it is a fruit and if it costs less than $2.50. • Label the grocery items as inexpensive (<$1), medium ($1-$2), or expensive (>$2) • Sum up the even numbers from the list. • Hint: use ISEVEN(someNumber) & ISODD(someNumber) • Sum up the odd numbers from the list