Skip to main content

Section 7.2 Use Library-WE1-P1

Subgoals for using libraries:.

  1. Import module or function (if needed)
    1. With alias (optional)
  2. Determine whether parameters are appropriate for function
    1. Number of parameters passed must match function documentation
    2. Type of parameters passes must match function documentation
  3. 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)
  4. Evaluate expression as necessary

Subsection 7.2.1 Use Library-WE1-P1

Exercises Exercises

1.
    Q1: What keyword is used to access a library?
  • import
  • access
  • use
  • None of these
2.
    Q2: What keyword is used to alias a library?
  • import
  • alias
  • as
  • in
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.
5.
Q5: Enter the output of the following program or enter “invalid” if the statement would result in an error.
import math
print(math.fabs(-2.2))
You have attempted of activities on this page.