https://google.github.io/styleguide/pyguide.html
- Make sure your code lints with Ruff Linter
- Include docstrings and comments to Google standard
- Use appropriate function and variable names
- Try to use type hints
student_grades = [85, 92, 78, 90, 88]
Find the average of the student grades.
What about if there were multiple students,
class_grades = [
[85, 90, 92], # student 1
[88, 82, 95], # student 2
[76, 89, 91] # student 3
]
Find each average of each student
Print the highest and lowest average.
This is a dictionary:
dict_directions = {
"foward": 10,
"left": 10,
"right": 10,
"back": 0
}
This is how you get a value given a key:
value = dict_directions["forward"]
Print out all of the movements the robot will take given that set of commands, e.g.
Forward
Forward
...
Imagine this robot is moving on a grid starting at (0,0)
. Work out the coordinates of where the robot ends up.
Given this coordinate, provide an optimised way to end up there.
from datetime import datetime, timedelta
# Example usage
due_date = datetime(2024, 3, 1)
return_date = datetime.now()
Calculate how many days overdue a book is
Calculate late fees (50p a day)
This is a class:
class BankAccount:
def __init__(self, name: str, balance: float = 0):
self.name = name
self.balance = balance
def deposit(self, amount: float):
self.balance += amount
Add a withdrawl method that also prevents the balance from dipping below 0.
Create multiple accounts and move money between them
Try to add interest rates (yearly), and history tracking (stretch)