473,398 Members | 2,404 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,398 software developers and data experts.

error explanation

Could someone please explain this error message:

Traceback (most recent call last):
File "C:\Python23\time.py", line 1, in -toplevel-
time.py
NameError: name 'time' is not defined

I tried entering the following example:

time.py
#This programs calculates rate and distance problems
print "Input a rate and a distance"
rate = input("Rate:")
distance = input("Distance:")
print "Time:",distance/rate

which according to the tutor should have run as this:
python times.py

Input a rate and a distance
Rate:5
Distance:10
Time: 2
Thanks for your help
Jul 18 '05 #1
4 1634
On Monday 29 September 2003 02:45 pm, Mac Wood wrote:
Could someone please explain this error message:

Traceback (most recent call last):
File "C:\Python23\time.py", line 1, in -toplevel-
time.py
NameError: name 'time' is not defined

I tried entering the following example:

time.py
#This programs calculates rate and distance problems
print "Input a rate and a distance"
rate = input("Rate:")
distance = input("Distance:")
print "Time:",distance/rate

which according to the tutor should have run as this:
python times.py


Input a rate and a distance
Rate:5
Distance:10
Time: 2
Thanks for your help

The line "time.py" is not meant to be a python statement, but is the
name of the file whose contents are the succeeding lines. Once you
get the file named "time.py" with this contents

#This programs calculates rate and distance problems
print "Input a rate and a distance"
rate = input("Rate:")
distance = input("Distance:")
print "Time:",distance/rate

then you can run the file with
python time.py

Gary Herron

Jul 18 '05 #2
On 29 Sep 2003 14:45:44 -0700, rumours say that
ma***********@ntlworld.com (Mac Wood) might have written:
Could someone please explain this error message:

Traceback (most recent call last):
File "C:\Python23\time.py", line 1, in -toplevel-
time.py
NameError: name 'time' is not defined

I tried entering the following example:

time.py
#This programs calculates rate and distance problems
print "Input a rate and a distance"
rate = input("Rate:")
distance = input("Distance:")
print "Time:",distance/rate


remove the time.py line (it's supposed to name the following lines, not
to be included with them :)
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.
Jul 18 '05 #3
"Mac Wood" <ma***********@ntlworld.com> wrote in message
news:13**************************@posting.google.c om...
Could someone please explain this error message:

Traceback (most recent call last):
File "C:\Python23\time.py", line 1, in -toplevel-
time.py
NameError: name 'time' is not defined

I tried entering the following example:

time.py
#This programs calculates rate and distance problems
print "Input a rate and a distance"
rate = input("Rate:")
distance = input("Distance:")
print "Time:",distance/rate

which according to the tutor should have run as this:
python times.py

Input a rate and a distance
Rate:5
Distance:10
Time: 2
Thanks for your help


Try using raw_input() rather than input()

regards
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/

Jul 18 '05 #4
Steve Holden wrote:
Try using raw_input() rather than input()


That definitely will not work. That will just result in him trying to
preform arithmetic with strings instead of numerics.

--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \ The revolution will not televised
\__/ Public Enemy
Jul 18 '05 #5

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

Similar topics

10
by: r6uji7 | last post by:
hello, i am new to PHP programming and wondered if u could help. lets say i have the following files: 1. error.php: that is routed to for all errors. this page should display proper and...
5
by: xuatla | last post by:
Hi, I encountered the following compile error of c++ and hope to get your help. test2.cpp: In member function `CTest CTest::operator+=(CTest&)': test2.cpp:79: error: no match for 'operator='...
15
by: Ajay DSouza | last post by:
When I try to validate my page http://www.ajaydsouza.com/wordpress/wpthemes/ I get this: I got the following unexpected response when trying to retrieve...
1
by: Sean C. | last post by:
Helpful folks, I have recently migrated our test server, which runs Win NT 4, from V7.2 FP11 to V8.1.3. Just about everything works wondefully, except I am having major problems getting the...
5
by: mairhtin o'feannag | last post by:
Hello, <hiding from IBM contributors> Well, IBM have done it again! During an install of 8.1 to a new linux box, and ALWAYS in the same place (just after Set Instance Properties in a...
9
by: Peter Oliphant | last post by:
For some reson my code is generating a LNK1215 error, which 'suggests' I re-install VS C++. So I did. which did NOT solve the problem. The weid part is it seems to be caused by my one CPP file, but...
0
by: BGS | last post by:
I have a web site (www.on-the-matrix.com) that displays photos in a "slide show" format on ASPX pages that run in an inline frame on an ASP page (or in a separate pop-up window). The ASPX pages...
34
by: Rory Campbell-Lange | last post by:
>>(1.0/10.0) + (2.0/10.0) + (3.0/10.0) 0.60000000000000009 0.59999999999999998 Is using the decimal module the best way around this? (I'm expecting the first sum to match the second). It seem...
6
by: WolfgangS | last post by:
Ok first off, i am a total beginner at this groups stuff and i have no clue how this works. This is probabaly the wrong group for my problem but i will post it anyways. Learning by doing right? ...
9
by: Daniel Smedegaard Buus | last post by:
Hey all :) I was wondering about the $error_types (I particularly notice the 's' suffix when reading the manual) parameter for 'set_error_handler()': Can be used to mask the triggering of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.