Skip to main content

Featured

Space Explorers Book 7: Answers and Explanations

Memunic Space Explorers › Book 7: Memoon and the Search for Another Home › Answers and Explanations Answers and Explanations Habitable means life could live there; inhabited means life does live there. A world can be habitable and empty, as an unoccupied flat has a roof and water but nobody in it. The Moon has almost no air, so water would boil or freeze, and its gravity is only about one-sixth of Earth’s, too weak to keep air. Accept also: no greenhouse blanket, so it swings between very hot and very cold. Venus. It matches Earth in size and roughly in mass, but its thick carbon dioxide air traps heat, making it hot and crushing. “Twin” is only true for size and weight. A dip of 1 per cent means (planet width divided by star width) squared is 0.01, so the ratio is 0.1: the planet is about a tenth as wide as the star. Repeats at the same gap show the planet is going round the star in 12 days, and rule out a one-time event such as a passing object. A planet shines only by reflected l...

Byte by Byte Book 5: Chapter 8 – Formulas and Functions

Byte by Byte › Book 5: Games, Spreadsheets and Networks › Chapter 8: Formulas and Functions

Chapter 8: Formulas and Functions

You will learn: how to write formulas with operators and cell references, the order of operations (BODMAS), how to use the functions SUM, AVERAGE, MIN, MAX, COUNT, MEDIAN and MODE, how formulas change when you copy them (relative references), how to work out mean, median, mode and range, and how to fix common formula errors.

🌟 The Adventure

The next morning the Queen sent Tally a list of questions she wanted answered before the closing ceremony:

Which village has won the most medals? Which village has the most medal points, counting 3 for gold, 2 for silver and 1 for bronze? What is the fastest sprint time? What is the average number of points per race? And please keep every answer up to date as new races finish.

Tally read the last line three times. "Up to date," she said faintly. "Every time a race finishes. There will be forty more races today."

The status bar could add up a column, but it could not work out medal points, and it forgot its answer the moment you clicked somewhere else.

Nimo bobbed in his bubble. "Then we must write the answers into the spreadsheet," he said, "not as numbers, but as instructions. Instructions that work themselves out again whenever anything changes."

"Formulas," said Memoon.

💡 Learn With Memoon

What is a formula? A formula is an instruction in a cell that tells Excel to calculate something. Every formula starts with an equals sign (=). The cell shows the result; the Formula Bar shows the formula itself.

Operators. Excel uses these arithmetic operators:

OperatorMeaningExampleResult
+Add=7+310
-Subtract=7-34
*Multiply=7*321
/Divide=7/23.5
^Power=2^38 (2 × 2 × 2)

Notice that computers use * for multiply and / for divide, not × and ÷. You saw the same in Scratch.

Order of operations. Excel follows the same rules you learn in maths, called BODMAS: Brackets first, then Orders (powers), then Division and Multiplication (left to right), then Addition and Subtraction (left to right).

FormulaWorkingResult
=2+3*43 × 4 = 12, then 2 + 1214
=(2+3)*42 + 3 = 5, then 5 × 420
=10-4/24 ÷ 2 = 2, then 10 − 28
=2*3^23² = 9, then 2 × 918

When in doubt, add brackets. They never hurt and they make a formula easier to read.

Use cell references, not typed numbers. You could type =10+12+8. But if any of those numbers change, the answer will be wrong. Instead, point to the cells: =F2+F3+F4. Now the formula reads whatever is in those cells right now, and Excel recalculates the moment any of them change. This is the secret of Tally's "always up to date".

To enter a reference without typing it, type =, then click the cell; type +, then click the next. Excel colours each reference and its cell to match, which helps you check.

Functions. Adding a hundred cells with + would be painful. A function is a ready-made formula with a name. You give it values to work on, called arguments, inside brackets:

