Hey guys I just recently got into programming, and Python is my first language. I'm trying to get a stem and leaf plot to show by using 3 functions stem_and_leaf(data) This is the function that actually produces the
plot
append_leaf(num) This takes a number (an int) and returns a leaf
(a str), which is the string version of the units digit of the int.
new_stem(num) This takes a number (an int) and returns everythin
but the last character, followed by a space and then a “pipe” (|)
character.
I've completed doing the 2nd two.
def stem_and_leaf(data):
def append_num(num):
append_last=str(num)
print ' ',append_last[-1]
def new_stem(num):
append_first= str(x)
print append_first[:-1], '|'
but when I put it together to print
new_stem(44)+append_num(45)
4 |
5
it adds an enter to the statement and thus make it look like its not a stem and leaf plot. Does anyone know whats going on? and any tips on starting the second half(putting a list through the main function and having a full fledged plot) would be immensly helpful!
Thanks!
plot
append_leaf(num) This takes a number (an int) and returns a leaf
(a str), which is the string version of the units digit of the int.
new_stem(num) This takes a number (an int) and returns everythin
but the last character, followed by a space and then a “pipe” (|)
character.
I've completed doing the 2nd two.
def stem_and_leaf(data):
def append_num(num):
append_last=str(num)
print ' ',append_last[-1]
def new_stem(num):
append_first= str(x)
print append_first[:-1], '|'
but when I put it together to print
new_stem(44)+append_num(45)
4 |
5
it adds an enter to the statement and thus make it look like its not a stem and leaf plot. Does anyone know whats going on? and any tips on starting the second half(putting a list through the main function and having a full fledged plot) would be immensly helpful!
Thanks!