lundi 24 août 2020

What is considered more readable / pythonic for a beginner? If other factors were to arrive? [closed]

  1. What is considered more readable / pythonic for a beginner? If other factors were to arrive?

  2. Does this change with experience?

hrs = float(input("How many Hours:"))
rate = float(input("Whats the rate?:"))
pay = hrs * rate

if hrs > 40:
  pay = 40*rate +(hrs-40)*rate*1.5

print (pay)

Or

hrs = float(input("How many Hours:"))
rate = float(input("Whats the rate?:"))
pay = hrs * rate

If hrs< 40:
  print(pay)
elif hrs > 40:
  pay = 40*rate +(hrs-40)*rate*1.5

print (pay)

Aucun commentaire:

Enregistrer un commentaire