Skip to content

Commit ff37e45

Browse files
committed
doc: add comments
Conditional exercises (if, elif, else). Travel cost.
1 parent c35faad commit ff37e45

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ex031.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#Travel Cost
12
#31- Develop a program that asks the distance of a trip in km. Calculate the ticket price, charging R$0.50 per
23
# km for trips up to 200km and R$0.45 for longer trips.
34
distance = float(input('What is the distance of your travel?'))
@@ -7,3 +8,16 @@
78
else:
89
price = distance * 0.45
910
print(f'And the price of your ticket will be R${price}.')
11+
12+
#Custo da Viagem
13+
# 031: Desenvolva um programa que pergunte a distância de uma viagem em Km. Calcule o preço da passagem,
14+
# cobrando R$0,50 por Km para viagens de até 200Km e R$0,45 parta viagens mais longas.
15+
distancia = float(input('Qual a distância em Km que você vai viajar?'))
16+
if distancia <= 200:
17+
preco = distancia * 0.50
18+
else:
19+
preco = distancia * 0.45
20+
print(f'O preço da passagem será de R${preco:.2f}.')
21+
22+
#PT- Exercícios com uso de condicional.
23+
#EN- Exercises using conditional.

0 commit comments

Comments
 (0)