Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Room Summary Reporter | Visualization and Automation in Architectural Workflows
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Architects

bookChallenge: Room Summary Reporter

In many architectural projects, you often need to generate quick reports summarizing the characteristics of rooms, such as their names and areas. Automating this process helps you avoid manual errors and saves valuable time. You will use a hardcoded pandas DataFrame containing room information, and your task is to create a function that generates a formatted string report. This report should list each room and its area, calculate the total area, and clearly highlight any room that is larger than 30 square meters.

To begin, you will work with a DataFrame structured with two columns: "Room" and "Area". Each row in this DataFrame represents a different room in the building and its corresponding area in square meters. The function you write should iterate over these rows, construct a readable report string, and apply a highlight to rooms exceeding 30 sqm—making these stand out in your summary. At the end of the report, you should also include the total area of all rooms combined.

Here is a sample DataFrame to illustrate the data you will be working with:

import pandas as pd

rooms = pd.DataFrame({
    "Room": ["Living Room", "Kitchen", "Bedroom", "Bathroom", "Study"],
    "Area": [35, 18, 28, 8, 32]
})

You can see that some rooms, like the Living Room and Study, have areas greater than 30 sqm. Your function should highlight these in the report, for example by adding a marker such as **(LARGE)** after their names.

Your formatted report should look something like this:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

This format makes it easy to see which rooms are particularly large and provides a clear summary for further decision-making or documentation.

Now, it's your turn to implement this functionality.

123456
import pandas as pd rooms = pd.DataFrame({ "Room": ["Living Room", "Kitchen", "Bedroom", "Bathroom", "Study"], "Area": [35, 18, 28, 8, 32] })
copy

You can see that some rooms, like the Living Room and Study, have areas greater than 30 sqm. Your function should highlight these in the report, for example by adding a marker such as **(LARGE)** after their names.

Your formatted report should look something like this:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

This format makes it easy to see which rooms are particularly large and provides a clear summary for further decision-making or documentation.

Your formatted report should look something like this:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

This format makes it easy to see which rooms are particularly large and provides a clear summary for further decision-making or documentation.

Compito

Swipe to start coding

Write a function generate_room_report(df) that takes a pandas DataFrame with columns "Room" and "Area". The function should:

  • Return a formatted string report listing each room and its area.
  • Highlight rooms with area greater than 30 by appending " (LARGE)" to the line.
  • At the end, include the total area in the format: "Total area: X sqm".

Example output:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 7
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

bookChallenge: Room Summary Reporter

Scorri per mostrare il menu

In many architectural projects, you often need to generate quick reports summarizing the characteristics of rooms, such as their names and areas. Automating this process helps you avoid manual errors and saves valuable time. You will use a hardcoded pandas DataFrame containing room information, and your task is to create a function that generates a formatted string report. This report should list each room and its area, calculate the total area, and clearly highlight any room that is larger than 30 square meters.

To begin, you will work with a DataFrame structured with two columns: "Room" and "Area". Each row in this DataFrame represents a different room in the building and its corresponding area in square meters. The function you write should iterate over these rows, construct a readable report string, and apply a highlight to rooms exceeding 30 sqm—making these stand out in your summary. At the end of the report, you should also include the total area of all rooms combined.

Here is a sample DataFrame to illustrate the data you will be working with:

import pandas as pd

rooms = pd.DataFrame({
    "Room": ["Living Room", "Kitchen", "Bedroom", "Bathroom", "Study"],
    "Area": [35, 18, 28, 8, 32]
})

You can see that some rooms, like the Living Room and Study, have areas greater than 30 sqm. Your function should highlight these in the report, for example by adding a marker such as **(LARGE)** after their names.

Your formatted report should look something like this:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

This format makes it easy to see which rooms are particularly large and provides a clear summary for further decision-making or documentation.

Now, it's your turn to implement this functionality.

123456
import pandas as pd rooms = pd.DataFrame({ "Room": ["Living Room", "Kitchen", "Bedroom", "Bathroom", "Study"], "Area": [35, 18, 28, 8, 32] })
copy

You can see that some rooms, like the Living Room and Study, have areas greater than 30 sqm. Your function should highlight these in the report, for example by adding a marker such as **(LARGE)** after their names.

Your formatted report should look something like this:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

This format makes it easy to see which rooms are particularly large and provides a clear summary for further decision-making or documentation.

Your formatted report should look something like this:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

This format makes it easy to see which rooms are particularly large and provides a clear summary for further decision-making or documentation.

Compito

Swipe to start coding

Write a function generate_room_report(df) that takes a pandas DataFrame with columns "Room" and "Area". The function should:

  • Return a formatted string report listing each room and its area.
  • Highlight rooms with area greater than 30 by appending " (LARGE)" to the line.
  • At the end, include the total area in the format: "Total area: X sqm".

Example output:

Living Room: 35 sqm **(LARGE)**
Kitchen: 18 sqm
Bedroom: 28 sqm
Bathroom: 8 sqm
Study: 32 sqm **(LARGE)**

Total area: 121 sqm

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 3. Capitolo 7
single

single

some-alt