By @alesanchezr and other contributors at 4Geeks Academy
Estas instrucciones también están disponibles en Español 🇪🇸
Practice writing small functions that receive values, compute with numbers and return a result. You will use arithmetic operators (+ - * / ** // %), the math module, rounding, conditionals and simple loops to solve everyday problems.
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 | 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 (📍 you are here) | 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 Lists and Loops
➡️ Next: Master Python: Strings and Collections
Open in Codespaces.
Once VS Code is open, LearnPack should start automatically. If it doesn't, run
learnpack startin the terminal.
-
Install LearnPack, the Python plugin and the testing tools:
npm i @learnpack/learnpack -g && learnpack plugins:install @learnpack/python
pip3 install pytest==6.2.5 pytest-testdox mock- Clone this repository and start the exercises:
git clone https://github.com/4GeeksAcademy/master-python-functions-exercises.git
cd master-python-functions-exercises
learnpack start- Exercises:
001-026 - Focus: defining functions, parameters,
return(including several values), arithmetic operators, integer division and modulo, themathmodule, rounding, conditionals and simple loops - Difficulty: beginner
Each exercise folder contains:
README.md/README.es.md: the instructions (English / Spanish).app.py: the starter file where you write your solution.test.py: the automatic grading tests. You don't need to open it, but you can read it if you are stuck.
Click Run to execute your app.py and Test to grade it.
These exercises were originally part of Master Python. Thanks to Alejandro Sánchez (alesanchezr), Paolo (plucodev), Marco Gómez (marcogonzalo) and every contributor. Found a typo or a bug? Open an issue.