Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3732
| Newsgroups | fr.comp.lang.python |
|---|---|
| Subject | Simplifier le programme |
| From | OverSkill <nospam_kadiyogohector@gmail.com.invalid> |
| Organization | !No_Organization! |
| Message-ID | <dLydnXMwVOCzfWf8nZ2dnUU7_83NnZ2d@giganews.com> (permalink) |
| Date | 2022-02-02 13:49 -0600 |
bonjour, je viens de finir un programme python pour un projet personnel mais
j'aimerais savoir s'il y a un moyen de le simplifier:
from datetime import *
month_days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30]
push_ups = 0
today = date.today()
day = today.day
month = today.month
if month == 2:
push_ups += month_days[0]
elif month == 3:
push_ups += month_days[0:1]
elif month == 4:
push_ups += month_days[0:2]
elif month == 5:
push_ups += month_days[0:3]
elif month == 6:
push_ups += month_days[0:4]
elif month == 7:
push_ups += month_days[0:5]
elif month == 8:
push_ups += month_days[0:6]
elif month == 9:
push_ups += month_days[0:7]
elif month == 10:
push_ups += month_days[0:8]
elif month == 11:
push_ups += month_days[0:9]
elif month == 12:
push_ups += month_days[0:10]
push_ups += day
print("Aujourd'hui, tu dois faire", push_ups, "pompes")
son but est de compter le combientième jour nous sommes dans l'année, si vous
avez une solution, merci d'avance
Back to fr.comp.lang.python | Previous | Next — Next in thread | Find similar
Simplifier le programme OverSkill <nospam_kadiyogohector@gmail.com.invalid> - 2022-02-02 13:49 -0600
Re: Simplifier le programme Dominique <zzz@aol.com.invalid> - 2022-02-02 21:46 +0100
Re: Simplifier le programme overskill <nospam_kadiyogohector@gmail.com.invalid> - 2022-02-02 15:06 -0600
Re: Simplifier le programme Dominique <zzz@aol.com.invalid> - 2022-02-03 06:20 +0100
Re: Simplifier le programme overskill <nospam_kadiyogohector@gmail.com.invalid> - 2022-02-04 01:27 -0600
csiph-web