I am building a program for the quadratic formula but it won't execute the sqrt command. I assume that I need the math modual but don't know how to import it. Please help.
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Python noob: how to import math modual
Featured Sponsors
Recent Reviews
-
Wow, I'm quite surprised that I am the first one to review this monitor. I probably won't be able to get all technical with this review, but I would like to write out what makes this a great...
-
I remember the first time I set my eyes on the Silverstone TJ07. It was like looking A PC Tower that screamed quality and versatility! The case is very light, unlike other full tower cases. Thumbs...
-
I had this case for a good while and it was such a joy. Everyone that saw my computer called it "The Tank" because they loved the beefy looks of it. I found the case to be very easy to work with...
-
I run 2 of these in my Quad-SLI rig. 0 coil whine... Software has worked well for me, not without "some" problems but, not a bad experience, either. When I called in about my issues (I purchased...
-
Okay. So I am kind of a nerd for finding computer cases and what I think looks good and matches peripherals and such. Many people don't pay attention to these things but I happen to and I'm glad I...
Python noob: how to import math modual
post #2 of 7
5/20/12 at 1:14am
For importing the "math" module in Python or any other module for that matter, all you have to include in your code before you wish to execute one of its functions is,
In this case,
Code:
import <module-name>
In this case,
Code:
import math
Toshiba Satellite L655
(13 items) |
Desktop
(13 items) |
MacBook Pro 13"
(6 items) |
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 480m@2.67GHz | AMD Radeon Mobility 5650 | 4GB DDR3 | 500GB |
| OS | Monitor | ||
| Windows 7 64bit HP | 15.6" 1366x768 | ||
| View all | |||
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| E7500 | Intel...:( | MSI GTS250 1GB | 2GB |
| Hard Drive | OS | Monitor | Power |
| 250GB | Windows XP | 17" LG CRT 1280x768@85hz | 400W |
| View all | |||
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 @ 2.5 GHz | Intel HD4000 | 4 GB DDR3 @ 1600 MHz | 500 GB @ 5400 RPM |
| OS | Monitor | ||
| OSX Lion | 13.3" @ 1280 x 800 | ||
| View all | |||
Toshiba Satellite L655
(13 items) |
Desktop
(13 items) |
MacBook Pro 13"
(6 items) |
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 480m@2.67GHz | AMD Radeon Mobility 5650 | 4GB DDR3 | 500GB |
| OS | Monitor | ||
| Windows 7 64bit HP | 15.6" 1366x768 | ||
| View all | |||
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| E7500 | Intel...:( | MSI GTS250 1GB | 2GB |
| Hard Drive | OS | Monitor | Power |
| 250GB | Windows XP | 17" LG CRT 1280x768@85hz | 400W |
| View all | |||
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 @ 2.5 GHz | Intel HD4000 | 4 GB DDR3 @ 1600 MHz | 500 GB @ 5400 RPM |
| OS | Monitor | ||
| OSX Lion | 13.3" @ 1280 x 800 | ||
| View all | |||
- Joined: Feb 2012
- Location: East Cost
- Posts: 345
- Rep: 4 (Unique: 4)
- Trader Rating: 1
- Select All Posts By This User
I put import math at the top of my program yet it still only says sqrt is not defined.
last gen
(11 items) |
late 2009 macbook pro
(4 items) |
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| Intel I7 930 | Asus P6x58d-p | XFX Radeon 6870 Double Dissipation | corsair xms3 |
| Hard Drive | Cooling | OS | Keyboard |
| OCZ agility 3 | Coolermaster Hyper 212+ | Win 7 pro 64 bit | cherry mx 8100 |
| Power | Case | Mouse | |
| kingwin 750w | open air | razer naga 2011 | |
| View all | |||
| CPU | Motherboard | RAM | OS |
|---|---|---|---|
| core 2 duo | apple logic board | 4 gb | mac osX |
| View all | |||
last gen
(11 items) |
late 2009 macbook pro
(4 items) |
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| Intel I7 930 | Asus P6x58d-p | XFX Radeon 6870 Double Dissipation | corsair xms3 |
| Hard Drive | Cooling | OS | Keyboard |
| OCZ agility 3 | Coolermaster Hyper 212+ | Win 7 pro 64 bit | cherry mx 8100 |
| Power | Case | Mouse | |
| kingwin 750w | open air | razer naga 2011 | |
| View all | |||
| CPU | Motherboard | RAM | OS |
|---|---|---|---|
| core 2 duo | apple logic board | 4 gb | mac osX |
| View all | |||
post #4 of 7
5/20/12 at 4:18am
You may not be using the correct syntax to use the sqrt function. If you want to find the square root of 4, you should have in your code,
.
Code:
math.sqrt(4)
Toshiba Satellite L655
(13 items) |
Desktop
(13 items) |
MacBook Pro 13"
(6 items) |
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 480m@2.67GHz | AMD Radeon Mobility 5650 | 4GB DDR3 | 500GB |
| OS | Monitor | ||
| Windows 7 64bit HP | 15.6" 1366x768 | ||
| View all | |||
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| E7500 | Intel...:( | MSI GTS250 1GB | 2GB |
| Hard Drive | OS | Monitor | Power |
| 250GB | Windows XP | 17" LG CRT 1280x768@85hz | 400W |
| View all | |||
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 @ 2.5 GHz | Intel HD4000 | 4 GB DDR3 @ 1600 MHz | 500 GB @ 5400 RPM |
| OS | Monitor | ||
| OSX Lion | 13.3" @ 1280 x 800 | ||
| View all | |||
Toshiba Satellite L655
(13 items) |
Desktop
(13 items) |
MacBook Pro 13"
(6 items) |
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 480m@2.67GHz | AMD Radeon Mobility 5650 | 4GB DDR3 | 500GB |
| OS | Monitor | ||
| Windows 7 64bit HP | 15.6" 1366x768 | ||
| View all | |||
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| E7500 | Intel...:( | MSI GTS250 1GB | 2GB |
| Hard Drive | OS | Monitor | Power |
| 250GB | Windows XP | 17" LG CRT 1280x768@85hz | 400W |
| View all | |||
| CPU | Graphics | RAM | Hard Drive |
|---|---|---|---|
| Intel i5 @ 2.5 GHz | Intel HD4000 | 4 GB DDR3 @ 1600 MHz | 500 GB @ 5400 RPM |
| OS | Monitor | ||
| OSX Lion | 13.3" @ 1280 x 800 | ||
| View all | |||
post #5 of 7
5/20/12 at 4:20am
- fkjac
- *cough* Stock *cough*
- Joined: May 2012
- Location: Denmark
- Posts: 66
- Rep: 5 (Unique: 5)
- Select All Posts By This User
- Joined: Feb 2012
- Location: East Cost
- Posts: 345
- Rep: 4 (Unique: 4)
- Trader Rating: 1
- Select All Posts By This User
Ohhhhh! Ok I get it now! Thanks guys. Rep+ for you two
last gen
(11 items) |
late 2009 macbook pro
(4 items) |
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| Intel I7 930 | Asus P6x58d-p | XFX Radeon 6870 Double Dissipation | corsair xms3 |
| Hard Drive | Cooling | OS | Keyboard |
| OCZ agility 3 | Coolermaster Hyper 212+ | Win 7 pro 64 bit | cherry mx 8100 |
| Power | Case | Mouse | |
| kingwin 750w | open air | razer naga 2011 | |
| View all | |||
| CPU | Motherboard | RAM | OS |
|---|---|---|---|
| core 2 duo | apple logic board | 4 gb | mac osX |
| View all | |||
last gen
(11 items) |
late 2009 macbook pro
(4 items) |
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| Intel I7 930 | Asus P6x58d-p | XFX Radeon 6870 Double Dissipation | corsair xms3 |
| Hard Drive | Cooling | OS | Keyboard |
| OCZ agility 3 | Coolermaster Hyper 212+ | Win 7 pro 64 bit | cherry mx 8100 |
| Power | Case | Mouse | |
| kingwin 750w | open air | razer naga 2011 | |
| View all | |||
| CPU | Motherboard | RAM | OS |
|---|---|---|---|
| core 2 duo | apple logic board | 4 gb | mac osX |
| View all | |||
post #7 of 7
6/13/12 at 8:13pm
Alternatively if you wanted to do just
You could do it this way:
But ONLY sqrt will be imported and no other function.
Code:
sqrt(25)
You could do it this way:
Code:
from math import sqrt
sqrt(25)
But ONLY sqrt will be imported and no other function.
Back in Black
(13 items) |
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| AMD Phenom II X4 965 BE (C3) | Biostar TA790GX A3+ | Sapphire HD 5770 (v2) | CORSAIR XMS3 4GB DDR3 |
| Hard Drive | Optical Drive | OS | Monitor |
| WD Caviar Black 640GB | Sony Optiarc CD/DVD RW | Windows 7 Ultimate x64 | NEC MultiSync LCD 1960NXi |
| Keyboard | Power | Case | Mouse |
| Microsoft Comfort Curve Keyboard 2000 | Corsair 650TX | Cooler Master Storm Scout | Logitech MX 400 Laser |
| View all | |||
Back in Black
(13 items) |
| CPU | Motherboard | Graphics | RAM |
|---|---|---|---|
| AMD Phenom II X4 965 BE (C3) | Biostar TA790GX A3+ | Sapphire HD 5770 (v2) | CORSAIR XMS3 4GB DDR3 |
| Hard Drive | Optical Drive | OS | Monitor |
| WD Caviar Black 640GB | Sony Optiarc CD/DVD RW | Windows 7 Ultimate x64 | NEC MultiSync LCD 1960NXi |
| Keyboard | Power | Case | Mouse |
| Microsoft Comfort Curve Keyboard 2000 | Corsair 650TX | Cooler Master Storm Scout | Logitech MX 400 Laser |
| View all | |||
Return Home
Back to Forum: Application Programming
- Python noob: how to import math modual
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › Python noob: how to import math modual
Currently, there are 1677 Active Users
(418 Members and 1259 Guests)
Recent Discussions
- › (CNET) NEC's Media x smartphone is liquid cooled 52 seconds ago
- › [Bit tech] Aquatuning drops Ek from their shop. 1 minute ago
- › AMD Phenom II X4 965 OC 2 minutes ago
- › NVIDIA Publicly Announces the GeForce GTX 780 At GeForce E-Sports ... 2 minutes ago
- › TATH \ Caselabs TH 10 + Pedastel "Hill 7.9" 2 minutes ago
- › 3770K - My Overclock is it good? 2 minutes ago
- › SFF Blower Card 3 minutes ago
- › Logitech M100 - Worst POS ever! 3 minutes ago
- › AMD FX (Bulldozer / PILEDRIVER!) Owners Club! 5 minutes ago
- › How Clean Is Your Desktop? 5 minutes ago
View: New Posts | All Discussions
Recent Reviews
- › ASUS PB Series PB278Q 27"" 5ms (GTG) WQHD Widescreen LED... by R3apR369
- › SilverStone Aluminum Body ATX Full Tower Computer Case TJ07B -... by R3apR369
- › Cooler Master HAF 922 RC-922M-KKN1-GP Black Steel + Plastic and... by Steve1300
- › CORSAIR AX1200i 1200W Power Supply by Masked
- › Silverstone Tek Aluminum Mini ITX 140mm FanX1 USB3.0x2 3.5-Inchx1... by yancyv8
- › Xfx ProSeries 750W PSU by Ticklemehballlz
- › Logitech M310 Wireless Mouse (Blue Shards) by Mournful3ch0
- › Azio Headset GH808 Levetron USB Gaming Headset Retail by ViSioNx
- › Xigmatek Gaia SD1283 120mm Long Life Bearing CPU Cooler bracket... by ViSioNx
- › Cooler Master Storm Recon - Gaming Mouse with 4000 DPI Optical... by ViSioNx
View: More Reviews
New Articles
- › The CD/DVD Duplication Process by MichaelBurrows
- › Why are DNS Servers Important? How to make... by exzacklyright
- › Titanium Backup Guide For Newbies by exzacklyright
- › How to install ADB (Android Debug Bridge) by exzacklyright
- › How to take ownership of a file, folder, or... by exzacklyright
- › How to disable the open file security warning... by exzacklyright
- › Clean and Make a USB Bootable Flash Drive for... by exzacklyright
- › Do you Really Need Cell Phone Insurance by andyharris
- › Efficiency Trials by dava4444
- › How on EARTH Do I Build a Computer??... by dava4444
View: New Articles | All Articles
Home | Reviews | Forums | Articles | My Profile
About Overclock.net | Join the Community | Advertise | Contact Us | All Staff
© 2013 Shogun Interactive Development Overclock.net is powered by Huddler Tech | FAQ | Support | Privacy | ToS | DMCA | Site Map
About Overclock.net | Join the Community | Advertise | Contact Us | All Staff
© 2013 Shogun Interactive Development Overclock.net is powered by Huddler Tech | FAQ | Support | Privacy | ToS | DMCA | Site Map






