Math Bonk! Learning Centre Play the game

Worksheet for the lesson Coding to Analyse Data: Subprograms and Nested Loops · All worksheets

Coding to Analyse Data: Subprograms and Nested Loops

Grade 8 math worksheet · mathbonk.com/learn

Name: ______________________   Date: ____________

Look

AnswerTally marks
PizzaIIII II
SushiIIII
TacosIII
OtherII
A tally chart of lunch choices: pizza, sushi, tacos and other
  1. How many people chose pizza?
  2. How many answers are there in all?
  3. What percent chose sushi, to the nearest whole percent?

Practice

  1. In a program, what is a named block that can be used again and again called?
  2. A counter starts at 0. What is it after repeat 3 [ repeat 4 [ add 1 to count ] ]?
  3. In a survey of 20 people, 8 chose pizza. What percent is that?
  4. Why does a counting loop contain an "if" block?
  5. A survey has 15 yes answers and 25 no answers. How many people were surveyed in all?
  6. How many lines does repeat 2 [ repeat 5 [ print "x" ]; new line ] print?
  7. Why test a program on a short list of data first?
  8. In a bag of 30 marbles, 9 are blue. What percent are blue?
  9. To turn counts into percents, what does the program do to each count?
  10. A loop goes through a list of 50 answers once. How many times does the loop run?
  11. True or false: a subprogram must be written separately for each choice being counted.
  12. Three classes each give 25 answers. How many answers are there in all?

Think it through

  1. Draw a flowchart for counting how many answers in a list say "yes".
  2. Explain why a program that counts answers should be tested on a short list first.

Challenge

  1. A counter runs repeat 3 [repeat 5 [add 2]]. What is the final count?
  2. In a list of 40 answers, 14 say "maybe". What percent is that?

Answer key

Look

  1. 7
  2. 17
  3. 29%

Practice

  1. a subprogram
  2. 12
  3. 40%
  4. to count only the answers that match
  5. 40
  6. 2
  7. to check that it works before running all the data
  8. 30%
  9. divides it by the total and multiplies by 100
  10. 50
  11. False
  12. 75

Think it through

  1. Start, for each answer, if it says yes add 1, then report the count
  2. To check that it works before running all the data

Challenge

  1. 30
  2. 35 {= 14/40*100}%