Functions in the standard math module.

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

math.log(x, base)

With one argument, return the natural logarithm of x (to base e). With two arguments, return the logarithm of x to the given base, calculated as log(x)/log(base).

Math.factorial(x)

factorial (3! = 3 * 2 * 1)

Math.sin(x)

sine of x (x in radians)

Math.tan(x)

tangent of x

math.fabs(x)

Absolute value

math.hypot(x,y)

Length of vector from origin

math.e(constant)

Mathematical constant 2.718281...

math.pi(constant)

Mathematical constant 3.141592...

Math.pow(x,y)

Raise to power

Math.fmod(x)

Remainder of division

math.log2(x)

Return the base-2 logarithm of x. This is usually more accurate than log(x, 2).

math.gcd(a, b)

Return the greatest common divisor of the integers a and b. If either a or b is nonzero, then the value of gcd(a, b) is the largest positive integer that divides both a and b. gcd(0, 0) returns 0.

math.log1p(x)

Return the natural logarithm of 1+x (base e). The result is calculated in a way which is accurate for x near zero.

Math.sqrt(x)

Returns the square root of x

math.floor(x)

Round down value

Math.ciel(x)

Round up value

Determine the final value of z. x = 2.3 z = math.floor(x)

The value of z is 2. math.floor(2.3) returns 2.

Math.acos(x)

Arc cosine

Math.asin(x)

Arc sine

Math.atan(x)

Arc tangent returns the angle in radians for the inverse of tangent

Math.atan2(y,x)

Arc tangent with two parameters

math.radians(x)

Convert degrees to radians

math.degrees(x)

Convert from radians to degrees

Math.cos(x)

Cosine

math.erf(x)

Error function

Math.exp(x)

Exponential function ex

math.fsum(x)

Floating-point sum

math.gamma(x)

Gamma function

math.cosh(x)

Hyperbolic cosine

math.sinh(x)

Hyperbolic sine

What is another name for a sequence of instructions?

A sequence of instructions that solves a problem is called an algorithm.

Determine the final value of z. z = 4.5 z = math.pow(math.floor(z), 2.0)

The value of z is 16.0. math.floor(z) returns 4. Then, math.pow(4, 2.0) returns 16.0.

Determine the final value of z. z = 4 z = math.factorial(z)

The value of z is 24. 4 * 3 * 2 * 1 is 24.

Determine the final value of z. x = 2.3 z = math.ceil(x)

The value of z is 3. math.ceil(2.3) returns 3.

Determine the final value of z. z = 15.75 z = math.sqrt(math.ceil(z))

The value of z is 4.0. math.ceil(z) returns 16. Then, math.sqrt(16) returns 4.0.


Kaugnay na mga set ng pag-aaral

World History Test - Ancient Civilizations II

View Set

Chapter 6 Multiple Choice and True False Quiz

View Set

Ch. 16 Social and Personality Development in Middle Adulthood

View Set

Nutrition Session 2: Community based management of acute malnutrition

View Set

CCRI Nursing 1010 HESI 1 NCLEX Questions

View Set

HOSP 327 - Unit 3 (Chapters 4, 6, 8, 9) Chapter 7 slides?

View Set

Life Insurance Policies & Annuities TEST

View Set

Perry Ch 7-10 Practice Questions

View Set