fork download
  1. strengths = list(range(29, 52))
  2.  
  3.  
  4. def for_every_five_over_30():
  5. for strength in strengths:
  6. carry = strength * 20
  7. if strength > 30 and strength % 5 == 0:
  8. carry = carry + (0.3 * strength * 20)
  9. print(f'{strength} can carry {carry:.0f} pounds')
  10.  
  11.  
  12. def for_every_over_30():
  13. for strength in strengths:
  14. modifier = 0
  15. if strength > 49:
  16. modifier = 1.2
  17. elif 44 < strength < 50:
  18. modifier = 0.9
  19. elif 39 < strength < 45:
  20. modifier = 0.6
  21. elif 34 < strength < 40:
  22. modifier = 0.3
  23.  
  24. carry = (strength * 20) + (strength * 20 * modifier)
  25. print(f'{strength} can carry {carry:.0f} pounds')
  26.  
  27.  
  28. if __name__ == '__main__':
  29. print('for every 5 over 30:')
  30. for_every_five_over_30()
  31.  
  32. print('for every over 30:')
  33. for_every_over_30()
  34.  
Success #stdin #stdout 0.02s 9060KB
stdin
Standard input is empty
stdout
for every 5 over 30:
29 can carry 580 pounds
30 can carry 600 pounds
31 can carry 620 pounds
32 can carry 640 pounds
33 can carry 660 pounds
34 can carry 680 pounds
35 can carry 910 pounds
36 can carry 720 pounds
37 can carry 740 pounds
38 can carry 760 pounds
39 can carry 780 pounds
40 can carry 1040 pounds
41 can carry 820 pounds
42 can carry 840 pounds
43 can carry 860 pounds
44 can carry 880 pounds
45 can carry 1170 pounds
46 can carry 920 pounds
47 can carry 940 pounds
48 can carry 960 pounds
49 can carry 980 pounds
50 can carry 1300 pounds
51 can carry 1020 pounds
for every over 30:
29 can carry 580 pounds
30 can carry 600 pounds
31 can carry 620 pounds
32 can carry 640 pounds
33 can carry 660 pounds
34 can carry 680 pounds
35 can carry 910 pounds
36 can carry 936 pounds
37 can carry 962 pounds
38 can carry 988 pounds
39 can carry 1014 pounds
40 can carry 1280 pounds
41 can carry 1312 pounds
42 can carry 1344 pounds
43 can carry 1376 pounds
44 can carry 1408 pounds
45 can carry 1710 pounds
46 can carry 1748 pounds
47 can carry 1786 pounds
48 can carry 1824 pounds
49 can carry 1862 pounds
50 can carry 2200 pounds
51 can carry 2244 pounds