CS1302 Introduction to Computer Programming
Import keyword: from math import sqrt
Three important parts: Name, Parameters, Result type
Automatically available to any Python program:
no import statement is required.
The standard math module provides much of the functionality of a scientifific calculator.
>>> import math
>>> dir(math)
['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'g amma', 'hypot', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
>>>
Warning
time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead
All algorithmic random number generators actually produce pseudorandom numbers, not true random
numbers.
The sys.exit function accepts a single integer argument, which it passed back to the operating system
when the program completes. The value zero indicates that the program completed successfully; a nonzero
value represents the program terminating due to an error of some kind.
eval: evaluate a string in the same way that the interactive shell would evaluate it.
Example:
Use functions from Python’s Turtle graphics module to draw a sunflower
import *: import all