Skip to content

Commit b79490c

Browse files
author
l
committed
make the instructions consistent with curriculum
1 parent 6d29a8c commit b79490c

16 files changed

Lines changed: 103 additions & 100 deletions

‎sprint-5/01-predict.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def double(value):
77
def second(value):
88
return value[1]
99

10+
# TASK 1:
1011
# 1. Predict what you think will happen with each of the following functions
1112
# 2. Then, test it, and explain in your own words what is actually happening and why
1213
# (feel free to comment out lines if you think they cause errors or crashes while testing)

‎sprint-5/02-playcomputer.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ rl.question("What URL should we fetch?\n> ", async (url) => {
2424
rl.close();
2525
});
2626

27-
// Task: Leave a comment on any line that you can see has some errors explaining what you think the problem is
27+
// TASK 2
28+
// Read through this file and predict what it does.
29+
// Leave a comment on any lines if you spot any errors, offering an explanation of the problem.

‎sprint-5/03-fix.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def double(number):
33

44
print(double(10))
55

6-
# Task:
7-
# What is the bug here?
8-
# How could you fix it?
9-
# Are there multiple possible ways to fix it?
6+
# TASK 3:
7+
# Read the code and see if you can find any bugs.
8+
# Write down what the bug is, and how would you fix it?
9+
# Are there multiple ways you could fix it?

‎sprint-5/04-addmypy.py‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ def format_pence_as_string(total_pence):
2929

3030
print(f"The bank accounts total {total_string}")
3131

32-
# TASK
32+
# TASK 4
3333
# This code contains bugs related to types. They are bugs mypy can catch.
34-
#
35-
# 1. Read this code to understand what it's trying to do.
36-
# 2. Install and set up mypy in a python virtual environment
37-
# 3. Add type annotations everywhere appropriate
38-
# 4. Run `mypy 04-addmypy.py`, and fix any errors
39-
# 5. When you're confident all of the type annotations are correct, and the bugs are fixed, run the code and check it works.
34+
# Read this code to understand what it's trying to do.
35+
# Add type annotations to the method parameters and return types of this code.
36+
# Run the code through mypy, and fix all of the bugs that show up.
37+
# When you're confident all of the type annotations are correct, and the bugs are fixed, run the code and check it works.

‎sprint-5/05-predict.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
print(imran["name"])
1515
print(imran["address"])
1616

17-
# Task:
18-
# Try running mypy on this file and see what happens
19-
# Predict what do you think will happen when you run this task?
17+
# TASK 5:
18+
# This code contains some untyped objects.
19+
# Try checking it with mypy before running the code and predict what you think will happen when you run the code.
20+
#
21+
# Prediction:
22+
#
2023
# Can you explain what actualy happens?
24+
#

‎sprint-5/06-classes.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ def __init__(self, name: str, age: int, preferred_operating_system: str):
1212
print(eliza.name)
1313
print(eliza.address)
1414

15-
# Task 6.1:
16-
# Run mypy on this code
17-
# Fix the code so there are no errors in mypy or when it runs
15+
# TASK 6.1:
16+
# Run mypy and fix any errors.
1817

19-
# Task 6.2:
18+
# TASK 6.2:
2019
# Create a new function in this file called likes_apple
2120
# It should take a person as parameter
2221
# It returns true if the preferred operating system is "macOS" or "iOS"
2322
# It should return false for any other preferred os
2423
# Add all the appropriate type annotations and test it has no errors in mypy
2524

26-
# Task 6.3:
25+
# TASK 6.3:
2726
# Compare objects and classes
2827
# What are some advantages and disadvantages of each?

‎sprint-5/07-methods.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Answer the following question:
1+
TASK 7:
2+
Answer the following questions:
23
What is the difference between a method and a function?
34
Can you give some advantages of methods over functions?
45

‎sprint-5/08-implement.py‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,25 @@ def __init__(self, name: str, age: int, preferred_car_brand: str):
44
self.age = age
55
self.preferred_car_brand = preferred_car_brand
66

