An applied Python coding assessment demonstrating real-world algorithmic logic across e-commerce discount mechanics, ETL string parsing & KYC applicant validation, and enterprise performance-driven payroll compensation modeling.
- π Overview
- π― Core Competencies Assessed
- πΌ Real-World Scenarios & Solutions
- π Business Logic Architecture
- π» Getting Started & Execution
- π€ Author & Connect
In modern analytics engineering, Python is frequently used to transform dirty operational inputs, enforce validation boundaries, and calculate dynamic financial metrics. This repository showcases solutions to 3 realistic enterprise problem domains:
- Dynamic Cart Invoicing: Handling multi-tiered discounts, string coupon normalization, and customer tier exemptions.
- Data Cleansing & KYC Screening: Splitting raw delimited logs, typecasting, validating integrity, and executing compliance checks.
- Incentive Compensation Systems: Multi-variable KPI rate calculations, CSAT score quality gates, and bonus payouts.
- String Manipulation & Sanitization: Using
.strip(),.lower(),.title(), and.split()to parse unstructured or dirty strings into structured variables. - Type Safety & Data Integrity: Guarding against casting crashes using
.isdigit()prior to numeric conversion. - Compound Financial Logic: Applying percentage-based thresholds and compounding promotional incentives.
- Conditional Quota Attainment: Calculating achievement ratios and segmenting employees into discrete performance tiers.
Business Case: Calculate an order's net checkout total by applying spending threshold discounts (10% on orders save15), and waiving delivery fees for VIP subscribers.
total_spent = 1200.0
promo_code = " save15 "
is_vip = False
# 1. Base threshold discount
base_discount_rate = 0.0
if total_spent >= 1000:
base_discount_rate = 0.10
# 2. Promo code normalization & application
promo_bonus = 0.0
cleaned_promo = promo_code.strip().lower()
if cleaned_promo == "save15":
promo_bonus = 0.15
# 3. Discount calculation
total_discount_rate = base_discount_rate + promo_bonus
discount_amount = total_spent * total_discount_rate
# 4. VIP shipping fee policy
shipping_fee = 0.0
if not is_vip:
shipping_fee = 50.0
final_total = total_spent - discount_amount + shipping_fee
print("=== CUSTOMER CHECKOUT SUMMARY ===")
print("Original Amount : EGP " + str(total_spent))
print("Discount Rate : " + str(total_discount_rate * 100) + "%")
print("Discount Amount : EGP " + str(discount_amount))
print("Shipping Fee : EGP " + str(shipping_fee))
print("Final Total : EGP " + str(final_total))=== CUSTOMER CHECKOUT SUMMARY ===
Original Amount : EGP 1200.0
Discount Rate : 25.0%
Discount Amount : EGP 300.0
Shipping Fee : EGP 50.0
Final Total : EGP 950.0
Business Case: Ingest a raw, pipe-delimited data string representing applicant information (" 8801 | mohamed ali | 24 "), extract constituent fields, clean whitespace, title-case names, validate age datatype, and apply compliance age gates (
raw_user_record = " 8801 | mohamed ali | 24 "
# 1. Delimited tokenization & normalization
fields = raw_user_record.split("|")
user_id = fields[0].strip()
full_name = fields[1].strip().title()
age_str = fields[2].strip()
age_value = 0
application_status = ""
# 2. Datatype validation & compliance checks
is_valid_age = age_str.isdigit()
if is_valid_age:
age_value = int(age_str)
if is_valid_age and age_value >= 21:
application_status = "APPROVED"
if is_valid_age and age_value < 21:
application_status = "REJECTED: Underage"
if not is_valid_age:
application_status = "ERROR: Invalid Age Format"
print("=== APPLICANT VERIFICATION ===")
print("User ID : " + str(user_id))
print("Full Name : " + full_name)
print("Age : " + str(age_value))
print("Application : " + application_status)=== APPLICANT VERIFICATION ===
User ID : 8801
Full Name : Mohamed Ali
Age : 24
Application : APPROVED
Business Case: Evaluate sales executive performance by calculating quota achievement percentage ($125,000 /
base_salary = 15000.0
sales_target = 100000.0
sales_achieved = 125000.0
csat_score = 4.8
achievement_rate = sales_achieved / sales_target
performance_rating = "Needs Improvement"
bonus_percentage = 0.0
# Performance tier & bonus tier evaluation
if achievement_rate >= 1.00:
performance_rating = "Meets Expectations"
bonus_percentage = 0.10
if achievement_rate >= 1.20 and csat_score >= 4.5:
performance_rating = "Exceeds Expectations"
bonus_percentage = 0.20
calculated_bonus = base_salary * bonus_percentage
# Quality penalty thresholding
if csat_score < 3.0:
calculated_bonus = calculated_bonus * 0.5
total_payout = base_salary + calculated_bonus
print("=== EMPLOYEE PAYROLL EVALUATION ===")
print("Achievement Rate : " + str(achievement_rate * 100) + "%")
print("Performance Tier : " + performance_rating)
print("Calculated Bonus : EGP " + str(calculated_bonus))
print("Total Payout : EGP " + str(total_payout))=== EMPLOYEE PAYROLL EVALUATION ===
Achievement Rate : 125.0%
Performance Tier : Exceeds Expectations
Calculated Bonus : EGP 3000.0
Total Payout : EGP 18000.0
| Scenario | Input Parameters | Validation / Logic Gates | Output Metrics |
|---|---|---|---|
| 1. Checkout Engine | Spend, Promo Code, VIP Flag | Spend 'save15' |
Net Payable Total |
| 2. KYC ETL Pipeline | Pipe-Delimited String | Whitespace trim, .isdigit(), Age |
Verification Status Flag |
| 3. Payroll Model | Target, Actual Sales, CSAT Score | Rate |
Total Compensation |
Click the badge below to run the notebook instantly in Google Colab:
-
Clone the repository:
git clone https://github.com/islamyasser424-design/Python-Quiz-01.git cd Python-Quiz-01 -
Launch Jupyter:
jupyter notebook Python_Quiz_01.ipynb
Islam Yasser
Data Analyst & Business Intelligence Specialist
- π Portfolio Website: islamyasser424-design.github.io/portfolio-
- πΌ LinkedIn Profile: linkedin.com/in/islam-yasser-55048b378
- π GitHub Profile: @islamyasser424-design
- βοΈ Email: islamyasser424@gmail.com
Part of the Python Programming & Data Analytics Portfolio series. Built with clean code standards and verified business logic.