1/33
Part 1
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Data Types
Refers to the type of data a value representing
Numeric - All Numbers
Integers, floating-point numbers, comple numbers
Boolean values
Sequences - Ordered Collections
lists, tuples, ranges
strings (a sequence of characters)
Mappings - Key-Value collections
dictionaries
Integeres
Whole numbers of any size

Floating-point Numbers (or float)
Any numeric value with decimal point will be read as a float data type
precision up to 14 decimals places

Float Rounding
Include the value and the number of decimal places you wish to round

Banker’s Rounding or Round Half-to-Even
When you use the function to round to the nearest integer, it will always prefer the closes even integer
Complex
Numbers with a real and an imaginary part
“j” as the imaginary unit

Boolean
This data type represents two values: True or False
numeric
Strings
Considered a sequence, since a sequence of none, one, or more characters.
represented by encolosing the value in single or double quotes.
Functions - len()
Return the number of charater; the length of the string
Function - replace()
Replaces part of the string with another string
Function - lower() & upper()
Changes the string to either allow all lower case or upper case
Function - isnumeric()
Checks if the string is a number
Function - split()
Useful function for splitting a string into separate parts

View of All Functions
Type
Type “type“ inside the parentheses to define any value. In return the funciton will give the data type of that value.

int()
This function converts any value you define in between the parentheses into an integer type.
float()
This function converts any value you define in between the parentheses into a float type.
str()
This function converts any value you define in between the parentheses into a string type.
String Formatting
The process of buildin a larger string value by combining or “glueing” strings and other values.
Concatenation
the operation of “gluing“ string values together
“+”
if you have a numeric type value it will perform addition
cannot perform concatenation with a numeric value
f-string
Allows you to embed variables or expressions directly inside a string
add the letter “f'“ as prefix
any non string {}
f-string w/ Rounding and Fixing
add a colon : after the float value you want to round
add a period . followed by the number that will represent the decimal place you want to round
add “f” to make it fixed

Escape Sequences
A special type of character that we can use to represent characters or formatting into a string
“\”
Formatting Characters - Escape Sequences
\b: - backspace
\t: tab(indentation)
\n: new line

Escape Sequences - Characters
\”: double-quote
\’: single-quote
\\: backslash

Expressions
A combination of values, variables, and operators that your computer will calculate and evaluate into a value.
Literals
These are the simplest of expressions since they do not need evaluation since they are the values themselves.
Operators
Wheneber you use any sort of operators like mathematical operators, Python must resolve the value before is able to perform any other task.
Function Calls
Some function calls are expressions. Whenever you use a funciton, the computer must evluate the value it returns.
Comparion Operators
in
not in
is
is not

Logical Operators
not
and
or