7+
def drivers_license_check(person: Person):
8+
if person.is_adult() == True:
9+
return 'Valid drivers license'
10+
11+
return 'This person is underage!'
12+
713
imran = Person("Imran", 22, "Mercedes")
8-
print(imran.is_adult())
14+
print(drivers_license_check(imran)) # should return 'Valid drivers license'
915

10-
# Task:
11-
# 1. Add the `drivers_license_check` free function and the `is_adult` method into the code
12-
# Make sure your code currently gives the expected output.
13-
#
14-
# 2. Change the `Person` class to take a date of birth
15-
# Use the standard library's `datetime.date` class
16-
# https://docs.python.org/3/library/datetime.html#datetime.date
17-
# Store the `date of birth` in a field instead of `age` (it should be a `str`)
16+
# TASK 8:
1817
#
19-
# 3. Try to run your code
20-
# How does this change break your code.
21-
# What kind of error do you get?
22-
# Is it helpful in identifying where your next change needs to be?
23-
# Type your thoughts here:
18+
# Add an `is_adult` method into the class, and make sure your code gives the expected output.
2419
#
20+
# Change the `Person` class to take a date of birth using
21+
# the standard library's `datetime.date` class
22+
# https://docs.python.org/3/library/datetime.html#datetime.date))
23+
# and store the `date of birth` instead of `age`.
2524
#
25+
# Try to run your code now and observe how this change breaks your code.
26+
# What kind of error do you get? Is it helpful in identifying where your next change needs to be?
2627
#
27-
#
28-
# 4. Update the `is_adult` method so the error is fixed.
29-
# Using the `drivers_license_check` function check everything runs as expected
30-
28+
# Now update only the `is_adult` method to fix the error and check everything works correctly.

‎sprint-5/09-encapsulation.py‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# TASK 9
2+
#
3+
# Having done some research on encapsulation, think about the benefits.
4+
#
5+
# Think of some examples and in your own words write down some benefits and trade-offs of using encapsulation in classes:
6+
#
7+
#
8+
#
9+
10+
# STRETCH TASK 9.1
11+
#
12+
# In the following class, make the name property private
13+
# Add a `get_name()` method to allow read-only access.
14+
115
class Person:
216
def __init__(self, name: str, age: int):
317
self.name = name
@@ -17,18 +31,3 @@ def is_adult(self):
1731
print(eliza.age) # fails
1832
print(imran.__age) # fails
1933
print(eliza.is_adult()) # works and prints False
20-
21-
# Task 9
22-
# Read through Python encapsulation
23-
# https://www.w3schools.com/python/python_encapsulation.asp
24-
# and think about some of the benefits that encapsulation can add to a class.
25-
#
26-
# Do some further research of your own to learn about encapsulation.
27-
#
28-
# Think of some examples and in your own words write down some benefits and trade-offs of using encapsulation in classes:
29-
#
30-
#
31-
#
32-
33-
# Stretch Task
34-
# Make the name property private, and add a get_name() method to make it read only.

‎sprint-5/10-dataclass.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
# Task 9.1:
1+
# TASK 10.1:
22
# Copy the code you have so far from task 08-implement.py
3-
# Convert this to a dataclass
4-
# Test that the dataclass works with mypy, with equality checks
3+
# Convert your existing `Person` class from task 8 into a value type using `@datatype`
4+
# so you can print the class (and see it's type and properties)
5+
# and compare class instances that are identical.
6+
# Make sure your `is_adult` method and `drivers_license_check` free function both work as normal.
57

6-
# Task 9.2:
7-
# Add a greeting method that says "Hello, <person name>!"
8+
# TASK 10.2:
9+
# Make a new method on your Person class - `greet()` which should return `"Hello <person name>!"` when used.
810

9-
# Task 9.3:
11+
# TASK 10.3:
1012
# Read the @datatype documentation here: https://docs.python.org/3/library/dataclasses.html
11-
# Explain what does `frozen=True` do to the class?
13+
# Explain what `frozen=True` does to the class?
1214
# What other options could you play around with and explore? Offer suggestions for any that would be useful here.

0 commit comments

Comments
 (0)