๐ Python Functions Tutorial and Exercises
By @alesanchezr and other contributors at 4Geeks Academy

Estas instrucciones estรกn disponibles en ๐ช๐ธ espaรฑol ๐ช๐ธ
Learn and practice Python Functions. You will see the following concepts:
-
Declaring a function.
-
Calling a function.
-
Function scopes.
-
Nest functions.
-
Recursive functions and many other functional concepts.
Note: The entire tutorial is ๐ interactive, โ
auto-graded and with ๐น video tutorials.
These exercises were built in collaboration, we need you! If you find any bugs or misspellings, please contribute and report them.
๐บ๏ธ Python practice path
This LearnPack is part of a series. We recommend completing them in order:
| # |
LearnPack |
What you practice |
| 1 |
Python for Beginners |
print, variables, input and basic operations |
| 2 |
Python Functions (๐ you are here) |
defining and calling functions, parameters and return |
| 3 |
Python Lists and Loops |
lists, for/while loops and iteration patterns |
| 4 |
Master Python: Functions and Numbers |
functions, arithmetic operators, the math module, conditionals and simple loops |
| 5 |
Master Python: Strings and Collections |
strings, lists, tuples, dictionaries, sets, comprehensions and sorting |
| 6 |
Master Python: Classes and OOP |
classes, special methods, inheritance, properties, composition, dataclasses and iterators |
โฌ
๏ธ Previous: Python for Beginners
โก๏ธ Next: Python Lists and Loops
One click installation (recommended):
You can open these exercises in just a few seconds by clicking: Open in Codespaces (recommended) or Open in Gitpod.
Once you have VSCode open, the LearnPack exercises should start automatically. If exercises don't run automatically you can try typing on your terminal: $ learnpack start
Local Installation
- Make sure you have LearnPack installed, node.js version 14+, and Python version 3+. This is the command to install LearnPack:
$ npm i -g @learnpack/learnpack@2.1.20 && learnpack plugins:install @learnpack/python@1.0.0
- Clone or download this repository in your local environment.
$ git clone https://github.com/4GeeksAcademy/python-functions-programming-exercises.git
$ cd python-functions-programming-exercises
Note: Once you finish downloading, you will find an "exercises" folder that contains all the exercises within.
- Start the tutorial/exercises by running the following command from the root of the project:
$ pip3 install pytest==6.2.5 pytest-testdox mock
$ learnpack start
How are the exercises organized?
Each exercise is a small Python application containing the following files:
- app.py: represents the entry Python file that will be executed by the computer.
- README.md: contains exercise instructions.
- test.py: you don't have to open this file, it contains the testing script for the exercise.
Note: The exercises have automatic grading, but it's very rigid and strict, my recommendation is to not take the tests too serious and use them only as a suggestion, or you may get frustrated.
Contributors
Thanks to these wonderful people (emoji key):
-
Alejandro Sanchez (alesanchezr), contribution: (coder) ๐ป, (idea) ๐ค, (build-tests) โ ๏ธ, (pull-request-review) ๐, (build-tutorial) โ
(documentation) ๐
-
Paolo (plucodev), contribution: (bug reports) ๐, (coder) ๐ป, (translation) ๐
-
Marco Gรณmez (marcogonzalo), contribution: (bug reports) :๐, (translation) ๐
This project follows the all-contributors specification.
Contributions of any kind are welcome!
This and many other exercises are built by students as part of the 4Geeks Academy Coding Bootcamp by Alejandro Sรกnchez and many other contributors. Find out more about our Full Stack Developer Course, and Data Science Bootcamp.