473,569 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?

Sep 22 '05 #1
5 1230
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

..
Sep 22 '05 #2
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

..
Sep 22 '05 #3
r2***@hotmail.c om 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
Sep 22 '05 #4
r2***@hotmail.c om 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
Sep 22 '05 #5
r2***@hotmail.c om 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 'o****@xiludom. gro'.split('@')])"
Sep 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2191
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to python-help, to point out a few resources that can help with answering your own questions, or improve the chances of getting a useful answer from the...
10
1932
by: Brendan | last post by:
Hi everyone I'm new to Python, so forgive me if the solution to my question should have been obvious. I have a function, call it F(x), which asks for two other functions as arguments, say A(x) and B(x). A and B are most efficiently evaluated at once, since they share much of the same math, ie, A, B = AB(x), but F wants to call them...
16
1838
by: rorley | last post by:
I'm new to Python and I'm struggling. I have a text file (*.txt) with a couple thousand entries, each on their own line (similar to a phone book). How do I make a script to create something like an inverted dictionary that will allow me to call "robert" and create a new text file of all of the lines that contain "robert"? Thanks so much.
12
1578
by: Ray | last post by:
Hello, I've got the chance to determine the technology to use in creating a product similar to this: http://www.atomicisland.com/ Now the thing is that I need to sell this to the guy with the money. I've developed for years with C++ and Java, last 7 years J2EE, and I'm kinda sick of the "bloated" feeling that the whole J2EE/appserver
3
6514
by: Lance Hoffmeyer | last post by:
Hey all, I'm new to python. I keep getting an error when running this. I'm sure there is an easy fix but I can't figure it out. What am I doing wrong? How do I fix it? def even_odd_round(num): if(round(num,2) + .5 == int(round(num,2)) + 1): if(int(num,0) % 2): #an odd number rounded_num = round(num,2) + .1
10
1714
by: stylecomputers | last post by:
Hey guys, I am absolutely new to Linux programming, with no w######s programming experience except a small amount of C++ console apps. Reasonably new to Linux, BSD etc, got good sound networking base of knowledge and dont have any problem working the command line etc. I want to learn a language that I can use in my networking duties that...
2
3401
by: Jon Smirl | last post by:
I only have a passing acquaintance with Python and I need to modify some existing code. This code is going to get called with 10GB of data so it needs to be fairly fast. http://cvs2svn.tigris.org/ is code for converting a CVS repository to Subversion. I'm working on changing it to convert from CVS to git. The existing Python RCS parser...
3
2914
by: aking | last post by:
Dear Python people, im a newbie to python and here...so hello! Im trying to iterate through values in a dictionary so i can find the closest value and then extract the key for that value....what ive done so far: def pcloop(dictionary, exvalue): z = dictionary.itervalues() y = z - exvalue
1
1220
by: Gabriel Genellina | last post by:
En Thu, 29 May 2008 06:29:00 -0300, <Dominique.Holzwarth@ch.delarue.com> escribió: You don't need setuptools at all. Just write a setup.py file using the standard distutils module, and execute: python setup.py bdist_wininst It will create an executable installer. A simple setup.py script looks
1
1963
by: zandrew | last post by:
Hello there everyone. For a summer project I'm doing, I have to use a phone to pass an image I've taken (on the phone) to a dedicated server I've made on a local ubuntu machine. For the upload code, I decided on python (seeing on how its easy to learn, and already on the phone), and for the server code I decided on PHP (that was also an easy...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.