Time | What |
---|---|
10:45 | Welcome, introduction, pair/team up |
10:50 | Together: setup: install tools, initialize the environment |
11:10 | Together: check setup + add parameters |
11:20 | In pairs/teams: return all trains + print available seats |
11:55 | Short check point |
12:00 | In pairs/teams: reserve a seat + further ideas or own ideas |
12:25 | Debrief, collect feedback, encourage to go on and find help on Slack |
We will use Python as the programming language and VS Code as the IDE/Editor in this course.
Both are quite popular tools, used by many developers. Having them setup will help you go further in getting into coding.
-
Login to AgileTD Zone Slack and join the channel
#lets-get-into-coding
-
Install Python and Virtual Studio Code from tools directory if necessary.
-
Clone this repo:
cd <wherever-you-want-your-project> git clone https://github.com/mkutz/lets-get-into-coding.git cd lets-get-into-coding/
-
Create a virtual environment in the cloned directory:
python3 -m venv venv --upgrade-deps
-
Activate the virtual environment:
source venv/bin/activate
-
You should now be able to run
python
(without3
):python --version
Should return something like
Python 3.11.4
. -
Install required packages:
pip install -r requirements.txt
-
Clone this repo:
cd <wherever-you-want-your-project> git clone https://github.com/mkutz/lets-get-into-coding.git cd lets-get-into-coding/
-
Create a virtual environment in the cloned directory:
python -m venv venv --upgrade-deps
-
Activate the virtual environment:
.\venv\Scripts\activate
-
You should now be able to run
python
(without3
):python --version
Should return something like
Python 3.11.4
. -
Install required packages:
pip install -r requirements.txt
Content:
-
Open 1-hello-wold.py in VS Code and understand its content.
Feel free to ask any questions you might have! -
Open a termin in VS code (Menu: Terminal โ New Terminal).
It should appear at the lower end of the VS code window. -
Enter the following in the terminal:
python 1-hello-world.py
The output should be
Hello World!
Please ask for help if it doesn't work.
Content:
- argument passing, sys.argv
print
- strings, optionally formatted string literals
- lists, sequence types, len
if
/else
statements
-
Open 2-hello-you.py.
-
Change the code to take an argument, which is printed instead of "World".
E.g. for
python 2-hello-you.py "AgileTD"
it should printHello, AgileTD!
-
If no argument is given (
python 2-hello-you.py
), printHello, you!
-
If more then one argument is given (e.g.
python 2-hello-you.py Stefan Micha
), printHello, Stefan and Micha!
Content:
-
Start the train reservation service by running
python train_reservation/main.py
This will start a simple train reservation service with in-memory data, using port 8080.
See the service's README.md if you run in any problems.
-
Open 3-request-trains.py.
-
Add code to list all available trains and print them in the following format:
๐ local_1000 ๐ express_2000
Content:
- dictionaries
filter
function (optional)
-
Take a train's name as an argument (e.g.
python 4-request-available-seats.py "local_1000"
).Make sure the train name is valid. Print an error message if it is not.
E.g.
python 4-request-available-seats.py "unknown_3000"
should return something like๐ unknown_3000 is unknown!
-
Now get the details of the requested train and extract the seats.
-
Print all seat numbers which are still available (have a empty
booking_reference
).E.g.
python 4-request-available-seats.py "express_2000"
should return something like๐บ 1A ๐ด ๐บ 2A ๐ข ๐บ 3A ๐ข ๐บ 4A ๐ข ๐บ 5A ๐ข ๐บ 6A ๐ข ๐บ 7A ๐ข ๐บ 8A ๐ข ๐บ 1B ๐ข ๐บ 2B ๐ด ๐บ 3B ๐ข ๐บ 4B ๐ข ๐บ 5B ๐ข ๐บ 6B ๐ข ๐บ 7B ๐ข ๐บ 8B ๐ข
Content:
-
Open 5-request-reservation.py.
-
Add a parameter for the seat you want to reserve.
E.g. to reserve seat "6B" on train "local_1000", we want to use
python 5-request-reservation.py local_1000 6B
-
Again, check the inputs to be valid and print error messages if they aren't.
-
Reserve the requested seat by
-
posting the booking reference in a JSON object like
{ "train_id": "<requested_train>", "seats": ["<requested_seat>"], "booking_reference": "<booking_reference>" }
E.g.
{ "train_id": "local_1000", "seats": ["6B"], "booking_reference": "01234567" }
-
If successful, print the booking reference; otherwise print an error message.
E.g. print
๐ local_1000 ๐บ 2C ๐ซ 1234567a1
- Create a script that creates some random bookings
- Use functions to structure your scripts (e.g.
verify_train_id(train_id)
,book_seat(train_id, seat_number)
) - Create a reservation script that asks for train_id and seat_number, instead of using call parameters
- Write some unit tests for your scripts
- Print a list which for each train lists the percentage of reserved seats per coach, and for the whole train
- Create a script that books a specified number of seats in a specified train
- Use train_data_service for code reading
- Add support for POST /train-data/reset to train_data_service, resetting all train data