Last part of articles about the Microsoft's Python for Beginners series.
All the examples from the playlist are available in this GitHub repository: Python Examples.
Objective
You will learn how to make connect with web APIs, manipulate dictionaries, read environment variables and use decorators.
A Python file was created to demonstrate each example.
Topics
api/post.py
Making a POST request to a web API.
The example file was created inside of a folder named api.
First, install the requests library:
pip install requests
The result will be:
Then, run this command:
python .\examples\api\post.py
The result will be:
dictionary.py
Creating and manipulating dictionaries.
Executing the command below:
python .\examples\dictionary.py
The result is:
keys.py
Reading environment variables.
Create a .env file containing a secret key.
Update the requirements.txt file by adding python-dotenv.
Let's use a virtual environment again by executing the commands below:
python -m venv venv
.\venv\Scripts\Activate.ps1
Install the python_dotenv package inside the venv:
pip install -r requirements.txt
The result will be:
Finally, run this command:
python .\examples\keys.py
The result will be:
decorators.py
How to use decorators in functions.
Run the command:
python .\examples\decorators.py
The result will be:
Conclusion
We have finally ended this series!
Now you have the basics to start working with Python.
Top comments (0)