Velocity Reviews > Help w/ easy python problem

# Help w/ easy python problem

r2_r2@hotmail.com
Guest
Posts: n/a

 09-22-2005
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
Guest
Posts: n/a

 09-22-2005
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...

r2_r2@hotmail.com
Guest
Posts: n/a

 09-22-2005
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...

Tomasz Lisowski
Guest
Posts: n/a

 09-22-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) napisaÅ‚(a):
> 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...
>

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

Mikael Olofsson
Guest
Posts: n/a

 09-22-2005
(E-Mail Removed) wrote:
> 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?

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

bruno modulix
Guest
Posts: n/a

 09-22-2005
(E-Mail Removed) wrote:
> 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?
>

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 '(E-Mail Removed)'.split('@')])"