=FUNCTION(arguments)
=SUM(F2:F11)
FunctionWhat it givesExample
SUMThe total=SUM(F2:F11)
AVERAGEThe mean (total ÷ how many)=AVERAGE(F2:F11)
MINThe smallest value=MIN(E2:E5)
MAXThe largest value=MAX(F2:F11)
COUNTHow many cells contain numbers=COUNT(F2:F11)
COUNTAHow many cells are not empty (any data)=COUNTA(D2:D11)
MEDIANThe middle value when sorted=MEDIAN(F2:F11)
MODE.SNGLThe most common value=MODE.SNGL(F2:F11)

Three quick ways to enter a function:

  • Type it. Type =SU and Excel suggests SUM. Press Tab to accept, then select the range and press Enter. You don't need to type the closing bracket; Excel adds it.
  • AutoSum. Click the cell under a column of numbers and click AutoSum (Σ) on the Home tab, or press Alt+=. Excel guesses the range; check it, then press Enter. The arrow beside Σ offers Average, Count, Max and Min too.
  • Insert Function. Click fx beside the Formula Bar to search for any function and see what each argument means.

Statistics: describing data with numbers. In maths you learn four ways to summarise a set of numbers. Excel does each in one formula. Using the Points column from Chapter 7 (10, 12, 8, 6, 12, 8, 10, 6, 10, 12):

MeasureMeaningWorkingExcelAnswer
MeanTotal ÷ how many94 ÷ 10=AVERAGE(F2:F11)9.4
MedianMiddle value when sortedSorted: 6, 6, 8, 8, 10, 10, 10, 12, 12, 12; middle two are 10 and 10=MEDIAN(F2:F11)10
ModeMost common value10 and 12 each appear 3 times=MODE.SNGL(F2:F11)10 (but see below)
RangeLargest − smallest12 − 6=MAX(F2:F11)- MIN(F2:F11)6

Look carefully at the mode. 10 and 12 both appear three times, so this data has two modes. MODE.SNGL can only show one, so it shows the first it finds. A computer gave a correct-looking answer that tells only half the story. That is why you must understand the maths, not just press buttons. (The function MODE.MULT lists every mode.)

Which average should you use? The mean uses every value but is pulled about by one very large or very small number. The median is not affected by extreme values. The mode is best for "most popular" questions, such as the most common shoe size.

Copying formulas: relative references. This is the most powerful idea in spreadsheets. Suppose G2 holds =E2+F2. Drag its fill handle down to G3. G3 does not get =E2+F2. It gets =E3+F3. Excel moves the references by the same amount the formula moved: one row down. These are called relative references, because they are relative to where the formula is.

CellFormula after copying down
G2=E2+F2
G3=E3+F3
G4=E4+F4

So you write a formula once for the first row, then copy it down for every other row. One formula, a thousand rows. (Sometimes you need a reference that does not move when copied. That is called an absolute reference, and you will learn it in a later book.)

Percentages. A percentage is a part of 100. To find what percentage of all medals Moonbrook won, divide its medals by the total: =E3/E7. The result is a decimal such as 0.22. Click Percent Style (%) on the Home tab to show it as 22%. Excel multiplies by 100 for display, but the cell still holds 0.22.

When formulas go wrong. Excel shows an error value instead of a result when it cannot calculate:

ErrorWhat it meansTypical cause
#DIV/0!Dividing by zeroThe cell you divide by is empty or 0
#NAME?Excel doesn't recognise a nameA misspelled function, such as =SUMM(F2:F11)
#VALUE!Wrong kind of dataDoing maths with text, such as =D2+F2 when D2 is a name
#REF!A reference no longer existsYou deleted a cell that a formula used
####Not an error: the column is too narrowWiden the column

