Python Forum
Homework that displays different weights
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homework that displays different weights
#2
drop the else and code after, then add 1 to high .. so you get:
a = 'Pounds'
b = 'Ounces'
c = 'Kilograms'

low = int(input('Enter a low value:'))
high = int(input('Enter a high value:'))
step = int(input('Enter a step value:'))

print('{0:<10}{1:^10}{2:>10}'.format(a, b, c))

for weight in range(low, high+1, step):
    print('{0:<10.1f}{1:^10.1f}{2:>10.1f}'.format(weight, weight * 16, weight * 453.592))
test:
Output:
Enter a low value:1 Enter a high value:10 Enter a step value:1 Pounds      Ounces   Kilograms 1.0          16.0        453.6 2.0          32.0        907.2 3.0          48.0       1360.8 4.0          64.0       1814.4 5.0          80.0       2268.0 6.0          96.0       2721.6 7.0         112.0       3175.1 8.0         128.0       3628.7 9.0         144.0       4082.3 10.0        160.0       4535.9 Enter a low value:1 Enter a high value:100 Enter a step value:10 Pounds      Ounces   Kilograms 1.0          16.0        453.6 11.0        176.0       4989.5 21.0        336.0       9525.4 31.0        496.0      14061.4 41.0        656.0      18597.3 51.0        816.0      23133.2 61.0        976.0      27669.1 71.0        1136.0     32205.0 81.0        1296.0     36741.0 91.0        1456.0     41276.9
Reply


Messages In This Thread
RE: Homework that displays different weights - by Larz60+ - Oct-20-2017, 06:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  traverses directory recursively and displays files Prani05 7 3,484 Apr-30-2020, 10:25 AM
Last Post: snippsat
  Program that displays the number with the greatest amount of factors ilusmd 3 2,895 Nov-01-2018, 08:28 PM
Last Post: ichabod801
  Creating a variable that displays time groovydingo 3 2,980 Apr-17-2018, 04:46 AM
Last Post: tannishpage

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020