4.6. Summary

In this chapter, you learned how to use the Python REPL, also called the Python prompt, to solve problems. You learned how to do arithmetic, powers and logarithms, trigonometry and save values to variables. Operations on strings were introduced including concatenation and comparison. In the last section of the chapter, Python’s print() function was introduced.

4.6.1. Key Terms and Concepts

REPL

Python REPL

Python Prompt

prompt

Python Interpreter

interpreter

operator

mathematical operator

import

module

Python Standard Library

Standard Library

syntax

functions

command line

error

variable

assignment operator

comparison operator

concatenate

equivalent

index

indexing

slicing

4.6.2. Summary of Python Functions and Commands

Below is a summary of the functions and operators used in this chapter:

4.6.2.1. Arithmetic

Arithmetic Operator

Description

+

addition

-

subtraction

*

multiplication

/

division

**

exponents

_

answer in memory

4.6.2.2. Trigonometry

Trig Function

Description

from math import *

sin

sine of angle in radians

cos

cosine of angle in radians

tan

tangent of angle in radians

pi

\(\pi\)

degrees

convert radians to degrees

radians

convert degrees to radians

asin

inverse sine

acos

inverse cosine

atan

inverse tangent

4.6.2.3. Logarithms and Exponents

Logarithms and Exponent Function

Description

from math import *

log

log base e, natural log

log10

log base 10

exp

\(e^{power}\)

e

the math constant \(e\)

pow(x,y)

x raised to the y power

sqrt

square root

4.6.2.4. Statistics

Statistics Function

Description

from statistics import *

mean

mean (average)

median

median (middle value)

mode

mode (most often)

stdev

standard deviation of a sample

pstdev

standard deviation of a population