hey,
I'm a newbie in the programming world.
I just started and already I'm in a whole lot of problems.
first problem is the fact that I started out with a little program who was
part of a course but the problem is when I launch the program. I don't have
the time to see the result because the screen closes immediately.
Can anyone explain what's happening.
thanks in advance
me,
# Een bedrag gepast betalen met zo min mogelijk euromunten
bedrag = input ( 'Geef bedrag tussen 0 en 500 eurocent: ' )
for munt in 200, 100, 50, 20, 10, 5, 2, 1 :
aantal = 0
while bedrag >= munt :
aantal = aantal + 1
bedrag = bedrag - munt
if aantal > 0 :
print aantal, 'x', munt
[Python] python newbie
| Tweet |
|
Search Discussions
-
Rene Pijlman at Jan 8, 2004 at 10:56 pm ⇧
broebel:first problem is the fact that I started out with a little program who wasThe program started, did what it had to do and then terminated :-)
part of a course but the problem is when I launch the program. I don't have
the time to see the result because the screen closes immediately.
Can anyone explain what's happening.
"1 How do I run a Python program under Windows?"
http://www.python.org/doc/faq/windows.html#how-do-i-run-a-python-program-under-windows
--
Ren? Pijlman -
D at Jan 8, 2004 at 11:01 pm ⇧
http://www.python.org/doc/faq/windows.html#how-do-i-run-a-python-program-under-windowsRene Pijlman wrote:
broebel:first problem is the fact that I started out with a little program who wasThe program started, did what it had to do and then terminated :-)
part of a course but the problem is when I launch the program. I don't
have the time to see the result because the screen closes immediately.
Can anyone explain what's happening.
"1 How do I run a Python program under Windows?"
>
Worked fine for me on Linux... made two suggested changes: 1) use
raw_input(), not input(), 2) check user input for errors. Sorry, I don't
know how to say "Enter a number between 0 and 500" in whatever language
this is in (German?)
#!/usr/bin/env python
while 1:
bedrag = raw_input ( 'Geef bedrag tussen 0 en 500 eurocent: ' )
try:
bedrag = int( bedrag )
except ValueError:
print "Enter a number between 0 and 500"
else:
if bedrag < 0 or bedrag > 500:
print "Enter a number between 0 and 500"
else:
break
for munt in 200, 100, 50, 20, 10, 5, 2, 1 :
aantal = 0
while bedrag >= munt :
aantal = aantal + 1
bedrag = bedrag - munt
if aantal > 0 :
print aantal, 'x', munt--
/d/ -
Notice: Undefined variable: pl_u_link_beg in /home/whirl/sites/grokbase/root/www/public_html__www/cc/flow/tpc.php on line 831
Notice: Undefined variable: pl_u_link_end in /home/whirl/sites/grokbase/root/www/public_html__www/cc/flow/tpc.php on line 831
Notice: Undefined variable: pl_u_link_beg2 in /home/whirl/sites/grokbase/root/www/public_html__www/cc/flow/tpc.php on line 833
Joe Francia
Notice: Undefined variable: pl_u_link_end in /home/whirl/sites/grokbase/root/www/public_html__www/cc/flow/tpc.php on line 833
at Jan 9, 2004 at 6:21 am ⇧
You're a Python user and you don't recognize Dutch?!?! For shame... ;>)d wrote:
Worked fine for me on Linux... made two suggested changes: 1) use
raw_input(), not input(), 2) check user input for errors. Sorry, I don't
know how to say "Enter a number between 0 and 500" in whatever language
this is in (German?)
-
Djw at Jan 9, 2004 at 8:42 pm ⇧
Well, I was only off by one country - not too bad for someone who took 4Joe Francia wrote:
d wrote:Worked fine for me on Linux... made two suggested changes: 1) useYou're a Python user and you don't recognize Dutch?!?! For shame... ;>)
raw_input(), not input(), 2) check user input for errors. Sorry, I don't
know how to say "Enter a number between 0 and 500" in whatever language
this is in (German?)
years of high school Spanish and can hardly speak a word of it.
I was looking at the code that I proposed to the OP, and wondered if this
wasn't better:
#!/usr/bin/env python
while 1:
bedrag = raw_input ( 'Geef bedrag tussen 0 en 500 eurocent: ' )
try:
bedrag = int( bedrag )
if bedrag < 0 or bedrag > 500:
raise ValueError
except ValueError:
print "Enter a number between 0 and 500" # In DUTCH, of course!
else:
break
# ... etc.
Is this good style, that is, to put multiple items inside a single try:
except: else: block? Seems more compact and tidy than my first try.
-d
-
Broebel at Jan 10, 2004 at 3:30 pm ⇧
Just like you don't speak dutch, I don't write python (that's a good reason
to learn, isn't it) so I'm not trying out your proposal to see wheather it
works or not.
I kept it aside to check as soon as I understand more of the language. So
thanks any way.
btw is there a special reason why someone should speak dutch to programm in
python.?
"djw" <donald.welch.nospam at hp.com> schreef in bericht
news:3fff1245 at usenet01.boi.hp.com...Joe Francia wrote:don'td wrote:Worked fine for me on Linux... made two suggested changes: 1) use
raw_input(), not input(), 2) check user input for errors. Sorry, IWell, I was only off by one country - not too bad for someone who took 4know how to say "Enter a number between 0 and 500" in whatever languageYou're a Python user and you don't recognize Dutch?!?! For shame... ;>)
this is in (German?)
years of high school Spanish and can hardly speak a word of it.
I was looking at the code that I proposed to the OP, and wondered if this
wasn't better:
#!/usr/bin/env python
while 1:
bedrag = raw_input ( 'Geef bedrag tussen 0 en 500 eurocent: ' )
try:
bedrag = int( bedrag )
if bedrag < 0 or bedrag > 500:
raise ValueError
except ValueError:
print "Enter a number between 0 and 500" # In DUTCH, of course!
else:
break
# ... etc.
Is this good style, that is, to put multiple items inside a single try:
except: else: block? Seems more compact and tidy than my first try.
-d -
Francis Avila at Jan 10, 2004 at 4:15 pm ⇧
broebel wrote in message <400018e8$0$294$ba620e4c at news.skynet.be>...Just like you don't speak dutch, I don't write python (that's a good reasonGuido van Rossum created Python, and is currently its BDFL (Benevolent
to learn, isn't it) so I'm not trying out your proposal to see wheather it
works or not.
I kept it aside to check as soon as I understand more of the language. So
thanks any way.
btw is there a special reason why someone should speak dutch to programm in
python.?
Dictator For Life). He's Dutch. It's a sort of an inside joke that Python
makes sense if you're dutch (type 'import this' into an interactive Python
prompt).--
Francis Avila -
Gerrit Holl at Jan 10, 2004 at 4:57 pm ⇧
So he'r really the VDVL, Verlichte Despoot Voor het Leven :)Francis Avila wrote:
Guido van Rossum created Python, and is currently its BDFL (Benevolent
Dictator For Life). He's Dutch. It's a sort of an inside joke that Python
makes sense if you're dutch (type 'import this' into an interactive Python
prompt).
Shouldn't the Zen of Python be translated?
De Zen van Python, door Tim Peters
vrij vertaald door ondergetekende
Mooi is beter dan lelijk.
Expliciet is beter dan impliciet.
Simpel is beter dan complex.
Complex is beter dan gecompliceerd.
Plat is beter dan genest.
Dun bezaaid is beter dan dicht bezaaid.
Leesbaarheid telt.
Speciale gevallen zijn niet speciaal genoeg om de regels te overtreden.
Maar de praktijk gaat voor de zuiverheid.
Foutmeldingen horen nooit genegeerd worden.
Behalve expliciet.
Weersta de verleiding tot raden bij onduidelijkheden.
Er hoort een - bij voorkeur slechts een - duidelijke oplossing te zijn.
Maar die lijkt misschien niet meteen duidelijk voor niet-Nederlanders.
Beter nu dan nooit.
Maar vaak is nooit beter dan *nu meteen*.
Als het moeilijk is uit te leggen, is het een slecht idee.
Als het makkelijk is uit te leggen, is het misschien een goed idee.
Namespaces zijn een ... goed idee -- daar doen we er meer van!
groetjes,
Gerrit :).
--
185. If a man adopt a child and to his name as son, and rear him, this
grown son can not be demanded back again.
-- 1780 BC, Hammurabi, Code of Law
--
PrePEP: Builtin path type
http://people.nl.linux.org/~gerrit/creaties/path/pep-xxxx.html
Asperger's Syndrome - a personal approach:
http://people.nl.linux.org/~gerrit/english/ -
Broebel at Jan 9, 2004 at 8:54 am ⇧
as answered by d,
this is dutch
but thanks this how-to is really interesting
"d" <dwelch at localhost.localdomain> schreef in bericht
news:UilLb.1570$nt4.1692 at attbi_s51...Rene Pijlman wrote:wasbroebel:first problem is the fact that I started out with a little program whohttp://www.python.org/doc/faq/windows.html#how-do-i-run-a-python-program-undpart of a course but the problem is when I launch the program. I don'tThe program started, did what it had to do and then terminated :-)
have the time to see the result because the screen closes immediately.
Can anyone explain what's happening.
"1 How do I run a Python program under Windows?"
er-windowsWorked fine for me on Linux... made two suggested changes: 1) use
raw_input(), not input(), 2) check user input for errors. Sorry, I don't
know how to say "Enter a number between 0 and 500" in whatever language
this is in (German?)
#!/usr/bin/env python
while 1:
bedrag = raw_input ( 'Geef bedrag tussen 0 en 500 eurocent: ' )
try:
bedrag = int( bedrag )
except ValueError:
print "Enter a number between 0 and 500"
else:
if bedrag < 0 or bedrag > 500:
print "Enter a number between 0 and 500"
else:
break
for munt in 200, 100, 50, 20, 10, 5, 2, 1 :
aantal = 0
while bedrag >= munt :
aantal = aantal + 1
bedrag = bedrag - munt
if aantal > 0 :
print aantal, 'x', munt
--
/d/ -
Broebel at Jan 9, 2004 at 8:53 am ⇧
thanks
"Rene Pijlman" <reply.in.the.newsgroup at my.address.is.invalid> schreef in
bericht news:5unrvv8u1vpske1j464epj4aff0f54k2nf at 4ax.com...broebel:wasfirst problem is the fact that I started out with a little program whohavepart of a course but the problem is when I launch the program. I don'thttp://www.python.org/doc/faq/windows.html#how-do-i-run-a-python-program-undthe time to see the result because the screen closes immediately.The program started, did what it had to do and then terminated :-)
Can anyone explain what's happening.
"1 How do I run a Python program under Windows?"
er-windows--
Ren? Pijlman -
Anthony Borla at Jan 9, 2004 at 5:44 am ⇧
"broebel" <computer.problemen at skynet.be> wrote in message
news:3ffddcfd$0$16662$ba620e4c at news.skynet.be...hey,And you'll probably experience a whole host more - welcome to the wonderful
I'm a newbie in the programming world.
I just started and already I'm in a whole lot of problems.
world of programming ;) !!!first problem is the fact that I started out with a little program<SNIP CODE>
who was part of a course but the problem is when I launch
the program. I don't have the time to see the result because
the screen closes immediately.
Can anyone explain what's happening.
You are obviously not launching the interpreter from a console window. Thus,
launching the interpreter forces a new console window to be opened, your
program executes, and it then closes because it has finished.
Possible remedies allowing you to view your program's output:
* Launch interpreter as you have been doing, but add a line
such as:
raw_input("Press a key to continue ")
at the end of your code to prompt for a key press before
exiting, and closing the console window
* Start using the intepreter from a console window i.e. start
using the command line. All generated output will appear
on the same console.
Since you are in a course [?] I'd recommend asking your
instructor about suitable tutorials for doing this
I hope this helps.
Anthony Borla
-
Broebel at Jan 9, 2004 at 8:57 am ⇧
thanks anthony,
that's what I really wanted to know.
"Anthony Borla" <ajborla at bigpond.com> schreef in bericht
news:9drLb.2088$Wa.188 at news-server.bigpond.net.au..."broebel" <computer.problemen at skynet.be> wrote in message
news:3ffddcfd$0$16662$ba620e4c at news.skynet.be...hey,And you'll probably experience a whole host more - welcome to the wonderful
I'm a newbie in the programming world.
I just started and already I'm in a whole lot of problems.
world of programming ;) !!!first problem is the fact that I started out with a little program<SNIP CODE>
who was part of a course but the problem is when I launch
the program. I don't have the time to see the result because
the screen closes immediately.
Can anyone explain what's happening.
You are obviously not launching the interpreter from a console window. Thus,
launching the interpreter forces a new console window to be opened, your
program executes, and it then closes because it has finished.
Possible remedies allowing you to view your program's output:
* Launch interpreter as you have been doing, but add a line
such as:
raw_input("Press a key to continue ")
at the end of your code to prompt for a key press before
exiting, and closing the console window
* Start using the intepreter from a console window i.e. start
using the command line. All generated output will appear
on the same console.
Since you are in a course [?] I'd recommend asking your
instructor about suitable tutorials for doing this
I hope this helps.
Anthony Borla
Related Discussions
Discussion Navigation
| view | thread | post |
Discussion Overview
| group | python-list |
| categories | python |
| posted | Jan 8, '04 at 10:50p |
| active | Jan 10, '04 at 4:57p |
| posts | 12 |
| users | 8 |
| website | python.org |
