@@ -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+
713imran = 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.
0 commit comments