Stem and Leaf plots

Discussion in 'Python' started by Barney, Oct 13, 2010.

  1. Barney

    Barney

    Joined:
    Oct 13, 2010
    Messages:
    1
    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!
    Barney, Oct 13, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. duffy.paul@comcast.net

    Regular expression to match word given stem

    duffy.paul@comcast.net, Aug 25, 2006, in forum: Java
    Replies:
    4
    Views:
    1,056
    Paul D
    Aug 26, 2006
  2. Mark

    stem

    Mark, Sep 16, 2011, in forum: Java
    Replies:
    1
    Views:
    253
    Jeff Higgins
    Sep 16, 2011
  3. Wonjun, Choi

    how to draw stem, twig, leaf?

    Wonjun, Choi, Oct 30, 2011, in forum: C Programming
    Replies:
    3
    Views:
    651
    Jean-Christophe
    Oct 31, 2011
  4. Gerwin
    Replies:
    0
    Views:
    164
    Gerwin
    Feb 6, 2007
  5. Aaron

    URI Stem

    Aaron, Sep 18, 2006, in forum: Javascript
    Replies:
    5
    Views:
    239
    McKirahan
    Sep 20, 2006
Loading...

Share This Page