I'm not really sure if this is the right place or not for my questions, since i'm a complete noob when it comes to python and all. But its a real simple question, and help would be appreciated.
I've been reading "Python for Software Design: How to Think Like a Computer Scientist", and ive been following along pretty well. The only problem is when it came to trying out little command line expressions on integer division.
The book is talking about a script that goes

percentage = (minute * 100) / 60

, and when i punch it into the python shell it throws something like this at me

Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    percentage = (minute * 100) // 60
NameError: name 'minute' is not defined

I just wanted to know what the problem is; is it the interpreter that i'm using? (IDLE on *nix), I was planning self-educating myself on that (i thought python would go good with some shell script on my linux distro), but it's hard to learn it whenyou can't try out the commands yourself...

So, ya help would be appreciated.

Recommended Answers

All 2 Replies

In python, the interpreter will only be meek if you define a variable before you use it. It seems you try to use the variable before defining it. This is where the py Interpreter becomes harsh!

Oh ok, so the interperter doesn't know what "minute" is. And i guess the book didn't really define it yet either, just gotta read on. Thx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.