python - How do i move all the numbers to allign with the columns -
python - How do i move all the numbers to allign with the columns -
canoeing = 3.5068 hiking = 6 roller_blading = 7.5068 tae_kwon_do = 10.3014 tai_chi = 3 body_mass = float(input("enter body mass: ")) canoeing = 0 hiking = 0 roller_blading = 0 tae_kwon_do = 0 tai_chi = 0 print(" canoeing hiking rollerblading tae kwon tai chi ") print("15") print("30") print("45") print("60") print("75") print("90") x in range(15,95,15): canoeing = canoeing+body_mass+(x/60) + canoeing hiking = hiking+body_mass+(x/60) + hiking roller_blading = roller_blading+body_mass+(x/60) + roller_blading tae_kwon_do = tae_kwon_do+body_mass+(x/60) + tae_kwon_do tai_chi = tai_chi+body_mass+(x/60) + tai_chi print("{0:>31.2f}".format(canoeing)) print("{0:>36.2f}".format(hiking)) print("{0:>51.2f}".format(roller_blading)) print("{0:>61.2f}".format(tae_kwon_do)) print("{0:>71.2f}".format(tai_chi))
how align answers columns ie, hiking , times 15 min. did answers come messed up.
you can print left-to-right, top-to-bottom. can't print row headers first, , print of data; have print each row headers along data.
also, each of print
statements prints newline. need add together end=''
prevent that.
so, should started:
print(" canoeing hiking rollerblading tae kwon tai chi ") x in range(15,95,15): print('{0:>2}'.format(x), end='') canoeing = … … print("{0:>31.2f}".format(canoeing), end='') … print()
this still isn't going right because format widths much, much wider columns you're trying fit them into. (also, since header 115 characters wide, it's not going nice in typical 80x25 terminal window…) can prepare part yourself.
python python-3.x
Comments
Post a Comment