Aug 1, 2024
print("Hello World")
to print to the terminal.age = 20
print(age)
age = 30
print(age)
name = "Mosh"
is_online = True
price = 19.95
input()
to get user input from the terminal.name = input("What is your name?")
print("Hello " + name)
int()
: Convert to integerfloat()
: Convert to floatstr()
: Convert to string+
, -
, *
, /
, %
(modulus), **
(exponentiation)x = 10 + 3 * 2 # Operator precedence applies
+=
, -=
, *=
, /=
>
, <
, >=
, <=
, ==
, !=
and
, or
, not
if price > 10 and price < 30:
if condition:
# code block
else:
# alternative code block
if temperature > 30:
print("It's a hot day.")
i = 1
while i <= 5:
print(i)
i += 1
[ ]
.names = ["John", "Bob", "Mosh"]
print(names[0]) # Outputs: John
append()
, insert()
, remove()
, clear()
, len()
numbers = (1, 2, 3)