reefboy1
Jan 28, 2015 - 02:18
This one is dedicated to ccc (I watched the EuroPython!) for all his
Help due to me being new and somewhat unsmart mistakes
This is my app that makes a chart
And is called Chartz
# PieMaker
# This simple thingymajigger (<- be careful that word is in no way professional)
# allows you to enter three % numbers and will make a bar chart.
print('Enter three percentage numbers that add up to 100%...\n')
a = raw_input('Enter % ') or '20' # 20 is the default value if user just presses enter
aPIE = int(a)
b = raw_input('Enter % ') or '30'
bPIE = int(b)
c = raw_input('Enter % ') or '50'
cPIE = int(c)
total = aPIE + bPIE + cPIE # make sure the three numbers add up to 100%
assert total == 100, '{} + {} + {} = {} != 100!'.format(a, b, c, total)
n1 = raw_input('Name your first bar ({}%): '.format(a)) or 'first'
n2 = raw_input('Name your second bar ({}%): '.format(b)) or 'second'
n3 = raw_input('Name your third bar ({}%): '.format(c)) or 'third'
print('')
dividing_line = '| {} |'.format('-' * 36)
fmt = '| {:>10} {:>3}% {:<20} |'
print(dividing_line)
stars = '*' * (aPIE / 5) # one star for every 5%
print(fmt.format(n1, a, stars))
print(dividing_line)
stars = '*' * (bPIE / 5)
print(fmt.format(n2, b, stars))
print(dividing_line)
stars = '*' * (cPIE / 5)
print(fmt.format(n3, c, stars))
print(dividing_line)