(Aug-27-2020, 01:42 PM)Axel_Erfurt Wrote: shorter version
hrs = float(input("Enter Hours:")) print(hrs * 1.5) if hrs <= 40 else print(hrs * 10.5)
Oh I like this game!
hrs = # blah print(hrs * (1.5 if hrs <=40 else 10.5))Or we can use indexing, knowing True=1 and False=0 (I don't like this version, though, it's not immediately obvious what's going on):
hrs = # blah print(hrs * (1.5, 10.5)[hrs > 40])OR! All in one line, for a terribly hard to read version:
print( (hrs := float(input("Hours? "))) and (hrs * (1.5, 10.5)[hrs > 40]))