diff --git a/assets/plan_01_topview.png b/assets/plan_01_topview.png new file mode 100644 index 0000000..e0fbee1 Binary files /dev/null and b/assets/plan_01_topview.png differ diff --git a/assets/plan_02_topview.png b/assets/plan_02_topview.png new file mode 100644 index 0000000..81f284f Binary files /dev/null and b/assets/plan_02_topview.png differ diff --git a/assets/plan_03_3d.png b/assets/plan_03_3d.png new file mode 100644 index 0000000..854321d Binary files /dev/null and b/assets/plan_03_3d.png differ diff --git a/assets/plan_03_topview.png b/assets/plan_03_topview.png new file mode 100644 index 0000000..b3369fd Binary files /dev/null and b/assets/plan_03_topview.png differ diff --git a/learning_python3.md b/learning_python3.md index 80245b3..63f1556 100644 --- a/learning_python3.md +++ b/learning_python3.md @@ -2100,7 +2100,46 @@ Take the additional class you made, such as vehicle and do some inheritance. For vehicles you could create a base class with a brand and number of wheels and seats. Then inherit for a bus, bike, car, cycle, etc. -## A *practical* example +# Coding challenge - Chalet floor + +Can you calculate me how much wood I need to order to build the base of my chalet? +I have three different plans, you can see below. +The idea behind this exercise is to create a `class` for each *base* shape. +If you implement the *right* methods you can add, subtract, multiply your shapes as you wish. +I created a library and imported it in my python shell so I can do the following. + +```python +>>> import shapes +>>> sq1 = shapes. +shapes.Circle( shapes.Rectangle( shapes.Shape( shapes.Square( shapes.Triangle( shapes.math +>>> sq1 = shapes.Square(400) +>>> cr1 = shapes.Circle(30) +>>> re1 = shapes.Rectangle(400, 600) +>>> total = sq1 + re1 - cr1 +>>> print(total) +I'm a Shape with an area of 397172.57 cm2 +>>> print(re1) +I'm a Rectangle with an area of 240000.00 cm2 +>>> print(cr1) +I'm a Circle with an area of 2827.43 cm2 +>>> print(sq1) +I'm a Square with an area of 160000.00 cm2 +>>> +``` + +There are quite a few things in this exercise we have not seen in detail, so don't hesitate to research online and ask questions! +This is a quite **advanced** challenge so you can be very proud of yourself if you understand the solution! + +![first plan](./assets/plan_01_topview.png) + +![second plan](./assets/plan_02_topview.png) + +![third plan](./assets/plan_03_topview.png) + +![third plan 3D view](./assets/plan_03_3d.png) + +
+ Spoiler warning ```python import math @@ -2167,6 +2206,8 @@ if __name__ == "__main__": print(combi) ``` +
+ ## Now some *practical* improvements ### Improve the login generator