473,394 Members | 1,721 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,394 software developers and data experts.

Total Python Noob

I have Python 2.6 installed on Vista Ultimate. When I try to calculate
sqrt (or any transcendental functions) I get the following error
>>sqrt(2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sqrt' is not defined

What am I doing wrong?

Tom Lake
Oct 10 '08 #1
3 1048
On Oct 9, 11:22*pm, "Tom Lake" <tl...@twcny.rr.comwrote:
I have Python 2.6 installed on Vista Ultimate. *When I try to calculate
sqrt (or any transcendental functions) I get the following error
>sqrt(2)

Traceback (most recent call last):
* File "<stdin>", line 1, in <module>
NameError: name 'sqrt' is not defined

What am I doing wrong?

Tom Lake
do 'from math import sqrt' first

or try '2**0.5'
Oct 10 '08 #2
On Thu, Oct 9, 2008 at 11:22 PM, Tom Lake <tl***@twcny.rr.comwrote:
I have Python 2.6 installed on Vista Ultimate. When I try to calculate
sqrt (or any transcendental functions) I get the following error
>>>sqrt(2)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sqrt' is not defined

What am I doing wrong?
They're not buitltin, they're in the 'math' module
(http://docs.python.org/library/math.html#module-math), which you need
to import.
e.g.
import math
print math.sqrt(4)

Please also Read the Fine Tutorial at:
http://docs.python.org/tutorial/index.html

Cheers,
Chris
--
Follow the path of the Iguana...
http://rebertia.com
>
Tom Lake --
http://mail.python.org/mailman/listinfo/python-list
Oct 10 '08 #3
"Chris Rebert" <cl*@rebertia.comwrote in message
news:ma**************************************@pyth on.org...
On Thu, Oct 9, 2008 at 11:22 PM, Tom Lake <tl***@twcny.rr.comwrote:
>I have Python 2.6 installed on Vista Ultimate. When I try to calculate
sqrt (or any transcendental functions) I get the following error
>>>>sqrt(2)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'sqrt' is not defined

What am I doing wrong?

They're not buitltin, they're in the 'math' module
(http://docs.python.org/library/math.html#module-math), which you need
to import.
e.g.
import math
print math.sqrt(4)

Please also Read the Fine Tutorial at:
http://docs.python.org/tutorial/index.html
Great! Thanks so much!

Tom Lake

Oct 10 '08 #4

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

Similar topics

8
by: Darren Dale | last post by:
Is there a place to put python programs so I dont have to refer to the absolute path everytime I want to call them? For example: if I am in /home/me and want to execute: python...
3
by: digitalsubjunctive | last post by:
Hey, I just started on Python and have a few questions I couldn't find answers to on the Python site or it's tutorial. 1. I notice a few "compiled python" files (indicated by reddish snake...
9
by: Dieter Vanderelst | last post by:
Dear all, I'm currently comparing Python versus Perl to use in a project that involved a lot of text processing. I'm trying to determine what the most efficient language would be for our...
5
by: lofty | last post by:
Hi, I'm building a time report system for work and I want to show the total hours and minutes a project have taken but can't get it to work ... I have a database (MySQL) in one table I have...
0
by: M.-A. Lemburg | last post by:
On 2008-05-12 07:43, Banibrata Dutta wrote: Most Python database modules adhere to the Python Database API specification (DB-API). The current version 2 is available in the PEP format as: ...
8
by: Derek Martin | last post by:
I'd like to know if it's possible to code something in Python which would be equivalent to the following C: ---- debug.c ---- #include <stdio.h> bool DEBUG;
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.