Skip to main content\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
\newcommand{\R}{\mathbb R}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 7.2 Use Library-WE1-P1
Subgoals for using libraries:.
-
Import module or function (if needed)
With alias (optional)
-
Determine whether parameters are appropriate for function
Number of parameters passed must match function documentation
Type of parameters passes must match function documentation
Determine what the function will return (i.e., data type), print, and/or change state of arguments and where it will be stored (nowhere, somewhere)
Evaluate expression as necessary
Subsection 7.2.1 Use Library-WE1-P1
Exercises Exercises
1.
2.
3.
Q3: After importing the math library without an alias, how can the log10
function be called on the integer 54
?
math.log10.54
math.log10(54)
math(log10)(54)
math(log10).54
4.
Q4: Write a program that takes user input of an integer and prints half the absolute value of that integer.
import math
---
x = int(input("Enter an integer: "))
---
absolute_value = math.fabs(x)
half = absolute_value / 2
---
print(half)
5.
You have attempted
of
activities on this page.