A progressive set of hands‑on challenges—simple → intermediate → advanced—to sharpen your Python fundamentals before Python_For Pentesters_Basics and beyond.
# | Exercise | Goal / Instructions |
---|---|---|
1 | Calculate the Factorial of a Number | Ask the user for a positive integer → use a loop to compute n! → return & print the result. |
2 | Sum of Digits of a Number | Ask for an integer → treat it as a string → loop & sum the digits → print the total. |
3 | Find the Minimum and Maximum in a List | Ask for a list → use min() / max() → display both values. |
4 | Average of Several Numbers | Ask for numbers → compute sum / len → print the average. |
5 | Generate a Multiplication Table | Ask for a base number & limit → loop and print n × i for each i. |
6 | Solve a First‑Degree Equation (ax + b = 0) | Ask for a, b → if a ≠ 0, solve x = −b/a; else decide no / infinite solutions. |
7 | Sum of Squares in a List | Ask for a list → square each → sum & print. |
8 | Average of Even Numbers in a List | Ask for a list → filter evens → average them or report none. |
9 | Check if a List is Increasing | Verify each element is ≤ the next → print whether ascending. |
# | Exercise | Goal / Instructions |
---|---|---|
10 | Find Prime Numbers in a List | Write is_prime() → apply to the list → display primes. |
11 | Find Multiples in a Range | Given n, a, b → loop a…b → collect numbers divisible by n. |
12 | Calculate the GCD (Euclid’s Algorithm) | Ask for two integers → use Euclid’s method → print the GCD. |
13 | Generate Fibonacci Sequence | Ask for n → loop to build the sequence → print it. |
14 | Find Perfect Numbers in a List | Sum proper divisors → keep numbers equal to that sum → display them. |
15 | Celsius ↔ Fahrenheit Converter | Ask conversion direction → apply C → F or F → C formula → print result. |
# | Exercise | Goal / Instructions |
---|---|---|
16 | Implement Selection Sort | Repeatedly find the smallest element & move it front using list.remove() → print sorted list. |
17 | Check if a String is a Palindrome | Ignore spaces / punctuation / case → state if it’s a palindrome. |
18 | Solve a Quadratic Equation | Ask for a, b, c → compute Δ = b² − 4ac → output real or complex roots. |
# clone the repo
git clone https://github.com/your-username/python_practice.git
cd python_practice
# run any exercise
python simple_exercises/ex01_factorial.py