Day 1 – Python Foundations for AEC Professionals


  

📐 Day 1 – Python Foundations for AEC Professionals

1. Learning Objectives

By the end of Day 1, you will be able to:

- Understand what Python is and why it’s used in architecture, engineering, and construction (AEC).
- Install Python and set up a coding environment (VS Code or Jupyter).
- Write your first Python script.
- Use variables to store real‑world AEC data (room dimensions, material costs, etc.).
- Work with basic data types: integers, floats, strings, booleans.
- Perform simple arithmetic and string operations relevant to building design.

2. Concept Explanation

2.1 What is Python?

Python is a high‑level, interpreted programming language known for its readability and vast ecosystem of libraries. 

 In the AEC world, Python is used to automate design calculations, generate parametric geometry, analyse structural systems, process BIM data (IFC), and script CAD/BIM tools (Rhino, Revit, Dynamo, Blender).

Key benefits for AEC professionals:

  • Rapid prototyping – test design ideas quickly.

  • Automation – replace repetitive spreadsheet or manual tasks.

  • Interoperability – connect different software (e.g., read Excel → compute → write CAD file).

  • Open‑source – free, with huge community support.

2.2 Installation & IDE Setup

  • Python – Download from python.org (latest 3.x). Add to PATH during installation.

  • VS Code – Lightweight editor with Python extension; recommended for AEC projects.

    • Install: Python and Pylance extensions.

  • Jupyter Notebook (optional) – Great for exploratory analysis and visualisation.

    • Install via Anaconda or pip install jupyter after Python.

Check installation: Open terminal / command prompt and type python --version.

2.3 Variables & Basic Data Types

Variables are named containers that hold data. In Python you assign them with = and don’t need to declare a type.

Four fundamental types we’ll use today:

TypeExampleAEC use case
intstorey_count = 5Number of floors
floatroom_width = 4.25Room dimensions (m)
strproject_name = "Office Tower A"Project identifier
boolis_sprinklered = TrueCompliance flag

Naming rules:

  • Use only letters, digits, underscores; cannot start with a digit.

  • Case‑sensitive: Area and area are different.

  • Follow PEP 8: lowercase with underscores (slab_thickness).


3. Code Examples

All examples are ready to run in any Python environment.

Example 1: Storing & printing building data

# --- Architectural data ---
project = "Corporate HQ"
num_floors = 12
gross_floor_area = 8500.50   # m²
location = "Manila"

# --- Material cost (simple) ---
concrete_unit_cost = 45.00   # USD per m³
steel_unit_cost = 1200.00    # USD per tonne

print("Project:", project)
print("Floors:", num_floors)
print("Gross Area:", gross_floor_area, "m²")

Output: Project: Corporate HQ Floors: 12 Gross Area: 8500.5 m²

Example 2: Basic arithmetic – room volume and material estimate

# Room dimensions (in metres)
room_length = 8.0
room_width  = 5.0
room_height = 3.0

# Volume
volume = room_length * room_width * room_height
print("Room volume:", volume, "m³")

# Concrete needed for a 0.2 m thick slab on that room
slab_volume = room_length * room_width * 0.2
print("Slab concrete volume:", slab_volume, "m³")

# Cost estimate (rough)
cost_per_m3 = 85.0   # USD
slab_cost = slab_volume * cost_per_m3
print("Estimated slab cost: $", slab_cost)

Example 3: String concatenation for naming

floor_label = "Level " + str(3)   # converts 3 to "3"
print(floor_label)                # "Level 3"

beam_mark = "B" + "1"            # "B1"
print("Beam mark:", beam_mark)

4. Hands‑on Exercises (3–5 Problems)

Try these yourself before peeking at the solutions (solutions are given after each block of problems). You can write a single script or separate files.

Problem 1 – Room area calculator Write code that stores the length and width of a rectangular room (use floats). Calculate and print the floor area. Label the output (e.g., "Floor area = 24.0 m²").

Problem 2 – Compliance check (boolean) Store a variable U_value = 0.35 (W/m²K). Store the maximum allowed max_U = 0.28. Create a boolean variable passes_code that is True if the U‑value is ≤ max. Print "Passes code: True/False".

Problem 3 – Material cost summary You have the following data:

  • concrete_volume = 12.5

  • steel_mass = 2.3 tonnes

  • concrete_rate = 95.0 $/m³

  • steel_rate = 1100.0 $/tonne Calculate:

  • Cost of concrete

  • Cost of steel

  • Total material cost Print each with appropriate text.

