Challenge: 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.
123456import 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.
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.
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
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Can you show me how to write the function that generates this report?
What is the best way to highlight rooms larger than 30 sqm in the report?
How do I calculate and display the total area at the end of the report?
Großartig!
Completion Rate verbessert auf 4.76
Challenge: Room Summary Reporter
Swipe um das Menü anzuzeigen
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.
123456import 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.
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.
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
Lösung
Danke für Ihr Feedback!
single