Sep 3, 2024
app.py
).print("Hello, World!")
to display output.
age = 20
print(age)
to display the value.age = 30
).first_name
).is_online = True
or is_online = False
.input()
function to receive user input.
name = input("What is your name? ")
+
(e.g., print("Hello, " + name)
).int()
, float()
, str()
, etc.+
, -
, *
, /
, //
(integer division), %
(modulus), **
(exponentiation).x += 3
).>
, <
, >=
, <=
, ==
, !=
.and
, or
, not
.if condition:
# code to execute if condition is true
elif another_condition:
# another code block
else:
# code if no conditions are true
While Loops: Repeat code while a condition is true.
i = 1
while i <= 5:
print(i)
i += 1
For Loops: Iterate over a sequence (like a list or range).
for item in sequence:
print(item)
names = ["John", "Bob", "Marsh"]
names[0]
).append()
, insert()
, remove()
, clear()
, etc.numbers = (1, 2, 3)
.len()
, range()
, etc.def function_name():
to define a custom function.