Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Room Proportion Analyzer | Geometric Computation and Spatial Analysis
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Architects

bookChallenge: Room Proportion Analyzer

Architects often need to quickly assess the proportions of different rooms to ensure they meet design standards and functional requirements. One way to do this is by classifying rooms based on their aspect ratios, which compare the width and length of a room. An aspect ratio close to 1:1 usually indicates a square room, while larger or smaller ratios suggest the room is either wide or narrow. In this challenge, you will write a function that analyzes a list of rooms, each with a specified width and length, and classifies their proportions as either 'Square', 'Wide', or 'Narrow'.

Tâche

Swipe to start coding

Write a function called classify_room_proportions that takes a list of dictionaries, where each dictionary has keys "name", "width", and "length". The function should return a dictionary mapping each room name to its aspect ratio classification:

  • 'Square' if width and length differ by less than 10%.
  • 'Wide' if width is greater than length by 10% or more.
  • 'Narrow' if length is greater than width by 10% or more.

Use the following sample data for testing:

rooms = [
    {"name": "Gallery", "width": 6.0, "length": 6.5},
    {"name": "Studio", "width": 3.5, "length": 3.4},
    {"name": "Library", "width": 4.0, "length": 5.0},
    {"name": "Lounge", "width": 5.5, "length": 4.5},
    {"name": "Hall", "width": 7.0, "length": 7.0}
]

Your function should return:

{
    'Gallery': 'Narrow',
    'Studio': 'Square',
    'Library': 'Narrow',
    'Lounge': 'Wide',
    'Hall': 'Square'
}

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 7
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Can you provide an example list of rooms to analyze?

What are the exact criteria for classifying a room as 'Square', 'Wide', or 'Narrow'?

Do you want the function to return the classifications as a list or print them directly?

close

bookChallenge: Room Proportion Analyzer

Glissez pour afficher le menu

Architects often need to quickly assess the proportions of different rooms to ensure they meet design standards and functional requirements. One way to do this is by classifying rooms based on their aspect ratios, which compare the width and length of a room. An aspect ratio close to 1:1 usually indicates a square room, while larger or smaller ratios suggest the room is either wide or narrow. In this challenge, you will write a function that analyzes a list of rooms, each with a specified width and length, and classifies their proportions as either 'Square', 'Wide', or 'Narrow'.

Tâche

Swipe to start coding

Write a function called classify_room_proportions that takes a list of dictionaries, where each dictionary has keys "name", "width", and "length". The function should return a dictionary mapping each room name to its aspect ratio classification:

  • 'Square' if width and length differ by less than 10%.
  • 'Wide' if width is greater than length by 10% or more.
  • 'Narrow' if length is greater than width by 10% or more.

Use the following sample data for testing:

rooms = [
    {"name": "Gallery", "width": 6.0, "length": 6.5},
    {"name": "Studio", "width": 3.5, "length": 3.4},
    {"name": "Library", "width": 4.0, "length": 5.0},
    {"name": "Lounge", "width": 5.5, "length": 4.5},
    {"name": "Hall", "width": 7.0, "length": 7.0}
]

Your function should return:

{
    'Gallery': 'Narrow',
    'Studio': 'Square',
    'Library': 'Narrow',
    'Lounge': 'Wide',
    'Hall': 'Square'
}

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 7
single

single

some-alt