File tree Expand file tree Collapse file tree 3 files changed +36
-17
lines changed Expand file tree Collapse file tree 3 files changed +36
-17
lines changed Original file line number Diff line number Diff line change 1- #Create a program that reads the age and gender of several people. For each registered person, the program should
2- # ask whether or not the user wants to continue. At the end, show:
3- #A) how many people are over 18 years old.
4- #B) how many men were registered.
5- #C) how many women are under 20 years old.
6-
1+ # 069: Crie um programa que leia a idade e o sexo de várias pessoas. A cada pessoa cadastrada, o programa deverá
2+ # perguntar se o usuário quer ou não continuar. No final, mostre:
3+ # A) quantas pessoas tem mais de 18 anos.
4+ # B) quantos homens foram cadastrados.
5+ # C) quantas mulheres tem menos de 20 anos.
6+ total_maior = total_homem = total_mulher = 0
7+ while True :
8+ idade = int (input ('Qual a sua idade?' ))
9+ genero = ' '
10+ while genero not in "FM" :
11+ genero = str (input ('Qual o seu gênero? [F/M]' )).strip ().upper ()[0 ]
12+ if idade >= 18 :
13+ total_maior += 1
14+ if genero == "M" :
15+ total_homem += 1
16+ if genero == "F" and idade < 20 :
17+ total_mulher += 1
18+ resposta = ' '
19+ while resposta not in "SN" :
20+ resposta = str (input ('Deseja continuar? [S/N]' )).strip ().upper ()[0 ]
21+ if resposta == "N" :
22+ break
23+ print (f"O total de pessoas com mais de 20 anos é { total_maior } ." )
24+ print (f'Ao total temos { total_homem } homens cadastrados.' )
25+ print (f'Ao total temos { total_mulher } mulheres com menos de 20 anos de idade.' )
Original file line number Diff line number Diff line change 33#A) qual é o total gasto na compra.
44#B) quantos produtos custam mais de R$1000.
55#C) qual é o nome do produto mais barato.
6- total = totmil = menor = cont = 0
6+ total = total_mil = menor = contador = 0
77barato = ' '
88while True :
99 produto = str (input ('Qual o produto que você quer comprar?' ))
1010 preco = float (input ('Qual o valor do produto em R$:' ))
1111 total += preco
1212 if preco > 1000 :
13- totmil += 1
14- if cont == 1 :
13+ total_mil += 1
14+ if contador == 1 :
1515 menor = preco
1616 else :
1717 if preco < menor :
1818 menor = preco
1919 barato = produto
20- resp = ' '
21- while resp not in "SN" :
22- resp = str (input ('Quer continuar? [S/N]' )).strip ().upper ()[0 ]
23- if resp == 'N' :
20+ resposta = ' '
21+ while resposta not in "SN" :
22+ resposta = str (input ('Quer continuar? [S/N]' )).strip ().upper ()[0 ]
23+ if resposta == 'N' :
2424 break
2525print ("Fim do programa." )
2626print (f'O total da compra foi R${ total :.2f} ' )
27- print (f'Temos { totmil } produtos custando mais de R$1.000,00' )
27+ print (f'Temos { total_mil } produtos custando mais de R$1.000,00' )
2828print (f'O produto mais barato foi { barato } que custa R${ menor :.2f} ' )
Original file line number Diff line number Diff line change 1- #Create a program that simulates the operation of an ATM. At the beginning, ask the user how much money will be
2- # withdrawn (integer) and the program will inform how many bills of each value will be delivered. NOTE:
3- #Consider that the ATM has bills of U $50, U $20, U $10 and U$1.
1+ # 071: Crie um programa que simule o funcionamento de um caixa eletrônico. No início, pergunte ao usuário qual
2+ # será o valor a ser sacado (número inteiro) e o programa vai informar quantas cédulas de cada valor serão entregues.
3+ # OBS: considere que o caixa possui cédulas de R $50, R $20, R $10 e R$1
You can’t perform that action at this time.
0 commit comments