Type print('Hello World') to display in the console.
Assigning variables
my_variable="6"
print("my number is " + my_variable + " and I love it")
my_variable="10"
print("my new number is " + my_variable + " and I still love it")
int() turns into integer, float() for float, str()
Can't turn a numerical int into a float, you need to do this: int(float("3.4))
Arithmetic
print('Addition : ', a + b)
print('Subtraction : ', a - b)
print('Multiplication : ', a * b)
print('Division (float) : ', a / b)
print('Division (floor) : ', a // b)
print('Modulus : ', a % b)
print('Exponent : ', a ** b)
Strings
string="hello world"
striing.upper()
string.lower()
string.capitalize() # First letter caps
string.title() # first letter of each word caps
string.len() # length of the string
string.count("o") # counts the number of "o" in the centence
string[0] # index of the character in the string
string[2:] # from index 2 till the end
string[2:15] #between both indexes (not inclusive of the last index)
string.find("something")
string.repace("something", "something else") # doesn't mutate, only returns.
"something" in string # boolean if "something" exists in the string
"something" not in string
message=f"{name} loves the color {color.lower()}!" # use variables within a string
User input
name = input("what's your name")
print("Hello {name}")