Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Coding

Ensino Fundamental
8° e 9° Anos

Coding Map SD3.5

Theme: Loopings Tempo: 100 min

Learning Goals

● Specific English vocabulary for repetition and loop commands.


● Association between loops and numerical lists.

Expectations for students at the end of this class

Students are expected to understand how to use loops in Python.

Let’s Start

Student’s material

Useful words

● While – enquanto

● For – para

● Range – alcance, tamanho

● List - lista

● Repetition - repetição

● Saving time - economizando tempo

Welcome Back!
Hello students, welcome back to the Coding Meeting!
In the last meetings we studied repetition commands. They are useful for saving time, and
important if you don't like writing the same thing over and over again. We will continue this
study today! Let's check the objectives of the day by clicking on the topics below:

Objectives
1. Rewind: What have I learned? Take a look at your Coding Documentation.
2. Training more about repetition commands.
3. Use the Trinket IDE to practice the repetition commands.
4. Create a program to display Fibonacci’s sequence.
5. Update your Coding Documentation and submit your Today's Mission link at Canvas.

Go to the next page to return your Python learning.

Instructor’s material

Welcome students and organize the learning environment.


Round 1: The students must complete the Let's Start section, read about the objectives of the
day and also complete the review activity there. During this time, walk among the tables,
answering possible questions from the students. If necessary, explain the “useful words” to
students.
Estimated time: 15 minutes

Learning Time

Student’s material

Vocabulary

● list - lista

● remember - relembrar

● successively - sucessivamente

● scroll - percorrendo

● mix - misturar

● instead - ao invés

● true - verdadeiro

● false – falso
● infinite – infinito

● nonending – sem fim

● nested – aninhado, agrupado

Infinite Loops

Suppose you write a while loop that theoretically never ends. Sounds weird, right?

Consider this example:

This code was problematic. Clearly, True will never be false, or we’re all in a big trouble.
Thus, while True: initiates an infinite loop that will theoretically run forever.

Maybe that doesn’t sound like something you’d want to do, but this pattern is actually quite
common. For example, you might write code for a service that starts up and runs forever
accepting service requests. “Forever” in this context means until you shut it down, or until the
heat death of the universe, whichever comes first.

In general, Python control structures can be nested within one another. For example, we can
put a loop inside another loop:

The following video shows another example of grouped/nested structures:

https://youtu.be/ld6xvFgOKdo
Well done! Move on to the next page to practice what you learned!

Instructor’s material
Today's Learning Time will continue with “for” and “while” commands. It’s important to
exercise them.
Round 2:  while the students do the Learning Time activities, go around the tables helping
with possible questions. 
Estimated time: 30 minutes

Checkpoint

Student’s material

What is the correct syntax for a "while" loop in Python?


a) for i in range(1, 11):
b) while i < 10:
c) for i = 1 to 10
d) while i <= 10:
Correct answer: d) while i <= 10:

What is an iteration variable in a loop in Python?


a) A variable that defines the number of loop iterations
b) A variable that stores the result of the loop
c) A variable that changes with each iteration of the loop
d) A variable that ends the loop
Correct answer: c) A variable that changes with each iteration of the loop

What is the difference between a "for" loop and a "while" loop in Python?
a) The "for" loop is more efficient than the "while" loop
b) The "for" loop is used to iterate over lists, while the "while" loop is used to repeat a block of
code while a condition is true
c) The "while" loop is more efficient than the "for" loop
d) The "for" loop is used to repeat a block of code while a condition is true, while the "while"
loop is used to iterate over lists
Correct answer: b) The "for" loop is used to iterate over lists, while the "while" loop is used to
repeat a block of code while a condition is true

What happens if you try to use a "for" loop to iterate over a dictionary in Python?
a) Nothing, the "for" loop works correctly with dictionaries
b) Python returns a syntax error
c) The "for" loop only iterates over the keys of the dictionary, not the values
d) The "for" loop only iterates over the values of the dictionary, not the keys
Correct answer: c) The "for" loop only iterates over the keys of the dictionary, not the values

What is the function of the "break" command in a loop in Python?


a) Ends the current loop
b) Skips to the next iteration of the loop
c) Sets a condition for the loop to end
d) Creates a copy of the current loop
Correct answer: a) Ends the current loop

Instructor’s material

At the end of learning time, use the quiz to check students' understanding of the topics
studied during today's meeting. This checkpoint also picks up on some conditional and
math commands from the previous encounters.
Round 3: use this moment to go through the tables and verify that the students are doing
the activities.
Estimated time: 15 minutes

Training Time

Student’s material

Exercise 3.5A
Create a program that calculates and displays the table of a user-supplied number using a
"for" loop. The program should ask the user which number he wants to calculate and then
display the 1-10 table for that number.
Exercise 3.5B
Write a program that prompts the user to type a word and then displays that word with
each letter duplicated. For example, if the user types "Python", the program should display
"PPyytthhoonn". Use a "for" loop to loop through the string and duplicate each letter.

Exercise 3.5C
Write a program that displays all odd numbers between two user-supplied values. The
program should prompt the user to enter the starting and ending values and then display
all odd numbers between those values. Use a "for" loop to loop through the numbers.

Instructor’s material

Training Time activities involve again various applications of “for” and “while” commands.
Remind students about the importance of completing the Coding Documentation.
Round 4: encourage students to do activities. Use this moment to walk around the tables,
check if students are doing the activities and solve questions.
Answer examples:
3.5C

Estimated time: 30 minutes

Today’s Mission

Student’s material

The Fibonacci sequence is a series of numbers where each number is the sum of the two
preceding numbers, starting with 0 and 1. So the sequence goes: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and
so on.
This sequence was first introduced to the western world by the Italian mathematician
Leonardo of Pisa, who was also known as Fibonacci, in his book Liber Abaci in the 13th
century. However, the sequence had been previously described in Indian mathematics.
The Fibonacci sequence has many interesting properties and applications in mathematics
and nature. For example, the ratio between two adjacent numbers in the sequence
converges to the golden ratio, which is a mathematical constant that appears in many
natural phenomena, such as the growth of shells, the proportions of the human body, and
the spirals of galaxies. The Fibonacci sequence also appears in the study of number theory,
combinatorics, and algorithms.
Create a program that prompts the user to enter a number and then displays the Fibonacci
sequence up to that number. The Fibonacci sequence is a series of numbers where each
number is the sum of the two previous numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Use a "while" loop
to generate the Fibonacci sequence up to the number provided by the user.

Instructor’s material

Today’s mission is to create a Fibonacci’s sequence.

Solution:

Round 5: use this moment to walk around the tables, check if students are doing the
activities and solve questions.
Estimated time: 25 minutes

Submit and Clean Up

Student’s material

<slide básico para o submit and clean up, contendo as instruções de inserção de link e de
arrumação do ambiente>

Instructor’s material

In the next section, Submit & Clean Up, if the student clicks on “iniciar tarefa”, this menu will
appear and it’s just paste the code on URL blank space:

The teacher, with the help of the monitors, must check if all the students posted their
Today’s Mission link in the Coding Documentation file. 
There is a unique slot in each encounter to be filled with this link.
This correction will not be part of the final grade, it will only be useful to help the teacher
understand which students are having more difficulties.
Estimated time: 15 minutes

Challenge Time

Student’s material

Challenge Time #1
Write a program that prompts the user to type a sentence and then displays the count of
each vowel present in the sentence. For example, if the user types "Python is a programming
language", the program should display "a: 6, e: 2, i: 1, o: 2, u: 1". Use a "for" loop to move
through the sentence and count the vowels.

Instructor’s material

You might also like