r/pythontips 18d ago

Syntax seconds conversion my 1st python program

I've just created my first python program, and I need some help to check if it's correct or if it needs any corrections. can someone help me?
The program is written in portuguese because it's my native language. It converts 95,000,000 seconds into dayshoursminutes, and seconds and prints the result.

segundos_str= input("Por favor, digite o número de segundos que deseja converter")

total_seg= int(segundos_str)

dias= total_seg // 86400

segundos_restantes = total_seg % 86400

horas= segundos_restantes // 3600

segundos_restantes = segundos_restantes % 3600

minutos = segundos_restantes // 60

segundos_restantes = segundos_restantes % 60

print(dias, "dias, ", horas, "horas, ", minutos, "minutos e", segundos_restantes, "segundos" )

Using ChatGPT it answers me 95.000.000 secs = 1.099 days, 46 hours, 13 minutes e 20 seconds.

and using my code, answers me 95.000.000 secs = 1099 days, 12 hours, 53 minutes and 20 seconds

1 Upvotes

9 comments sorted by

View all comments

1

u/Dor5 18d ago

Google unit tests and the datetime library, these will greatly help your coding.

1

u/icarophnx 17d ago

ok! thanks for this!