To see every formula in a sheet at once, press Ctrl+` (the key above Tab), or use Formulas → Show Formulas. Press it again to go back. It is a great way to check your work, and a Book 4 debugging skill: isolate the problem by looking at what each cell is really doing.

💡 Memoon’s tip: After writing a formula, check it with a number you can work out in your head. If =AVERAGE(2,4) doesn't give 3, something is wrong with how you are using it.

Illustration from Byte by Byte Book 5: Chapter 8 – Formulas and Functions

✍️ Try It Yourself

Activity 1: BODMAS check. Open a new sheet in your Memunic Games Results workbook (click + and rename it Practice). In column A type each formula below, but first write your prediction in your notebook. Were you right every time?

  1. =5+5*2
  2. =(5+5)*2
  3. =20/4+1
  4. =20/(4+1)
  5. =3^2+4^2
  6. =100-10*3^2

Activity 2: Summary formulas. Go to the Races sheet.

  1. In D13 type Total points, and in F13 type =SUM(F2:F11).
  1. Below it, add labels in column D and formulas in column F for: Average points (AVERAGE), Median points (MEDIAN), Most points in a race (MAX), Fewest points in a race (MIN), Points range (MAX − MIN), Number of races (COUNT).
  2. In D20 type Fastest sprint (s) and in E20 type =MIN(E2:E5).
  3. Check each answer against the table in this chapter.
  4. Change Spike's points in Race 4 from 6 to 7. Watch which results change by themselves. Then change it back.

Activity 3: The medal table. Add a new sheet called Medals.

  1. Type this table, starting in A1:
VillageGoldSilverBronze
Riverbend435
Moonbrook542
Snowpeak354
Pebble Hollow223
Palace Town134
  1. In E1 type Total medals. In E2 type =B2+C2+D2 (or =SUM(B2:D2)). Drag the fill handle from E2 down to E6.
  2. In F1 type Medal points. In F2 type =B2*3+C2*2+D2 . Why are no brackets needed? Drag it down to F6.
  3. Click F4 and look at the Formula Bar. What is the formula now? Why did it change?
  4. In A7 type All villages, and in B7 use SUM for the gold column. Drag B7 across to F7.
  5. In G1 type Share of medals. In G3 type =E3/E7 and click Percent Style. What percentage of all medals did Moonbrook win?
  6. Press Ctrl+` to see all your formulas, then press it again.

Activity 4: Error hunt. In the Practice sheet, make each error happen on purpose: #DIV/0!, #NAME? and #VALUE!. Write the formula that caused each one and how you would fix it.

Unplugged: The human spreadsheet. Six friends stand in a row as cells A1 to F1, each holding a card with a number. One more friend is cell G1, holding a card that says =SUM(A1:F1). G1 must call out the total. Now change one friend's card. G1 must recalculate out loud straight away. Then try G1 = MAX, MIN and AVERAGE.

🎉 Memoon Solves It

By lunchtime Tally's workbook could answer every one of the Queen's questions. The Medals sheet worked out total medals and medal points for every village with just two formulas, each written once and copied down. Moonbrook led on medal points with 25, ahead of Riverbend and Snowpeak on 23 each.

Then a runner raced in with a new result. Snowpeak had won another gold. Tally typed 4 over the 3 in the Gold column and pressed Enter.

The total changed. The medal points changed. The percentages changed. The village totals at the bottom changed. All at once, all correct.

Tally checked them anyway, twice, with a pencil. They were right.

"Forty more races," she said, and for the first time all week, she laughed.

But when the Queen came to look, she frowned slightly at the screen. "It is all very correct," she said kindly. "But it is a great many numbers. Tonight I must announce the results to all of Memunic. Can anyone see, at a glance, who is winning?"

❓ Check Your Knowledge

  1. What must every formula in Excel start with?
  2. What is the result of =4+6/2? Of =(4+6)/2? Explain using BODMAS.
  3. Why is =F2+F3 better than =10+12?
  4. What is a function? What are its arguments?
  5. Write the formula to find the largest number in B2:B30.
  6. For the data 3, 7, 7, 2, 9, 5, 2, find the mean, median, mode(s) and range by hand. Then write the Excel formula for each.
  1. Cell C2 holds =A2*B2 . You copy it down to C5. What formula is in C5? What is this kind of reference called?
  2. What is the difference between COUNT and COUNTA?
  3. What does #NAME? usually mean? What about #DIV/0!?
  4. A cell holds 0.35. How will it look after you click Percent Style?
  5. Challenge: The Queen changes the scoring to 5 points for gold, 3 for silver and 1 for bronze. Which single cell would you edit first, and how would you update all the villages? Which village leads now?

