473,325 Members | 2,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

very very basic question

hi guys,
this would be the most basic question ever...I am not a programmer but
I am trying to learn programming in python...I was reading John Zelle's
text book and instructed me to make .py file and save it on the desk
top...then it said close the python GUI and double click on the icon of
the I just made and that should run the program...well, the good news
is that it does but when I input a number for calculation and press the
enter key the program closes...Does any one know what the problem is?

thanx a bunch
andy

Apr 2 '06 #1
6 1217
aghazalp wrote:
hi guys,
this would be the most basic question ever...I am not a programmer but
I am trying to learn programming in python...I was reading John Zelle's
text book and instructed me to make .py file and save it on the desk
top...then it said close the python GUI and double click on the icon of
the I just made and that should run the program...well, the good news
is that it does but when I input a number for calculation and press the
enter key the program closes...Does any one know what the problem is?


The DOS box closes as soon as the program terminates. To prevent that, add
a call to raw_input() at the end of your script. Python will then prompt you
for input, and therefore the window will stay open.

Georg
Apr 2 '06 #2
thanx george for the prompt answer... when you say add a call that
means what exactly?...here is the program I was supposed to
write...could you tell me what to add where in this program?

def main():
print "this program is crazy"
x=input ('enter a number betwenen 0 and 1: ')
for i range (10)
x=3.9*x*(1-x)
print x

main()
thanx again

Apr 2 '06 #3
aghazalp wrote:
thanx george for the prompt answer... when you say add a call that
means what exactly?...here is the program I was supposed to
write...could you tell me what to add where in this program?

def main():
print "this program is crazy"
x=input ('enter a number betwenen 0 and 1: ')
for i range (10)
x=3.9*x*(1-x)
print x

main()


At the very end of the program, that is here, after main(), just insert

raw_input()

Georg
Apr 2 '06 #4
thanx ...it works great now...you re awesome...the only thing is that
the program only executes once though...I guess I ll have to read up
more anout it but for now that helped me a lot...I appreciated the help

Apr 2 '06 #5
aghazalp wrote:
thanx ...it works great now...you re awesome...the only thing is that
the program only executes once though...I guess I ll have to read up
more anout it but for now that helped me a lot...I appreciated the help


It only executes once because you only call it once.

Your program:

def main():
print "this program is crazy"
x=input ('enter a number betwenen 0 and 1: ')
for i range (10)
x=3.9*x*(1-x)
print x

main()

Change to something like:

def main():
print "this program is crazy"
while 1:
x=input ('enter a number between 0 and 1 [-1 to exit]: ')
if x == -1: break
for i range (10)
x=3.9*x*(1-x)
print x

main()
-Larry Bates
Apr 2 '06 #6
WOWWWWWWWW Larry
that was very very smart...it works perfectly =)

Apr 2 '06 #7

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

Similar topics

9
by: Tom | last post by:
Hey all, I've been planning to get myself started with DocBook for quite some time now, so when I unexpectedly encountered a task for which DocBook might actually be very useful, I thought I'd...
30
by: Vla | last post by:
why did the designers of c++ think it would be more useful than it turned out to be?
5
by: Lee David | last post by:
I went to the sun site and downloaded what I hope is the development part of java. I downloaded JDK5 with Netbeans. I installed it and now have a folder in my program group "Netbeans". Is that...
10
by: Jason Curl | last post by:
Greetings, I have an array of 32 values. This makes it extremely fast to access elements in this array based on an index provided by a separate enum. This array is defined of type "unsigned long...
6
by: msnews.microsoft.com | last post by:
Hello All, I am very new to ASP.NET and I have a basic question. Can somebody please explain? I have an .aspx Web Page with a textbox control. When the Page initially loads I am calling a...
8
by: pamelafluente | last post by:
Hi, I would like to get some advice. I know enough vb.net on win apps, but I have never worked on web applications and asp.net. I would appreciate if you could indicate the most basic...
17
by: blueapricot416 | last post by:
This is a very basic question -- but I can't find the answer after looking for 20 minutes. If you code something like: function set_It() { setTimeout('Request_Complete("apple", -72)',5000) }...
7
by: Bruno43 | last post by:
Hi I am trying to learn Visual Basic and I am getting everything for the most part, mainly because of my ability to read code like a book, but my question is what is the best way to Navigate through...
56
by: mdh | last post by:
As I begin to write more little programs without the help of the exercises, little things pop up that I need to understand more fully. Thus, below, and although this is not the exact code, the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.