Problem 4 – String combining You have these separate pieces: prefix = "WF" size = 600 section = prefix + str(size) Print the section name (should be "WF600"). Then combine with a quantity qty = 4 to produce: "Order: 4 x WF600".

Solution check (only read after trying):

# P1
room_len, room_wid = 6.0, 4.0
area = room_len * room_wid
print("Floor area =", area, "m²")

# P2
U_value = 0.35
max_U = 0.28
passes_code = U_value <= max_U
print("Passes code:", passes_code)

# P3
conc_vol = 12.5; steel_mass = 2.3
conc_rate = 95.0; steel_rate = 1100.0
conc_cost = conc_vol * conc_rate
steel_cost = steel_mass * steel_rate
total = conc_cost + steel_cost
print("Concrete cost: $", conc_cost)
print("Steel cost: $", steel_cost)
print("Total material cost: $", total)

# P4
prefix = "WF"; size = 600
section = prefix + str(size)
qty = 4
order = "Order: " + str(qty) + " x " + section
print(order)

5. Applied Challenge Task (Mini‑Project Starter)

Task: Architect’s Room Data Sheet Write a script that collects (via assignment, not input yet) the following data for two rooms:

  • Room name (string)

  • Length, width, height (floats, in metres)

  • Number of windows (int)

  • Intended use (string: “Office”, “Meeting Room”, etc.)

Then compute:

  • Floor area of each room

  • Volume of each room

  • Total floor area of both rooms combined

Finally, print a formatted summary like:

Room 1: Meeting Room
Dimensions: 8.0 x 5.0 x 3.0 m
Floor area: 40.0 m²   Volume: 120.0 m³

Room 2: Office
Dimensions: 6.0 x 4.0 x 2.8 m
Floor area: 24.0 m²   Volume: 67.2 m³

Combined floor area: 64.0 m²

Try to write it yourself. If you get stuck, a possible skeleton is:

# Data for room 1
room1_name = "Meeting Room"
room1_L = 8.0; room1_W = 5.0; room1_H = 3.0
room1_windows = 2

# Data for room 2
room2_name = "Office"
room2_L = 6.0; room2_W = 4.0; room2_H = 2.8
room2_windows = 1

# Calculations
room1_area = room1_L * room1_W
room1_vol = room1_L * room1_W * room1_H
room2_area = room2_L * room2_W
room2_vol = room2_L * room2_W * room2_H
total_area = room1_area + room2_area

# Output
print("Room 1:", room1_name)
print(" Dimensions:", room1_L, "x", room1_W, "x", room1_H, "m")
print(" Floor area:", room1_area, "m²   Volume:", room1_vol, "m³")
print()
print("Room 2:", room2_name)
print(" Dimensions:", room2_L, "x", room2_W, "x", room2_H, "m")
print(" Floor area:", room2_area, "m²   Volume:", room2_vol, "m³")
print()
print("Combined floor area:", total_area, "m²")

Why this matters: This task mimics how you might later read real project data (from an Excel import or IFC file) and quickly produce summaries for a design review.


6. Brief Review Summary

  • Python is a powerful, beginner‑friendly language widely used in AEC automation.

  • We set up Python and an editor (VS Code / Jupyter).

  • Variables store data without explicit type declaration.

  • Basic types: int, float, str, bool.

  • Arithmetic (+, -, *, /) and string concatenation (+, str()).

  • We practiced storing and manipulating building‑related numbers and text.

Key takeaway: Even with just variables and simple operations, you can already automate many everyday design checks and calculations.


7. Preview of Next Topic (Day 2)

Tomorrow we’ll dive into operators, input/output, and type casting. You’ll learn how to:

  • Use arithmetic, comparison, and assignment operators.

  • Get data from the user (e.g., beam span) using input().

  • Convert strings to numbers (and vice versa) with type casting.

  • Apply these to practical checks – like verifying if a beam length exceeds a standard stock length.

Remember: in AEC, precision matters. Day 2 will also introduce how Python handles floating‑point numbers – an important skill for avoiding geometry errors.


Great work on Day 1! Try the challenge task and exercises; tomorrow we’ll build on this foundation to make your programs interactive.

Comments

EARN AT THE COMFORT OF YOUR HOME

Sponsored content

Popular posts from this blog

Day 5 – Functions, Scope, and Docstrings

Day 10 – Exception Handling and Debugging