Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Stem and Leaf plots

Reply
Thread Tools

Stem and Leaf plots

 
 
Barney Barney is offline
Junior Member
Join Date: Oct 2010
Posts: 1
 
      10-13-2010
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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to draw stem, twig, leaf? Wonjun, Choi C Programming 3 10-31-2011 11:58 AM
Installation of Lingua:Stem fails -> Lingua-Stem-Snowball-Da already installed... Gerwin Perl Misc 0 02-06-2007 11:55 AM
Regular expression to match word given stem duffy.paul@comcast.net Java 4 08-26-2006 03:52 PM
Stem Cell Research - Is it moral? Sparrow Digital Photography 150 11-14-2004 02:52 PM



Advertisments