Trial 022: Number Pattern Generator. Topic. Number Pattern Generator. Academy Trial Briefing. Practice using range() with a for loop to build a running total and print a number pattern report. The holotable needs five numbered pattern marks. Use range() so Python forges the marks in order and totals the sequence. Learn Before You Code. Lesson 1. Python focus: range makes numbers for loops. range(1, 6) gives the numbers 1 through 5. A for loop can use those numbers one at a time. Code example....
Full Transcript
Trial 022: Number Pattern Generator. Topic. Number Pattern Generator. Academy Trial Briefing. Practice using range() with a for loop to build a running total and print a number pattern report. The holotable needs five numbered pattern marks. Use range() so Python forges the marks in order and totals the sequence. Learn Before You Code. Lesson 1. Python focus: range makes numbers for loops. range(1, 6) gives the numbers 1 through 5. A for loop can use those numbers one at a time. Code example. for number in range(1, 6): Lesson 2. Add each number to a total. A running total starts at 0. Inside the loop, add the current number to the total. Code example. pattern total = pattern total + number Lesson 3. Print marks as the loop runs. Printing inside the loop shows each pattern mark. Printing after the loop shows the final total. Code example. print(f"Pattern total: {pattern total}") Micro Trial Steps. Step 1. Open the range. Concept. range sequence. Use range(1, 6) so the loop receives 1 through 5. Checkpoint. range is used. Step 2. Add each mark. Concept. for loop total. Use a for loop and add number to pattern total inside it. Checkpoint. for loop syntax is present. Step 3. Forge the marks. Concept. number pattern. Print a Pattern mark line as each number arrives. Checkpoint. Output shows pattern marks.
Trial 022: Number Pattern Generator. Topic. Number Pattern Generator. Academy Trial Briefing. Practice using range() with a for loop to build a running total and print a number pattern report. The holotable needs five numbered pattern marks. Use range() so Python forges the marks in order and totals the sequence. Learn Before You Code. Lesson 1. Python focus: range makes numbers for loops. range(1, 6) gives the numbers 1 through 5. A for loop can use those numbers one at a time. Code example....