Help w/ easy python problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • r2_r2@hotmail.com

    #1

    Help w/ easy python problem

    I am very much a beginner to python. I have been working on writing a
    very simple program and cannot get it and was hoping someone could help
    me out. Basically i need to write a code to print a sin curve running
    down the page from top to bottom. The trick is I have to do this using
    only 7-8 lines of code. Any ideas?

  • r2_r2@hotmail.com

    #2
    Re: Help w/ easy python problem

    Actually, it is not a sin curve i need to plot, it is dots running down
    the page in the shape of a sin curve like this

    ..

    Comment

    • r2_r2@hotmail.com

      #3
      Re: Help w/ easy python problem

      Actually, it is not a sin curve i need to plot, it is dots running down
      the page in the shape of a sin curve like this

      ..

      Comment

      • Tomasz Lisowski

        #4
        Re: Help w/ easy python problem

        r2_r2@hotmail.c om napisał(a):[color=blue]
        > Actually, it is not a sin curve i need to plot, it is dots running down
        > the page in the shape of a sin curve like this
        >
        > .
        > .
        > .
        > etc...
        >[/color]

        Seems, like a homework to me :-)

        Anyway, use the following hints:

        math.sin() is your sine function, ranging, from -1.0 to 1.0 inclusively
        set up a for loop printing the strings containing spaces, and one dot at
        the appropriate location with:
        - the appropriate argument increase step between the lines (print
        statements)
        - the appropriate scaling of the <-1.0, 1.0> range into e.g. <0, 71>,
        representing the 72 characters wide lines being printed.

        Tomasz Lisowski

        Comment

        • Mikael Olofsson

          #5
          Re: Help w/ easy python problem

          r2_r2@hotmail.c om wrote:[color=blue]
          > I am very much a beginner to python. I have been working on writing a
          > very simple program and cannot get it and was hoping someone could help
          > me out. Basically i need to write a code to print a sin curve running
          > down the page from top to bottom. The trick is I have to do this using
          > only 7-8 lines of code. Any ideas?[/color]


          This sounds like homework, and I think you should do that on your own.
          One hint, though: You could take a look at the standard module math.

          /MiO

          Comment

          • bruno modulix

            #6
            Re: Help w/ easy python problem

            r2_r2@hotmail.c om wrote:[color=blue]
            > I am very much a beginner to python. I have been working on writing a
            > very simple program and cannot get it and was hoping someone could help
            > me out. Basically i need to write a code to print a sin curve running
            > down the page from top to bottom. The trick is I have to do this using
            > only 7-8 lines of code. Any ideas?
            >[/color]
            Yes : do your homework yourself. When you'll run into trouble with
            *your* code, then post here for help.


            --
            bruno desthuilliers
            python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
            p in 'onurb@xiludom. gro'.split('@')])"

            Comment

            Working...