Skip to content

Summary

Summary

In this chapter, you learned how to use the Python REPL, also called the Python prompt, to solve calculation problems.

In the first section of the chapter, you learned what the Python is. REPL stands for Read Evaluate Print Loop. The Python REPL is also sometimes called the Python Prompt.

You learned how to do arithmetic with Python. Addition and subtraction are completed with + and -. Division and multiplication are completed with / and *. To raise a number to a power (exponents) in Python, use ***.

You learned how to import Python's math module and use functions from the math module to complete problems with powers and logarithms, and trigonometry. Python statistics module includes statistical functions such as mean(), median(), mode() and std() (standard deviation).

In the middle of the chapter, you learned about four data types in Python. Two numeric data types were integers and floats (decimals). Boolean values can only be True or False. Strings are sequences of letters, numbers, symbols and spaces. In Python, strings can be defined with either single ' ' or double " " quotes.

At the end of the chapter, you learned about Python's print() function. The chapter concluded with a couple string operations including concatenation (combining), repetition (using *) and indexing. When a string is indexed, the general form isstring[index] or string[start:stop:step]. Remember, in Python, counting starts at 0 and ends at n-1. To call the first index in a string, use string[0]. The second character in the string is accessed with the command string[1].

Key Terms and Concepts

REPL

operator

variable

mathematical operator

command Line

error

module

Standard Library

import

prompt

print

integer

numeric data type

scalar

float

floating point number

complex number

boolean

True

False

index

input

output

Summary of Python Functions and Commands

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

Arithmetic Opperators description
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponents
_ answer in memory
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
Logarithms and Exponents Function description
from math import *
log log base e, natural log
log10 log base 10
exp e^{power}
e Euler's constant e
pow(x,y) x raised to the y power
sqrt square root
Statistical Function description
from statistics import *
mean mean (average)
median median (middle value)
mode (most often)
stdev standard deviation of a sample
pstdev standard deviation of a population
### Additional Resoures
Python's Built-in functions on the Python Docs:

https://docs.python.org/3/library/functions.html

Documentation of the math module on the Python Docs:

https://docs.python.org/3/library/math.html

Documentation of the statistics module on the Python Docs:

https://docs.python.org/3/library/statistics.html

How to Round Numbers in Python by David Amos on RealPython.com:

https://realpython.com/python-rounding/