Giter Club home page Giter Club logo

lets-get-into-coding's Introduction

Let's get Into Coding

Agenda

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

Setup

1. Install the Tools

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.

  1. Login to AgileTD Zone Slack and join the channel #lets-get-into-coding

  2. Install Python and Virtual Studio Code from tools directory if necessary.

2. Initialize the Environment

Linux and macOS

  1. 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/
  2. Create a virtual environment in the cloned directory:

    python3 -m venv venv --upgrade-deps
  3. Activate the virtual environment:

    source venv/bin/activate
  4. You should now be able to run python (without 3):

    python --version

    Should return something like Python 3.11.4.

  5. Install required packages:

    pip install -r requirements.txt

Windows

  1. 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/
  2. Create a virtual environment in the cloned directory:

    python -m venv venv --upgrade-deps
  3. Activate the virtual environment:

    .\venv\Scripts\activate
  4. You should now be able to run python (without 3):

    python --version

    Should return something like Python 3.11.4.

  5. Install required packages:

    pip install -r requirements.txt

Objectives

1. Check Your Setup

Content:

  1. Open 1-hello-wold.py in VS Code and understand its content.
    Feel free to ask any questions you might have!

  2. Open a termin in VS code (Menu: Terminal โ†’ New Terminal).
    It should appear at the lower end of the VS code window.

  3. 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.

2. Add Parameters

Content:

  1. Open 2-hello-you.py.

  2. Change the code to take an argument, which is printed instead of "World".

    E.g. for python 2-hello-you.py "AgileTD" it should print

    Hello, AgileTD!
    
  3. If no argument is given (python 2-hello-you.py), print

    Hello, you!
    
  4. If more then one argument is given (e.g. python 2-hello-you.py Stefan Micha), print

    Hello, Stefan and Micha!
    

3. Return all Trains

Content:

  1. 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.

  2. Open 3-request-trains.py.

  3. Add code to list all available trains and print them in the following format:

    ๐Ÿš† local_1000
    ๐Ÿš† express_2000
    

4. Print Available Seats in Train

Content:

  1. Open 4-request-available-seats.py.

  2. 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!
    
  3. Now get the details of the requested train and extract the seats.

  4. 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 ๐ŸŸข
    

5. Reserve a Seat

Content:

  1. Open 5-request-reservation.py.

  2. 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

  3. Again, check the inputs to be valid and print error messages if they aren't.

  4. Reserve the requested seat by

    1. getting a booking reference, and

    2. 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"
      }
  5. If successful, print the booking reference; otherwise print an error message.

    E.g. print

    ๐Ÿš† local_1000 ๐Ÿ’บ 2C ๐ŸŽซ 1234567a1
    

Further Ideas

  • 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

Resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.