Content-Length: 47994 | pFad | http://luckrnx09.com/python-guide-for-javascript-engineers/math-module

Math Module | Python Guide for Javascript Engineers
Skip to main content

Math Module

The math module in Python provides various mathematical functions and constants.

Task

Design a program to calculate the area of a circle based on the input radius.

JavaScript implementation

const radius = 5;
const area = Math.PI * Math.pow(radius, 2);
console.log(area);

Python implementation

import math

radius = 5
area = math.pi * math.pow(radius, 2)
print(area)

Difference Quick View

FeatureJavaScriptPython
Absolute ValueMath.abs(x)abs(x)
Round to Nearest IntegerMath.round(x)round(x)
Ceiling (Smallest Integer Not Less Than x)Math.ceil(x)math.ceil(x)
Floor (Largest Integer Not Greater Than x)Math.floor(x)math.floor(x)
Exponential OperationMath.pow(x, y)math.pow(x, y)
Square RootMath.sqrt(x)math.sqrt(x)
Trigonometric FunctionsMath.sin(x)Math.cos(x)Math.tan(x)Math.asin(x)Math.acos(x)Math.atan(x)math.sin(x)math.cos(x)math.tan(x)math.asin(x)math.acos(x)math.atan(x)
Convert Degrees to Radians-math.radians(x)
Convert Radians to Degrees-math.degrees(x)

Resources









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://luckrnx09.com/python-guide-for-javascript-engineers/math-module

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy