The maintainer has not written a description at the source.
Model momentarek1/Python_Assignment, read from Hugging Face 1 min ago.
momentarek1/Python_Assignment is a model on Hugging Face by momentarek1. It declares no license on Hugging Face. Public does not mean open source: without a license, nobody is granted the right to reuse it. It has 0 likes and last changed on 2026-08-22. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from Hugging Face on 2026-11-22.
The author's own card, shown from Hugging Face. Take My Repo does not keep a copy.
This repository contains three Jupyter Notebooks covering Python fundamentals, Object-Oriented Programming, recursion, functional programming, decorators, control flow, list comprehensions, and algorithmic problem solving.
The notebooks are designed as practical exercises with a focus on clean, readable, typed, documented, and PEP 8-compliant Python code.
The project is divided into three notebooks:
| Notebook | Main Topics |
|---|---|
01_OOP_Class_and_Inheritance.ipynb |
Abstract Classes, Inheritance, Encapsulation |
02_Functions_Recursion_Lambda_Decorators.ipynb |
Functions, Expression Parsing, Recursion, Lambda, Higher-Order Functions, Decorators |
03_Python_Control_Flow_and_Data_Analysis.ipynb |
Match-Case, Loops, List Comprehensions, Lists, Collatz Conjecture |
The first notebook focuses on Object-Oriented Programming (OOP) concepts, particularly:
An abstract Shape class is created as the base representation for geometric shapes.
The class provides an area() method that must be implemented by subclasses.
Conceptually:
Shape
โ
โโโ Rectangle
The Shape class defines the expected interface while leaving the actual area calculation to the child class.
Rectangle inherits from Shape and represents a rectangle using:
width
height
The dimensions are stored as private attributes:
self.__width
self.__height
The class implements:
Area = width ร height
Perimeter = 2 ร (width + height)
The notebook demonstrates how private attributes can prevent direct modification of internal object state.
Instead of exposing:
rect.__width
the class can provide controlled access through properties.
This allows code such as:
print(rect.width)
print(rect.height)
and controlled assignment such as:
rect.width = 10
rect.height = 20
while keeping the actual attributes private.
Object-Oriented Programming
โ
โโโ Classes
โโโ Inheritance
โโโ Abstraction
โโโ Encapsulation
โโโ Private Attributes
โโโ Properties
โโโ Method Overriding
The second notebook contains four advanced Python exercises.
Implement:
evaluate_expression(expr)
to evaluate mathematical expressions containing:
+
-
*
/
(
)
without using:
eval()
or similar built-in expression evaluators.
The evaluator follows standard mathematical precedence:
Parentheses
โ
Multiplication / Division
โ
Addition / Subtraction
For example:
evaluate_expression("3+5*2-8/4")
produces:
10.0
because:
5 ร 2 = 10
8 / 4 = 2
3 + 10 - 2 = 11
Note: If the intended expected result is
10.0, the example expression or expected output should be corrected; standard PEMDAS gives 11.0.
Instead of relying on eval(), the expression is processed manually.
The parser identifies:
A match-case statement can be used to apply the appropriate arithmetic operation.
The implementation is expected to handle invalid input such as:
Invalid characters
Malformed expressions
Division by zero
Unbalanced parentheses
Missing operands
Implement:
fibonacci_sequence(n)
which returns the first n Fibonacci numbers.
The Fibonacci sequence is defined as:
F(0) = 0
F(1) = 1
F(n) = F(n-1) + F(n-2)
Example:
fibonacci_sequence(10)
returns:
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
The exercise demonstrates how a sequence can be constructed recursively.
A naive implementation repeatedly calculates the same Fibonacci values and becomes inefficient for large inputs.
Therefore, the notebook explores optimization techniques such as:
The function validates that:
n is an integer
n >= 0
Invalid values should raise an appropriate exception.
A list of student dictionaries is processed using functional programming techniques.
Example structure:
students = [
{"name": "Alice", "age": 20, "grade": 88},
{"name": "Bob", "age": 19, "grade": 75},
{"name": "Charlie", "age": 22, "grade": 93},
{"name": "David", "age": 21, "grade": 85},
]
The notebook performs three operations.
Students are sorted by grade in descending order using a lambda function.
Charlie โ 93
Alice โ 88
David โ 85
Bob โ 75
The user provides a minimum age.
Students younger than that age are removed using:
filter()
with a lambda function.
For:
minimum age = 20
the result is:
Charlie
Alice
David
The average grade is calculated from the filtered students using a combination of:
lambda
+
map/reduce
For the example:
93 + 88 + 85
---------------- = 88.666...
3
Lambda
โ
โโโ sorted()
โ
โโโ filter()
โ
โโโ map()
โ
โโโ reduce()
Create a reusable decorator:
validate_inputs
that validates function arguments before the function executes.
It is applied to:
calculate_power(base, exponent)
Must be:
int
or
float
Must be:
integer
and:
exponent >= 0
@validate_inputs
def calculate_power(base, exponent):
return base ** exponent
Valid:
calculate_power(2, 3)
Result:
8
Invalid:
calculate_power(5, -2)
or:
calculate_power("a", 2)
should raise:
ValueError
with an appropriate error message.
Function Call
โ
โผ
validate_inputs
โ
โโโ Valid โโโโโโโบ calculate_power()
โ
โโโ Invalid โโโโโบ ValueError
The third notebook focuses on fundamental Python programming techniques:
match-caseIt contains four exercises.
Create a calculator that accepts:
First number
Second number
Operator
Supported operators:
+
-
*
/
%
The operation is selected using Python's:
match-case
statement.
Enter the first number: 10
Enter the second number: 5
Enter an operator: /
Result: 2.0
The calculator handles:
Error: Cannot divide by zero.
Error: Invalid operator.
The program should also prevent crashes when the user enters non-numeric values.
Generate a sequential number pattern based on a user-provided n.
The implementation must use nested for loops.
For:
n = 10
the expected pattern is:
1
2 3
4 5 6
7 8 9 10
The program progressively increases the number of elements in each row.
Conceptually:
Row 1 โ 1 number
Row 2 โ 2 numbers
Row 3 โ 3 numbers
Row 4 โ 4 numbers
...
The process stops when adding another number would exceed n.
Given two integer lists:
list_a = [1, 2, 3, 4]
list_b = [3, 4, 5, 6]
the program calculates:
list_alist_b[3, 4]
list_a[1, 2]
list_b[5, 6]
Corresponding elements are compared:
|1 - 3| = 2
|2 - 4| = 2
|3 - 5| = 2
|4 - 6| = 2
Therefore:
2 + 2 + 2 + 2 = 8
Result:
Sum of differences: 8
The implementation uses:
list comprehensions
instead of sets.
It also handles lists with different lengths by comparing elements only up to the length of the shorter list.
The original lists remain unchanged.
Generate the Collatz sequence for a positive integer using a while loop.
The rules are:
n โ n / 2
n โ 3n + 1
The process continues until:
n = 1
Input:
6
Output:
[6, 3, 10, 5, 16, 8, 4, 2, 1]
Input n
โ
โผ
Is n > 0?
โ
โโโ No โ Ask again
โ
โโโ Yes
โ
โผ
Add n to list
โ
โผ
n == 1?
/ \
Yes No
โ โ
โผ โผ
Stop Is n even?
โ
โโโโโโดโโโโโ
โ โ
Yes No
โ โ
n/2 3n+1
โ โ
โโโโโโฌโโโโโ
โ
โผ
Repeat
The notebooks use standard Python functionality and do not require external machine-learning frameworks.
map()filter()reduce()sorted()All three notebooks follow the provided coding requirements.
Variables and function parameters/return values should use Python's typing system where appropriate.
Example:
def calculate_power(base: float, exponent: int) -> float:
...
Classes and public methods/functions include descriptive triple-quoted docstrings.
Example:
def fibonacci_sequence(n: int) -> list[int]:
"""Return the first n Fibonacci numbers."""
Multi-line comments are used where they improve understanding of:
Comments are intended to explain why something is being done rather than simply repeating the code.
The implementations aim to follow:
PEP 8
โ
โโโ Readability
โโโ Consistent naming
โโโ Type annotations
โโโ Documentation
โโโ Error handling
โโโ Maintainability
Python-Programming-Exercises/
โ
โโโ README.md
โ
โโโ notebooks/
โ โ
โ โโโ 01_OOP_Class_and_Inheritance.ipynb
โ โ
โ โโโ 02_Functions_Recursion_Lambda_Decorators.ipynb
โ โ
โ โโโ 03_Control_Flow_and_Algorithms.ipynb
โ
โโโ requirements.txt
Clone the repository:
git clone <repository-url>
cd Python-Programming-Exercises
Install Jupyter Notebook if needed:
pip install notebook
Start Jupyter:
jupyter notebook
Then open the notebooks from:
notebooks/
Alternatively, the notebooks can be opened directly using JupyterLab, Google Colab, or VS Code.
After completing these notebooks, the following concepts are covered:
Python Fundamentals
โ
โโโ Variables & Input
โโโ Conditions
โโโ Loops
โโโ Lists & Dictionaries
โ
โผ
Functions
โ
โโโ Normal Functions
โโโ Recursion
โโโ Lambda
โโโ Higher-Order Functions
โโโ Decorators
โ
โผ
Object-Oriented Programming
โ
โโโ Classes
โโโ Inheritance
โโโ Abstraction
โโโ Encapsulation
โ
โผ
Algorithmic Thinking
โ
โโโ Expression Parsing
โโโ Fibonacci
โโโ Pattern Generation
โโโ List Analysis
โโโ Collatz Conjecture
Python
Python Programming
OOP
Object-Oriented Programming
Classes
Inheritance
Abstraction
Encapsulation
Private Attributes
Functions
Recursion
Fibonacci
Lambda Functions
Higher-Order Functions
Decorators
Input Validation
Match-Case
List Comprehension
Loops
Nested Loops
Expression Evaluation
PEMDAS
Algorithms
Collatz Conjecture
Type Annotations
Docstrings
PEP 8
Jupyter Notebook
Python Programming & OOP Exercises is a collection of three practical notebooks designed to demonstrate Python programming from fundamental concepts to more advanced programming techniques.
The project progresses from:
Python Fundamentals
โ
Control Flow & Algorithms
โ
Functions & Recursion
โ
Functional Programming
โ
Decorators
โ
Object-Oriented Programming
โ
Clean & Maintainable Python
Together, the three notebooks provide hands-on practice in Python problem solving, OOP, functional programming, recursion, decorators, algorithms, and software development best practices.
momentarek1/Python_Assignment is a model on Hugging Face by momentarek1. Its maker has not written a description.
It declares no license on Hugging Face. Public does not mean open source: without a license, nobody is granted the right to reuse it.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on Hugging Face was on 2026-08-22. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.