Python code that worked and learning
experiences and Notes
# When you put smth in capital letters, it means keep the value of a variable
constant.
#list types
() = tuple/non mutable
[] = list/mutable
{} = set/kinda mutable but gives random answer for multiple values
#functions
== helps us compare things to see if they are equal, like checking if two toys are
the same!
Type = what types of value is smth e.g. is it a float/ variable
Id = value address
Dict = dictionary
Zip = merge 2 things like 2 items from 2 separate lists.
Int = make a variable a integer a = 1.3344092187
type(a)
<class 'float'>
b = int(a)
type(b)
<class 'int'>
b
1
Same applies to floats and if I wanna make smth a complex number,
then u gotta say complex and put in 2 in the brackets. And for bools, u
have to say bool = (here is the value ur tryna ask e.g. is b < d .
#data types
None = Variables with no value (must start with capital)
#shortcut: when assigning values to more than 1 var, you can do it like this :
a,b = 2,3
Numeric =
Floats -
Integers/int -
Complex – smth like 6 + 9j / imaginary numbers (must have the j) so 1 real num
and 1 imaginary \ j = squared by -1
Bool – true/ false (must start in caps) e.g .bool = b<k ( here you’ll get a response
like true/ false).
b = 6 == True is like saying 6 = b is true but 6 = 7 e.g. is false.
Int = make a variable a integer a = 1.3344092187
Same applies to floats and if I want to make smth a complex number,
then u gotta say complex and put in 2 in the brackets. And for bools, u
have to say bool = (here is the value ur tryna ask e.g. is b.)
Sequence =
List -/list list out smth
Set-/set
Tuple-
String- /str
Range-range = nums in between
(2,10,4)
Divisible /what multiples u
want
Endin
Startin
g
g
#operators
Arithmetic =
Assignment = things like x = y+3, that give variables values (must have an =
sign in it)
Unary = Change numbers’ values, with a (-) sign
Relational = smth like ‘==’ is comparing 2 things