Discover the library of Python scripts created by the NumWorks community!

Examples

Name Description Author
This script defines a function gcd(a,b) which returns the greatest common divisor of a and b.
This script defines two functions. The hypotenuse(a,b) function returns the hypotenuse length of a right-angled triangle whose right-angle adjacent sides are a and b. The pythagore(a,b,c) function tests if the integer tuple (a,b,c) is Pythagorean, it returns true if and only if a**2+b**2=c**2.
This script will allow you to simulate flipping a coin a specified number of times.
This script will allow you to generate a slope field for a given dy/dx on the x and y axes [-3, 3]. When inputting your dy/dx you must explicitly define every operation Examples of inputting different slopes are below: if dy/dx = 2x/y then input 2*x/y if dy/dx = 0.5x+y then input 0.5*x+y Watch a tutorial at https://www.youtube.com/watch?v=bT391K229Bs
This script will allow you to approximate a solution to a differential equation using Euler’s method. When inputting your dy/dx you must explicitly define every operation Examples of inputting different dy/dx are below: if dy/dx = 2x/y then input 2*x/y if dy/dx = 0.5x+y then input 0.5*x+y Watch a tutorial at : https://youtu.be/Q9BwmdPH9-M?si=O26JjlLRm4A3En69
This script runs the Pythagorean Converse to determine if a triangle is acute, obtuse, or right. If you use values that do not make a triangle, then it will also let you know the numbers cannot be a triangle.
This script will take a number in any base (2-16), and convert it to another base (2-16). Method: First, it converts all numbers (regardless of the goal) to base 10. Then it will either return the base 10 value it that is the goal, or converts to the target base. Because a crucial part of this script is to convert all numbers to base 10, the script will return the base 10 conversion AND the desired conversion, if base 10 is not the goal nor the initial base. This script has two functions defined, convert_to_10 and convert_from_10. These two functions are helper functions that do the mathematical computation converting numbers to and from base 10.
This script determines if a whole number is prime or composite.
Defines function prime(lower, upper) that finds all prime values from lower limit to upper limit.

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.