Sunday, August 24, 2025

#3 Module 1 Colab

Ready-to-use Colab notebook content (you can copy-paste into a .ipynb or open directly in Colab):


📘 Python for Civil Engineering – Module 1: Basics

# Module 1: Python Foundations for Engineers This notebook covers: 1. Factor of Safety (FoS) 2. BMI Calculator 3. Simple Interest 4. Material Quantity Estimation (Loop Example)

🔹 1. Factor of Safety

# Factor of Safety Calculation def factor_of_safety(strength, stress): if stress == 0: return "Stress cannot be zero!" return strength / stress # Example usage strength = float(input("Enter material strength (N/mm²): ")) stress = float(input("Enter applied stress (N/mm²): ")) fos = factor_of_safety(strength, stress) print(f"Factor of Safety = {fos:.2f}") if isinstance(fos, float): if fos >= 1.5: print("✅ Safe design") else: print("⚠️ Not safe, redesign required")

🔹 2. BMI Calculator (Worker Health Check)

# BMI Calculation def bmi(weight, height): return weight / (height ** 2) weight = float(input("Enter weight (kg): ")) height = float(input("Enter height (m): ")) bmi_value = bmi(weight, height) print(f"BMI = {bmi_value:.2f}") if bmi_value < 18.5: print("Underweight ❗") elif 18.5 <= bmi_value < 24.9: print("Normal ✅") elif 25 <= bmi_value < 29.9: print("Overweight ⚠️") else: print("Obese 🚨")

🔹 3. Simple Interest (Finance in Construction Projects)

# Simple Interest Calculator def simple_interest(principal, rate, time): return (principal * rate * time) / 100 p = float(input("Enter Principal Amount (₹): ")) r = float(input("Enter Rate of Interest (%): ")) t = float(input("Enter Time (years): ")) si = simple_interest(p, r, t) print(f"Simple Interest = ₹{si:.2f}") print(f"Total Amount Payable = ₹{p + si:.2f}")

🔹 4. Material Quantity Estimation (Loop Example)

# Calculate volume of multiple beams (loop example) n = int(input("Enter number of beams: ")) total_volume = 0 for i in range(n): print(f"\nBeam {i+1}") length = float(input(" Enter length (m): ")) breadth = float(input(" Enter breadth (m): ")) depth = float(input(" Enter depth (m): ")) volume = length * breadth * depth total_volume += volume print(f" Volume = {volume:.2f} m³") print(f"\nTotal Concrete Volume for {n} beams = {total_volume:.2f} m³")

✅ Now you can upload this as a Colab notebook.

No comments:

Post a Comment

#6 Civil Applications using Python

 Let’s dive deeper into civil engineering applications with Python . I’ll give you detailed, explained code for three real-world tasks: ...