Estruturas de seleção - Parte 2 Estruturas de repetição...
Transcript of Estruturas de seleção - Parte 2 Estruturas de repetição...
![Page 1: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/1.jpg)
1
Estruturas de seleção - Parte 2 Estruturas de repetição - Parte 1
Prof. Jesús P. Mena-ChalcoCMCC/UFABC
Q1/2020
Processamento da Informação
![Page 2: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/2.jpg)
2
Procure o programaSpyder
no seu computador
![Page 3: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/3.jpg)
3
Exercício sobre seleção: Gerações
![Page 4: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/4.jpg)
4
Tipos de gerações:baseadas no ano de nascimento
Crie um programa que faça a leitura de um ano (entre 1940 e 2018) e imprima na tela o tipo de geração ao qual o ano está relacionado.
Considere apenas os seguintes 5 tipos: 1940-1960: Geracao Baby Boomers 1961-1980: Geracao X 1981-1997: Geracao Y 1998-2009: Geracao Z 2010-hoje: Geracao Alfa
Obs: Se não estiver em nenhuma dessa geração deve de imprimir “Não classificado”
3
![Page 5: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/5.jpg)
5
Tipos de gerações:baseadas no ano de nascimento
Vamos usar funções, veja a parte inicial do programa
3
TO-DO
![Page 6: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/6.jpg)
6
![Page 7: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/7.jpg)
7
Exercício sobre repetição: Fatorial
![Page 8: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/8.jpg)
8
Fatorial de um número
Crie uma função que permite calcular o fatorial de um número inteiro:
0! = 11! = 12! = 23! = 64! = 24
Assinatura:
3
![Page 9: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/9.jpg)
9
Fatorial de um número
![Page 10: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/10.jpg)
10
Teste de mesa:https://donkirkby.github.io/live-py-plugin/demo/
Teste com valores Diferentes de 5
Note como a variável n atinge o valor zero.Note como o fatorial é ‘construído’.
![Page 11: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/11.jpg)
11
Teste de mesa:https://donkirkby.github.io/live-py-plugin/demo/
...
![Page 12: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/12.jpg)
12
Exercício sobre repetição: Aproximação de e
![Page 13: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/13.jpg)
13
Aproximação de e
O número de Euler
Implemente essa somatoria mas considerando os n primeiros termos, para n>=1.
Assinatura:
Termo1
Termo2
Termo3
Termo4
Termo5
![Page 14: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/14.jpg)
14
![Page 15: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/15.jpg)
15
Teste de mesa:https://donkirkby.github.io/live-py-plugin/demo/
![Page 16: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/16.jpg)
16
Exercício sobre repetição: Aproximação de e (versão 2)
![Page 17: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/17.jpg)
17
Aproximação de e
O número de Euler
Implemente essa nova somatoria mas considerando todos os termos maiores ou iguais a 0.0000001
Assinatura:
Desafio:Quantos termos são maiores ou iguais a 0.0000001?
Termo1
Termo2
Termo3
Termo4
Termo5
![Page 18: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/18.jpg)
18
![Page 19: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/19.jpg)
19
Aproximação de e
11 termos?
Resposta do programa
Uma boa aproximação de e.
![Page 20: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/20.jpg)
20
![Page 21: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/21.jpg)
21
Lista 2:
- 8 exercícios obrigatórios + 1 opcional- Entrega: 09/março (23h59)
![Page 22: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/22.jpg)
22
Lista2_1 - Bart Simpson
![Page 23: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/23.jpg)
23
Lista2_2 - Tabuada
![Page 24: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/24.jpg)
24
Lista2_3 – Máquina de somar
![Page 25: Estruturas de seleção - Parte 2 Estruturas de repetição ...professor.ufabc.edu.br/~jesus.mena/courses/pi-1q... · 2010-hoje: Geracao Alfa Obs: Se não estiver em nenhuma dessa](https://reader034.fdocumentos.tips/reader034/viewer/2022042809/5f8f5c0d3a1e4f10c15910cc/html5/thumbnails/25.jpg)
25
Lista2_4 –Contagem regressiva maluca