Aug 6, 2024
print("Hello, World!")
if condition:
# code to execute if condition is true
else:
# code to execute if condition is false
for item in sequence:
# code to execute for each item
while condition:
# code to execute while condition is true
def
keyword followed by the function name and parameters.return
statement.my_list = [1, 2, 3, 4]
my_dict = {'key1': 'value1', 'key2': 'value2'}
try:
# code that may raise an exception
except ExceptionType:
# code to handle the exception
open()
to read a file.r
(read), w
(write), a
(append).write()
or writelines()
to add content to a file.import
statement to include a module in your code.