Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Square and Cube roots.
#2
Use int() to ignore the non-integer values:
>>> x = 9.4392
>>> x
9.4392
>>> int(x)
9
>>> y = 3.8743
>>> y
3.8743
>>> int(y)
3
To get a root, use a fraction as an exponent. The square root of 9 is 3. 3 squared is 9. 3**2 is 9. 9**(1/2) is 3.
The cube root of 27 is 3. 3 cubed is 27. 3**3 is 27. 27**(1/3) is 3.
Reply


Messages In This Thread
Square and Cube roots. - by jarrod0987 - Apr-13-2018, 01:19 PM
RE: Square and Cube roots. - by nilamo - Apr-13-2018, 09:05 PM
RE: Square and Cube roots. - by casevh - Apr-13-2018, 09:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Im at square one even with trying to install python origen 1 496 Jan-12-2024, 05:39 AM
Last Post: ndc85430
  Finding all roots of a function thonpy 3 2,591 Apr-16-2021, 03:02 AM
Last Post: bowlofred
  pip unistall in alternate roots confminn 0 1,509 Aug-21-2020, 08:03 PM
Last Post: confminn
  square root of 5 input numbers mrityunjoy 1 2,133 Jun-10-2020, 11:08 AM
Last Post: perfringo
  square root of 6 input numbers mrityunjoy 3 2,771 Jun-07-2020, 06:35 AM
Last Post: ndc85430
  How to simplify square finding program? meknowsnothing 3 3,084 Jun-11-2019, 08:20 PM
Last Post: meknowsnothing
  cropping a picture (always square) Leon 1 2,246 Aug-13-2018, 10:04 AM
Last Post: Leon
  Error when trying to square a number pistacheoowalnuttanker 5 4,007 Jul-20-2018, 02:23 AM
Last Post: pistacheoowalnuttanker
  I'm having a problem with this cube root code Duc311003 2 3,062 May-16-2018, 07:13 PM
Last Post: buran
  "³" math cube symbol encoding Ragnar 5 10,033 Mar-09-2018, 04:23 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020