Programming fundamentalsLesson 4 of 5 in the course Expressions

Python's math Module: Functions, Constants, and Formula Applications

5 flashcards · 5 quiz questions · 5 match pairs · 4 fill-in sentences · English

Lesson progress
0 / 5

Your progress is kept in this browser only.Sign up to save it

Summary

Python provides many useful functions, but they are not all accessed in the same way. This lesson introduces modules and explains the difference between built-in functions and functions from the math module.

A module is previously written Python code that can be used by another program. Python's standard library contains many modules, including math, which provides mathematical functions and constants.

All flashcards

What is a Python module?
Previously written Python code that a program can import and reuse.
What is a built-in function?
A function available directly in Python without importing a module, such as print or float.
What does math.tau represent?
A constant equal to 2π2\pi, the ratio of a circle's circumference to its radius.
How do math.ceil and math.floor differ?
ceil returns the smallest integer at least as large as its input; floor returns the largest integer no greater than its input.
What unit do math.sin, math.cos, and math.tan expect?
Radians.

Quiz questions

  1. What is a Python module?Answer: Previously written Python code that can be imported and used by a program.
  2. Which statement makes the math module available under the name math?Answer: import math
  3. Why can a Python program call print without importing a module?Answer: print is a built-in function available directly in Python.
  4. After writing import math, how should a program call the square-root function on 25?Answer: math.sqrt(25)
  5. What distance does the distance formula give between (0,0)(0,0) and (3,4)(3,4)?Answer: 5.0, from 32+42\sqrt{3^2+4^2}.

Based on Introduction to Python Programming by Udayan Das, Aubrey Lawson, Chris Mayfield, Narges Norouzi (OpenStax), licensed CC BY 4.0. Adapted into a summary, flashcards and quizzes.

All Programming fundamentals lessons