📚 Word Bank

  • Formula: an instruction in a cell, starting with =, that calculates a result.
  • Operator: a symbol for a calculation: + − * / ^.
  • BODMAS: the order of operations: brackets, orders, division and multiplication, addition and subtraction.
  • Function: a named, ready-made formula such as SUM or AVERAGE.
  • Argument: a value or range given to a function inside its brackets.
  • AutoSum: the Σ button that adds a SUM (or other) function automatically.
  • Mean: the total divided by how many values (AVERAGE in Excel).
  • Median: the middle value when the data is sorted.
  • Mode: the most common value; data can have more than one.
  • Range (statistics): the largest value minus the smallest.
  • Relative reference: a cell reference that changes when a formula is copied.
  • Percentage: a part out of 100, shown with %.
  • Error value: a code such as #DIV/0! shown when a formula cannot be calculated.

Keep learning with Byte by Byte

Explore Book 5: Games, Spreadsheets and Networks. Find the ebook, purchase details and teaching slides on MemuniCity.

Watch this chapter on YouTube

Comments

Popular posts from this blog

CA-7 Job Status and Failure Reason Codes

Here are the various status codes that You may see for jobs in the Queue or Logs in CA-7. R-C0002 R-C0003 R-C0099 R-C0255 R-JCLER A-U0002 A-U0004 A-U0015 A-U0043 A-U4095 A-SOC7 A-U4000 Reason Code/Job Status Code explanation: The indication of the job's current disposition. Values and their meanings are: A-Snnnn-- The job has failed with a system abend. A-Unnnn --The job has failed with a user abend. C-Cnnnn --The job has completed successfully and is going through completion processing. E-ARFATT-- An error occurred during the attempt to attach ARF definitions. This can result if the ARFSET specified is not defined. A diagnostic message may have been written to the CA-7 log, the OS console, or to the trailer queue for the job (in which case it can be displayed using LQ,JOB=x,LIST=ALL). E-ARFERR ---The job encountered an error in the ARF processing. Do a LARFQ command for the job to get more specific information. E-SEGERR --The job has been requeued...

Whistling Winds and Waterfalls: 4 Days of Magic in Shillong

Nestled in the clouds, where the scent of pine trees mingles with the rhythm of waterfalls and the tunes of local guitar-strumming youth—Shillong is more than a place. It’s a vibe. If you’ve got 3 nights and 4 days, you’ve got just enough time to fall in love. Here’s how to make the most of it—food, fun, fog and fantastic views included. Day 1: Shillong, We’re Coming for You! You land in Guwahati, barely out of the airport when the hills start calling. You hop into your cab, Spotify on, windows down, and the three-hour ride to Shillong begins. Just when you think it can’t get better, you stop at Umiam Lake —a lake so calm, it looks like someone ironed the water. By evening, you’re sipping hot chai in Laitumkhrah, maybe nibbling on spicy momos or pork jadoh from a roadside stall. You’re checked into your charming hotel ( Tripura Castle if you fancy old-world royalty, Ri Kynjai if you’re into lakeside poetry). The breeze whispers secrets of waterfalls and pine forests. Sleep well, drea...

Installing and Configuring Hadoop on Ubuntu as a Pseudo Distributed Single Node Cluster

Briefly what is psuedo-distributed single node Hadoop cluster: It is a Hadoop distributed cluster having Single Node. All the five daemons (NN,DN,JT,TT,SNN) are running as individual JVM (java process) instances. We will get all distributed features of Hadoop. This mode is used to develop, test, and staging (before production) Map Reduce programs quickly. It writes all the system, daemon and user logs to different files on the cluster To install Hadoop in this mode, we have to modify the hadoop-env.sh, core-site.xml, hdfs-site.xml, mapred-site.xml. hadoop-env.sh contains all the Environment variables which are required for running Hadoop. All the default values are fine, Only we have to modify the JAVA_HOME=“The location of Java Home Directory” Core-site.xml contains all the cluster specific information like io, temp directory, sorting, file system uri etc. Hdfs-site.xml contains all the parameters which are specific to HDFS like name node directory, data node directory...