SECTION 14 / 15

Tutorial lab: nouns, bill averages and expenditure bands

2 min read
On this page 3 headings

Practise the same ideas with the original word cards and shopping bills. These are new questions on familiar data, so you can focus on the procedure rather than learning a new dataset.

Check PartOfSpeech first. Among nouns, length greater than 7 is long; exactly 7 is short.
Check PartOfSpeech first. Among nouns, length greater than 7 is long; exactly 7 is short.

Tutorial 3.1: nested decisions

LongNoun = 0; ShortNoun = 0
for each row X in Words {
    if (X.PartOfSpeech == "Noun") {
        if (X.LetterCount > 7) { LongNoun = LongNoun + 1 }
        else { ShortNoun = ShortNoun + 1 }
    }
}
REAL COURSE DATA · FOLLOW THE PROCEDURE

Count long and short nouns

Read the current record, check the explanation, and watch the variables. Use Back to revisit any step.

Ready

CURRENT RECORD

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Start at the first step. Watch the current row and the values we remember.

The result is 7 long noun occurrences and 14 short noun occurrences:21 nouns in total. Non-nouns increase neither counter. Notice that “short” here means 7 or fewer; this task uses a different definition from the hypothesis lesson’s 5-or-fewer rule.

Tutorial 3.2: bills above average

Find the final average of all 30 bills before selecting the bills above it.
Find the final average of all 30 bills before selecting the bills above it.
REAL COURSE DATA · FOLLOW THE PROCEDURE

Find bills above the final average

Read the current record, check the explanation, and watch the variables. Use Back to revisit any step.

Ready

CURRENT RECORD

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Start at the first step. Watch the current row and the values we remember.

All 30 amounts total₹24,413. Average=24413/30≈₹813.7667. The 8 above-average BillNo values are 2,3,5,8,11,13,23,25. Use the unrounded average for comparisons.

Tutorial 3.2: low, medium and high expenditure

The supplied bills range from₹92 to₹4,174. The tutorial’s three bands contain 26,1 and 3 bills.
The supplied bills range from₹92 to₹4,174. The tutorial’s three bands contain 26,1 and 3 bills.
REAL COURSE DATA · FOLLOW THE PROCEDURE

Classify bills into expenditure bands

Read the current record, check the explanation, and watch the variables. Use Back to revisit any step.

Ready

CURRENT RECORD

Ready to begin

No records have been processed. Start with Next step.

What we remember

Processed
0

Start at the first step. Watch the current row and the values we remember.

Tutorial bandInclusive rupee boundsCount
Low92–145326
Medium1454–28131
High2814–41743

The numerical width is(4174−92)/3≈1360.6667. The tutorial rounds cut points to define the integer bands above. Specify those bounds explicitly; they are the convention used here. Real bills can include paise, so a general solution would use continuous bounds or integer paise rather than leaving fractional amounts between integer bands.

A guessed huge initial Minimum is only safe with a guaranteed bound. Initializing Minimum and Maximum from the first actual bill avoids assuming that no larger bill can ever occur. Handle an empty dataset separately.

Try it yourself

Does a noun with 7 letters count as long here?

Show explained answer

No. The condition is strictly greater than 7, so it is short in this tutorial.

Try it yourself

What is LongNoun+ShortNoun?

Show explained answer

7+14=21 noun occurrences.

Try it yourself

How many bills exceed the final average?

Show explained answer

8 bills.

Try it yourself

Which BillNo is the only medium-expenditure bill?

Show explained answer

Bill 2, for₹1,525.

Try it yourself

Do three expenditure bands contain ten bills each?

Show explained answer

No. They have 26 low,1 medium and 3 high bills.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