Corrigé

Code:
my_name = "Émile"
print("Hello, " + my_name)
print(len(my_name))

print(my_name.upper())
print(my_name.capitalize())
# or:
print(my_name[0].upper() + my_name[1:].lower())

mid = len(my_name) // 2
print(my_name[0:mid] + '-' + my_name[mid:])


distance = 10
speed = 3
duration = distance // speed

print("Distance à parcourir: " + str(distance) + " km")
print(f"Vitesse: {speed} km/h")
print(f"Durée du trajet: {duration} h")

duration_minutes = int(((distance / speed) - duration) * 60)
print(f"Non... vraie durée du trajet: {duration} h {duration_minutes} min")

# or:
duration_hours, rest = divmod(distance, speed)
duration_minutes = int(rest / speed * 60)

print(f"Non... vraie durée du trajet: {duration_hours} h {duration_minutes} min")
Last modified: Monday, 19 September 2022, 23:58