omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Chartz

    Pythonista
    2
    4
    1840
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • reefboy1
      reefboy1 last edited by

      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)
      
      
      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        Thanks for the dedication! It is more of a bar chart than a pie chart. A few ideas...

        # 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 pie ({}%): '.format(a))  or 'first'
        n2 = raw_input('Name your second pie ({}%): '.format(b)) or 'second'
        n3 = raw_input('Name your third pie ({}%): '.format(c))  or 'third'
        
        dividing_line = '| {} |'.format('-' * 36)
        fmt = '| {:>10} {:>3}% {:<20} |'
        print('\n' + 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)
        

        Output should look like this:

        Enter three percentage numbers that add up to 100%...
        
        Enter % 50
        Enter % 30
        Enter % 20
        Name your first pie (50%): won
        Name your second pie (30%): lost
        Name your third pie (20%): tied
        
        | ------------------------------------ |
        |        won  50% **********           |
        | ------------------------------------ |
        |       lost  30% ******               |
        | ------------------------------------ |
        |       tied  20% ****                 |
        | ------------------------------------ |
        
        1 Reply Last reply Reply Quote 0
        • reefboy1
          reefboy1 last edited by

          Oh! Sorry I'm only in elementary school xD! I got confused. Thanks for the help! Mind if I use this?

          1 Reply Last reply Reply Quote 0
          • ccc
            ccc last edited by

            Go ahead and use it. ;-)

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors