Sep 23, 2024
item
).item = "orange"
.item
vs. Item
).item_name
).print()
to display values.print(item)
will show orange
.10
)."hello"
).True
, False
).my_list = ["apple", 2, False]
).print(name + str(integer))
to combine string and integer.+
-
*
/
**
if
, elif
, and else
for conditional logic.
if age > 21:
print("You are old")
elif age == 18:
print("You are getting old")
else:
print("You are still young")
for i in range(n):
for i in range(3):
print("hello" + str(i))
while condition:
i = 0
while i < 5:
print(i)
i += 1
def
keyword.def say_hello(name):
print(f"Hey there, {name}!")
pass
for functions without logic to avoid errors.try
and except
blocks to handle errors.
try:
result = 10 + int(user_input)
except ValueError:
print("That is not a valid number")