Python
Elements that the language already know.
+ - addition
- - Subtraction
* - multiplication
/ - float division (number has decimals)
// - integer division (exact division with whole numbers
% - restante
_ - previews answer
\n – enter (next line)
‘’ – text
r‘’ – raw text, so everything in quotes will be text
'marley\'s "laptop"' – marley’s “laptop”
Variables
x = 2 - x variable value is 2
x+3 - the anser will be 5 because x value is 2 and we add 3 equals 5
y = 3 - y variable value is 3
x+y - python will be adding x and y values that equals 5
x=9 - x value will change to 9, will not be 2 anymore
abc - will be an error, because variables are not define
name = ‘class’
name + ‘rock’ - answer will be ‘class rock’
name value is class, if we break name value will have 5 values (starting with 0) because class has 5
letters, so
name[0] = ‘c’
name [-1] = ‘e’ - because starts from the end
name [4] = ‘e’ - because is the last letter
name[0:2] = ‘cl’ - says selects letters from 0 to before 2
name[1:3]= ‘la’ -says select letters from 1 to before 3
name[:4]= ‘clas’ -from beginning to before 4
name[1:]= ‘lass’ -from 1 to the end
name[3:10]= ‘ss’ -from 3 to before 10 but because there is nothing from 9-10 will be in blank
name[0] = “C” -error, you can’t change the value of a single letter
myname = “Marley Hernandez”
len(myname) = 16 - tells you the length of the value (how many characters it has, even with
spaces)