Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How would I code this in pythone without using if statements? You are playing th

ID: 3885704 • Letter: H

Question

How would I code this in pythone without using if statements?

You are playing the game of Monopoly and you decide you wish to construct houses on one of your property groups. The rules of the game require that the number of houses on the properties within each group may not differ by more than one. You will be given an amount of money to spend, the cost per house, and the number of properties in the group The goal is to determine how many houses will go on each. To make the program simple, you may assume that you will not have enough money to build past four houses, so there needs to be no special cases for hotels. Monopoly Property Groups Here is a small table relating the colors of the monopoly property groups, the number of properties within the group, and the cost of the houses color size cost purple 2 50 light blue 3 50 maroon 3 100 orange red yellow 3 150 green dark blue 2 200 3 100 3 150 3 200

Explanation / Answer

propertygroups = {
   'purple':[2, 50],
   'light blue':[3, 50],
   'maroon':[3, 100],
   'orange':[3, 100],
   'red':[3, 150],
   'yellow':[3, 150],
   'green':[3, 200],
   'dark blue':[2, 200],
}

color = input ('Which color block will you be building on? ')
money = float(input('How much money do you have to spend? '))

numberofproperties = propertygroups[color][0]
costofhouse = propertygroups[color][1]

print ('There are {0} properties and each house costs {1}'.format(numberofproperties, costofhouse))

canbuild = int(money/costofhouse)

print ('You can build {0} house(s)'.format(canbuild))

OUTPUT:

D:Code>python houses.py
Which color block will you be building on? orange
How much money do you have to spend? 220
There are 3 properties and each house costs 100
You can build 2 house(s)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote