Write your first Python program
Start with variables, lists, loops and functions. Use fictional study-session data; never publish classmates' personal information in a notebook.
Break it down
01Practice: a study-time calculator
Represent five sessions as a list of minutes. Calculate total time, then put the calculation in a function. Test an empty list and one session. Explain the result before moving on.
def total_minutes(sessions):
return sum(sessions)
assert total_minutes([]) == 0
print(total_minutes([25, 30, 20]))02Checkpoint
You can run a file, read an error traceback and change the program without copying a complete solution. If programming is new to you, practice small exercises before using the official tutorial as a reference.
Take it further
Continue learning on these source websites.
Python: official tutorial (basic programming knowledge recommended)(opens in a new tab)