{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Dario Radečić",
  "title_listed": "Python Square Roots: 5 Ways to Take Square Roots in Python",
  "keywords": "Python,数学",
  "domain": "数据处理",
  "content_type": "深度技术解析",
  "is_paid_flag": "部分免费/会员墙",
  "url": "https://towardsdatascience.com/python-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f/",
  "publish_date": "2022-12",
  "corpus_stage": "预训练/SFT",
  "notes": "",
  "id": "1a95a37bf609",
  "collected_at": "2026-10-01T21:38:44",
  "title": "Python Square Roots: 5 Ways to Take Square Roots in Python | Towards Data Science",
  "body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Data Science](https://towardsdatascience.com/category/data-science/)\n# Python Square Roots: 5 Ways to Take Square Roots in Python\nThere's more than one way to Python square roots. Learn 5 approaches to square roots in Python + some bonus advanced tricks.\n[Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\nDecember 1, 20229 min read\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/12/0bgbsy4vW3aI7nerL-scaled.jpg)\nAfter learning about [4 ways to square a number in Python](https://betterdatascience.com/python-squaring/), now it's time to tackle the opposite operation - Python square roots. This article will teach you five distinct ways to take square roots in Python and will finish off with a bonus section on cube roots and square roots of Python lists.\nLet's get started by introducing the topic and addressing the potential issues you have to consider when calculating square roots in Python.\n* * *\n## Introduction to Python Square Roots\nPut simply, the square root of a number is a value that returns the same number when multiplied by itself. It's an inverse operation of squaring.\nFor example, 3 squared is 9, and a square root of 9 is 3 because 3 x 3 is 9. It's a concept that's somewhat difficult to explain in a sentence, but you get the idea as soon as you see it in action.\nBefore diving into different ways to take square roots in Python, let's go over the sets of numbers for which you can and can't take square roots.\nLearn this step by step with the interactive [AI and Data Scientist](https://roadmap.sh/ai-data-scientist), [Computer Science](https://roadmap.sh/computer-science) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\n### Square root of a positive number\nSquare roots only play well with positive numbers. For now, ignore the code that's responsible for calculations and just focus on the results.\nThe following code snippet prints the square root for numbers 1 and 25:\ntext\n\n```\nimport math\n\na = 1\nb = 25\n\n# Square root of a positive number\na_sqrt = math.sqrt(a)\nb_sqrt = math.sqrt(b)\n\n# Print\nprint(\"Square root of a positive number\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\nprint(f\"Square root of {b} = {b_sqrt}\")\n```\n\nHere's the output:\nSo, 1x1 = 1, and 5x5 = 25 - that's essentially how square roots work. But what if you were to take a square root of zero?\n### Square root of zero\nNow, zero is neither a prime nor composite number, so we can't find its [prime factorization](https://www.cuemath.com/numbers/prime-factorization/). For this reason, a square root of zero is zero:\ntext\n\n```\nimport math\n\na = 0\n\n# Square root of a zero\na_sqrt = math.sqrt(a)\n\n# Print\nprint(\"Square root of a zero\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\n```\n\nHere's the output:\nOnly one use case left, and that's negative numbers.\n### Square root of a negative number\nThere's no way to calculate a square root of a negative number by using [real numbers](https://study.com/learn/lesson/negative-square-root-overview-examples.html). Two negative numbers multiplied will always result in a positive number.\nNevertheless, let's give it a shot:\ntext\n\n```\nimport math\n\na = -10\n\n# Square root of a negative number\na_sqrt = math.sqrt(a)\n\n# Print\nprint(\"Square root of a negative number\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\n```\n\nIt results in an error:\nThere are ways to calculate square roots of negative numbers, and that's by writing them as a multiple of -1. For instance, -9 can be written as -1 x 9. The result would be **3i**. Stepping into the realm of imaginary numbers is out of the scope for today, so I'll stop here.\nNext, let's go over 5 ways to tackle Python square roots.\n## Calculate Square Roots with the sqrt() Function\nThe first method is actually the one you've seen in the previous section. It relies on the `math.pow()` function to do the trick. This module ships with the default Python installation, so there's no need to install any external libraries.\nBelow is a code snippet demonstrating how to take square roots in Python using this function:\ntext\n\n```\nimport math\n\na = 1\nb = 25\nc = 30.82\nd = 100\ne = 400.40\n\n# Method #1 - math.sqrt() function\na_sqrt = math.sqrt(a)\nb_sqrt = math.sqrt(b)\nc_sqrt = math.sqrt(c)\nd_sqrt = math.sqrt(d)\ne_sqrt = math.sqrt(e)\n\n# Print\nprint(\"Method #1 - math.sqrt() function\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\nprint(f\"Square root of {b} = {b_sqrt}\")\nprint(f\"Square root of {c} = {c_sqrt}\")\nprint(f\"Square root of {d} = {d_sqrt}\")\nprint(f\"Square root of {e} = {e_sqrt}\")\n```\n\nAnd here are the results:\nThis is probably the one and only method you'll need, but let's take a look at some alternatives as well.\n## Calculate Square Roots with the pow() Function\nIf squaring a number means raising it to the power of 2, then taking a square root is essentially raising it to the power of 0.5. That's exactly the behavior you can implement with the `math.pow()` function. It takes two arguments - the number and the exponent.\nLet's take a look at a couple of examples:\ntext\n\n```\nimport math\n\na = 1\nb = 25\nc = 30.82\nd = 100\ne = 400.40\n\n# Method #2 - math.pow() function\na_sqrt = math.pow(a, 0.5)\nb_sqrt = math.pow(b, 0.5)\nc_sqrt = math.pow(c, 0.5)\nd_sqrt = math.pow(d, 0.5)\ne_sqrt = math.pow(e, 0.5)\n\n# Print\nprint(\"Method #2 - math.pow() function\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\nprint(f\"Square root of {b} = {b_sqrt}\")\nprint(f\"Square root of {c} = {c_sqrt}\")\nprint(f\"Square root of {d} = {d_sqrt}\")\nprint(f\"Square root of {e} = {e_sqrt}\")\n```\n\nThe output is identical to what we had before:\nNeat, but can we eliminate library usage altogether? Sure, here's how.\n## Python's Exponent Operator (**) for Taking Square Roots\nThe same logic from the previous function applies here. You can raise a number to the power of 0.5 with Python's exponent operator. It does the same as `math.pow(x, 0.5)`, but the syntax is shorter and doesn't rely on any libraries.\nHere's how to use it in Python:\ntext\n\n```\na = 1\nb = 25\nc = 30.82\nd = 100\ne = 400.40\n\n# Method #3 - Python exponent operator\na_sqrt = a**0.5\nb_sqrt = b**0.5\nc_sqrt = c**0.5\nd_sqrt = d**0.5\ne_sqrt = e**0.5\n\n# Print\nprint(\"Method #3 - Python exponent operator\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\nprint(f\"Square root of {b} = {b_sqrt}\")\nprint(f\"Square root of {c} = {c_sqrt}\")\nprint(f\"Square root of {d} = {d_sqrt}\")\nprint(f\"Square root of {e} = {e_sqrt}\")\n```\n\nThe results are once again identical, no surprises here:\nNext, let's take a look at taking square roots of numbers and arrays with Numpy.\n## Numpy - Calculate the Root of a Number or an Array\nNumpy is a go-to library for numerical computations in Python. It has a `sqrt()` function built-in, and you can use it to take square roots for both numbers and arrays.\nJust keep in mind the return type - it will be `numpy.float64` for a single number and `numpy.ndarray` for the array. Each array element will be of type `numpy.float64`, of course:\ntext\n\n```\nimport numpy as np\n\na = 1\nb = 25\nc = 30.82\nd = 100\ne = 400.40\narr = [a, b, c]\n\n# Method #4 - Numpy square roots\na_sqrt = np.sqrt(a)\nb_sqrt = np.sqrt(b)\nc_sqrt = np.sqrt(c)\nd_sqrt = np.sqrt(d)\ne_sqrt = np.sqrt(e)\narr_sqrt = np.sqrt(arr)\n\n# Print\nprint(\"Method #4 - Numpy square roots\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\nprint(f\"Square root of {b} = {b_sqrt}\")\nprint(f\"Square root of {c} = {c_sqrt}\")\nprint(f\"Square root of {d} = {d_sqrt}\")\nprint(f\"Square root of {e} = {e_sqrt}\")\nprint(f\"Square root of {arr} = {arr_sqrt}\")\n```\n\nHere's the console output:\nThis is by far the most convenient method because it relies on a widely-used Python library, and the calculation procedure is the same regardless of the data type coming in.\n## Cmath - Take Python Square Roots of Complex Numbers\nRemember the story of square roots and negative numbers? Python's `math` module raised an error but `cmath` is here to save the day. This module is used to work with complex numbers.\nIn the code snippet below, you'll see square roots taken from positive integers, floats, complex numbers, and negative numbers:\ntext\n\n```\nimport cmath\n\na = 1\nb = 25.44\nc = cmath.pi\nd = 10+10j\ne = -100\n\n# Method #5 - Square roots of complex numbers\na_sqrt = cmath.sqrt(a)\nb_sqrt = cmath.sqrt(b)\nc_sqrt = cmath.sqrt(c)\nd_sqrt = cmath.sqrt(d)\ne_sqrt = cmath.sqrt(e)\n\n# Print\nprint(\"Method #5 - Square roots of complex numbers\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {a} = {a_sqrt}\")\nprint(f\"Square root of {b} = {b_sqrt}\")\nprint(f\"Square root of {c} = {c_sqrt}\")\nprint(f\"Square root of {d} = {d_sqrt}\")\nprint(f\"Square root of {e} = {e_sqrt}\")\n```\n\nThere are no errors this time:\nI've never had a need to use this module, but it's good to know it exists.\nNext, let's go over some more advanced usage examples of Python square roots.\n## Bonus: Advanced Python Roots Topics\nWe'll now shift gears and discuss a couple of more advanced topics. These include ways to calculate cube roots in Python, and take square roots of vanilla Python lists. Let's start with the cube roots.\n### Cube root in Python\nIf taking a square root means raising a number to the power of 0.5, then the cube root must be represented by the power of 0.333, or 1/3.\nHere's how to implement this logic in Python, without any external libraries:\ntext\n\n```\na = 1\nb = 27\nc = 30.82\nd = 1000\ne = 400.40\n\n# Bonus #1 - Cube roots\na_cbrt = a ** (1./3.)\nb_cbrt = b ** (1./3.)\nc_cbrt = c ** (1./3.)\nd_cbrt = d ** (1./3.)\ne_cbrt = e ** (1./3.)\n\n# Print\nprint(\"Bonus #1 - Cube roots\")\nprint(\"--------------------------------------------------\")\nprint(f\"Cube root of {a} = {a_cbrt}\")\nprint(f\"Cube root of {b} = {b_cbrt}\")\nprint(f\"Cube root of {c} = {c_cbrt}\")\nprint(f\"Cube root of {d} = {d_cbrt}\")\nprint(f\"Cube root of {e} = {e_cbrt}\")\n```\n\nThe results are printed below:\nNumpy provides an easier way to take cube roots in Python. It has a `cbrt()` function built in, which stands for _cube root_. You can use it both on numbers and arrays, just as with square roots:\ntext\n\n```\nimport numpy as np\n\na = 1\nb = 27\nc = 30.82\nd = 1000\ne = 400.40\narr = [a, b, c]\n\n# Bonus #1.2 - Cube roots with Numpy\na_cbrt = np.cbrt(a)\nb_cbrt = np.cbrt(b)\nc_cbrt = np.cbrt(c)\nd_cbrt = np.cbrt(d)\ne_cbrt = np.cbrt(e)\narr_cbrt = np.cbrt(arr)\n\n# Print\nprint(\"Bonus #1.2 - Cube roots with Numpy\")\nprint(\"--------------------------------------------------\")\nprint(f\"Cube root of {a} = {a_cbrt}\")\nprint(f\"Cube root of {b} = {b_cbrt}\")\nprint(f\"Cube root of {c} = {c_cbrt}\")\nprint(f\"Cube root of {d} = {d_cbrt}\")\nprint(f\"Cube root of {e} = {e_cbrt}\")\nprint(f\"Cube root of {arr} = {arr_cbrt}\")\n```\n\nLet's take a look at the results:\nYes, it's that easy.\n### Square root of a list in Python\nThere's also an easy way to calculate the square root of Python lists, without Numpy. You can simply iterate over the list and take a square root of an individual list item:\ntext\n\n```\nimport math\n\narr = [1, 25, 30.82]\narr_sqrt = []\n\n# Bonus #2 - Square root of a Python list\nfor num in arr:\n    arr_sqrt.append(math.sqrt(num))\n\n# Print\n# Print\nprint(\"Bonus #2 - Square root of a Python list\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {arr} = {arr_sqrt}\")\n```\n\nHere's the result:\nOr, if you prefer a more Pythonic approach, there's no reason not to use a list comprehension and simply the above calculation to a single line of code:\ntext\n\n```\nimport math\n\narr = [1, 25, 30.82]\n\n# Bonus #2.2 - Square root of a Python list using list comprehension\narr_sqrt = [math.sqrt(num) for num in arr]\n\n# Print\n# Print\nprint(\"Bonus #2.2 - Square root of a Python list using list comprehension\")\nprint(\"--------------------------------------------------\")\nprint(f\"Square root of {arr} = {arr_sqrt}\")\n```\n\nThe output is identical:\nAnd that's how easy it is to take square roots in Python - for integers, floats, lists, and even complex numbers. Let's make a short recap next.\n* * *\n## Conclusion\nYou now know 5 different ways to calculate Python square roots. In practice, you only need one, but it can't hurt to know a couple of alternatives. You can use the built-in `math` module, opt for `numpy`, or use the exponent operator and avoid libraries altogether. All approaches work, and the choice is up to you.\nStay tuned to the blog if you want to learn more basic Python concepts. Thanks for reading!\n* * *\n_Loved the article? Become a_[ _Medium member_](https://towardsdatascience.com/@radecicdario/membership) _to continue learning without limits. I'll receive a portion of your membership fee if you use the following link, with no extra cost to you._\n> [**Join Medium with my referral link - Dario Radečić**](https://medium.com/@radecicdario/membership)\n* * *\n### Stay connected\n  * Hire me as a [technical writer](https://betterdatascience.com/contact/)\n  * Subscribe on [YouTube](https://www.youtube.com/c/BetterDataScience)\n  * Connect on [LinkedIn](https://www.linkedin.com/in/darioradecic/)\n\n\n* * *\n_Originally published at_[](https://betterdatascience.com)[ _https://betterdatascience.com_](https://betterdatascience.com/python-square-roots/) _on December 1, 2022._\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657095692_93hujy.png)\nWritten By\n## [Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\nhttps://writingfordevs.substack.com\n[See all from Dario Radečić](https://towardsdatascience.com/author/radecicdario/)\n[Data Science](https://towardsdatascience.com/tag/data-science/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Programming](https://towardsdatascience.com/tag/programming/)[Python](https://towardsdatascience.com/tag/python/)[Towards Data Science](https://towardsdatascience.com/tag/towards-data-science/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fpython-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f%2F&title=Python%20Square%20Roots%3A%205%20Ways%20to%20Take%20Square%20Roots%20in%20Python)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fpython-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f%2F&title=Python%20Square%20Roots%3A%205%20Ways%20to%20Take%20Square%20Roots%20in%20Python)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fpython-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f%2F&text=Python%20Square%20Roots%3A%205%20Ways%20to%20Take%20Square%20Roots%20in%20Python)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/0bqE498kXCqDz132X-scaled.jpg)](https://towardsdatascience.com/is-a-straight-line-linear-f9f491514e97/)\n## [Is a straight line linear?](https://towardsdatascience.com/is-a-straight-line-linear-f9f491514e97/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhat is linearity by the book\n[Łukasz Gebel](https://towardsdatascience.com/author/luk.gebel/)\nAugust 28, 20206 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/1BMnXJ6R0uukYxeN1oZnu8g-scaled.jpeg)](https://towardsdatascience.com/a-gentle-introduction-automating-machine-learning-pipelines-71f97192eabf/)\n## [A Gentle Introduction: Automating Machine Learning Pipelines](https://towardsdatascience.com/a-gentle-introduction-automating-machine-learning-pipelines-71f97192eabf/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nDeploying a model quickly and confidently is hard. This post shows you how to automate ML pipelines to make your life that bit easier.\n[Mark Douthwaite](https://towardsdatascience.com/author/mark-l-douthwaite/)\nNovember 5, 202014 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/1758zk6c3dmSG5XqjwVqufA.png)](https://towardsdatascience.com/feature-importance-in-linear-models-four-often-neglected-but-crucial-pitfalls-e5c513e45b18/)\n## [Feature Importance in Linear Models: Four Often Neglected but Crucial Pitfalls](https://towardsdatascience.com/feature-importance-in-linear-models-four-often-neglected-but-crucial-pitfalls-e5c513e45b18/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nThe family of linear models includes ordinary linear regression, Ridge regression, Lasso regression, SGD regression, and so on. The...\n[Alina Zhang](https://towardsdatascience.com/author/alina-li-zhang/)\nMarch 12, 20213 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2026/02/Gemini_Generated_Image_t7612at7612at761-scaled-1.jpg)](https://towardsdatascience.com/the-gap-between-junior-and-senior-data-scientists-isnt-code/)\n## [The Gap Between Junior and Senior Data Scientists Isn’t Code](https://towardsdatascience.com/the-gap-between-junior-and-senior-data-scientists-isnt-code/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nWhy my obsession with complex algorithms was actually holding my career back.\n[Benjamin Nweke](https://towardsdatascience.com/author/benjaminnweke/)\nFebruary 27, 20265 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/0cdpBFq0yNq7udecq-scaled.jpg)](https://towardsdatascience.com/syntax-gotchas-writing-pyspark-when-knowing-pandas-57ace4ae769b/)\n## [Syntax Gotchas writing PySpark when knowing Pandas](https://towardsdatascience.com/syntax-gotchas-writing-pyspark-when-knowing-pandas-57ace4ae769b/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nIf you have some basic knowledge in data analysis with Python Pandas and are curious about PySpark and don't know where to start, tag...\n[Christine Winter](https://towardsdatascience.com/author/icecubes/)\nMarch 30, 20215 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/05/0S1UopJtACvWKrNEc-scaled.jpg)](https://towardsdatascience.com/quadratic-optimization-with-constraints-in-python-using-cvxopt-fc924054a9fc/)\n## [Quadratic Optimization with Constraints in Python using CVXOPT](https://towardsdatascience.com/quadratic-optimization-with-constraints-in-python-using-cvxopt-fc924054a9fc/)\n[](https://towardsdatascience.com/python-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f/)\nQuadratic optimization is a problem encountered in many fields, from least squares regression [1] to portfolio optimization [2] and passing...\n[Perceval Desforges](https://towardsdatascience.com/author/pdesforges/)\nMay 10, 20229 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/1qWDhUJsHpFxxHoGDO-c06g-scaled.jpeg)](https://towardsdatascience.com/machine-learning-lifecycle-with-mlops-github-actions-label-studio-iterative-ai-and-nbdev-30515f444a3e/)\n## [Machine Learning Lifecycle with MLOps: Github Actions, Label Studio, Iterative.ai and NBDEV](https://towardsdatascience.com/machine-learning-lifecycle-with-mlops-github-actions-label-studio-iterative-ai-and-nbdev-30515f444a3e/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nCollaborating on deep learning projects is not easy since there are a lot of moving pieces and very little standard development practices.\n[Aaron Soellinger](https://towardsdatascience.com/author/soellingeraj/)\nMay 7, 20218 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/07/1bQ6MEeXUXx7oRnO_sEARGA.png)](https://towardsdatascience.com/final-dxa-nation-f0309d718980/)\n## [Final DXA-nation](https://towardsdatascience.com/final-dxa-nation-f0309d718980/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAI can see the end! Deep learning predicts all-cause mortality from single and sequential body composition imaging\n[Lambert Leong](https://towardsdatascience.com/author/lambertleong/)\nJuly 22, 20238 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/09/12cKX4PqiXxlCaiZm445ULA-scaled.jpeg)](https://towardsdatascience.com/python-loops-a-complete-guide-on-how-to-iterate-in-python-b29e0d12211d/)\n## [Python Loops: A Complete Guide On How To Iterate in Python](https://towardsdatascience.com/python-loops-a-complete-guide-on-how-to-iterate-in-python-b29e0d12211d/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nLeveraging the power of loops in Python\n[Federico Trotta](https://towardsdatascience.com/author/federicotrotta/)\nSeptember 16, 20227 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "Python Square Roots: 5 Ways to Take Square Roots in Python | Towards Data Science",
    "description": "There's more than one way to Python square roots. Learn 5 approaches to square roots in Python + some bonus advanced tricks.",
    "keywords": null,
    "author": "Dario Radečić",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Python Square Roots: 5 Ways to Take Square Roots in Python",
    "og:description": "There's more than one way to Python square roots. Learn 5 approaches to square roots in Python + some bonus advanced tricks.",
    "og:url": "https://towardsdatascience.com/python-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/12/0bgbsy4vW3aI7nerL-scaled.jpg",
    "og:image:width": "2560",
    "og:image:height": "1906",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Dario Radečić",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "9 min read",
    "article:published_time": "2022-12-01T14:00:56.000Z",
    "article:modified_time": "2022-12-01T14:00:56.000Z",
    "article:author": "https://towardsdatascience.com/author/radecicdario/"
  },
  "paywall": {
    "listed_paid": true,
    "detected": false,
    "marker": "",
    "public_only": true,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_000.txt",
      "chars": 297
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_001.txt",
      "chars": 206
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_002.txt",
      "chars": 230
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_003.txt",
      "chars": 512
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_004.txt",
      "chars": 530
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_005.txt",
      "chars": 477
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_006.txt",
      "chars": 589
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_007.txt",
      "chars": 547
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_008.txt",
      "chars": 468
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_009.txt",
      "chars": 586
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_010.txt",
      "chars": 313
    },
    {
      "language": "txt",
      "file": "attachments/1a95a37bf609/code/block_011.txt",
      "chars": 344
    }
  ],
  "images": [
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/12/0bgbsy4vW3aI7nerL-scaled.jpg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/000.jpg",
      "bytes": 395163,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/08/0bqE498kXCqDz132X-scaled.jpg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/001.jpg",
      "bytes": 107312,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2020/11/1BMnXJ6R0uukYxeN1oZnu8g-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/002.jpeg",
      "bytes": 710999,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/1758zk6c3dmSG5XqjwVqufA.png",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/003.png",
      "bytes": 51799,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2026/02/Gemini_Generated_Image_t7612at7612at761-scaled-1.jpg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/004.jpg",
      "bytes": 536127,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/03/0cdpBFq0yNq7udecq-scaled.jpg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/005.jpg",
      "bytes": 415087,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/05/0S1UopJtACvWKrNEc-scaled.jpg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/006.jpg",
      "bytes": 1422558,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/1qWDhUJsHpFxxHoGDO-c06g-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/007.jpeg",
      "bytes": 613554,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/07/1bQ6MEeXUXx7oRnO_sEARGA.png",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/008.png",
      "bytes": 160180,
      "downloaded": true
    },
    {
      "src": "https://assets.insightmediagroup.io/media/wp-content/uploads/2022/09/12cKX4PqiXxlCaiZm445ULA-scaled.jpeg",
      "alt": "",
      "local_path": "attachments/1a95a37bf609/images/009.jpeg",
      "bytes": 386682,
      "downloaded": true
    }
  ],
  "audio": [],
  "videos": [
    {
      "src": "https://www.youtube.com/c/BetterDataScience",
      "quality": "unavailable",
      "local_path": "",
      "note": "无1080p且无720p，未交付更低清晰度"
    },
    {
      "src": "https://www.youtube.com/c/TowardsDataScience",
      "quality": "unavailable",
      "local_path": "",
      "note": "无1080p且无720p，未交付更低清晰度"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/radecicdario/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/@radecicdario/membership"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/programming/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/python/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/towards-data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/is-a-straight-line-linear-f9f491514e97/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/luk.gebel/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/a-gentle-introduction-automating-machine-learning-pipelines-71f97192eabf/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/mark-l-douthwaite/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/feature-importance-in-linear-models-four-often-neglected-but-crucial-pitfalls-e5c513e45b18/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://betterdatascience.com/python-squaring/"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/computer-science"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://www.cuemath.com/numbers/prime-factorization/"
    },
    {
      "type": "external",
      "href": "https://study.com/learn/lesson/negative-square-root-overview-examples.html"
    },
    {
      "type": "external",
      "href": "https://medium.com/@radecicdario/membership"
    },
    {
      "type": "external",
      "href": "https://betterdatascience.com/contact/"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/BetterDataScience"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/in/darioradecic/"
    },
    {
      "type": "external",
      "href": "https://betterdatascience.com"
    },
    {
      "type": "external",
      "href": "https://betterdatascience.com/python-square-roots/"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=Python+Square+Roots%3A+5+Ways+to+Take+Square+Roots+in+Python&u=https%3A%2F%2Ftowardsdatascience.com%2Fpython-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=Python+Square+Roots%3A+5+Ways+to+Take+Square+Roots+in+Python&url=https%3A%2F%2Ftowardsdatascience.com%2Fpython-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=Python+Square+Roots%3A+5+Ways+to+Take+Square+Roots+in+Python&url=https%3A%2F%2Ftowardsdatascience.com%2Fpython-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f%2F"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/TowardsDataScience"
    },
    {
      "type": "external",
      "href": "https://www.threads.net/@towardsdatascience"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T11:11:48Z",
  "source_url": "https://towardsdatascience.com/python-square-roots-5-ways-to-take-square-roots-in-python-445ea9b3fb6f/",
  "delivery_status": "excluded_paid",
  "discovery_status": "excluded_paid",
  "missing_reason": "按原约定排除付费/会员全文"
}