Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python, the first and second picture are a precondition for the task and the code has been written. In python, the first and second

In python, the first and second picture are a precondition for the task and the code has been written.

In python, the first and second picture are a precondition for the task and the code has been written.

image text in transcribedimage text in transcribedimage text in transcribed
#dictionary with colors, sizes, and costs properties = { 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] # list to convert integers into words numbers = [ none , "one , "two , three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"] def main () : color = input ( Which color block will you be building on? ") money = int (input ("how much money do you have to spend? ") ) # finding number of properties of input color and cost of single house numberOfProperties = properties[color] [0] costOfHouse = properties[color] [1] totalHouses = money // costOfHouse # total number of houses can be builr minimumHouses = totalHouses // numberOfProperties # each properties can have this minimum number of houses # how many properties will have minimum number of houses numberOfPropertiesWithMinHouses = numberOfProperties - (totalHouses * numberOfProperties) numberOfPropertiesWithMaxHouses = numberOfProperties - numberOfPropertiesWithMinHouses # how many properties will have one more house # printing answers using numbers list to convert numbers to words print ( There are "+ numbers [numberOfProperties] + " properties and each house costs " + str (costOfHouse)) print ( You can build " + numbers [totalHouses] + "house (s) -- + numbers [numberOfPropertiesWithMinHouses] + " will have " + numbers[minimumHouses] + "and " + numbers [numberOfPropertiesWithMaxHouses] + main ( input ( Press ")This assignment provides more practice in basic calculations, and also introduces the use of data structures to hold information used in solving the problem. These data structures will be initialized within the program source code, and consulted after the input arrives. Since the problem is a little more complicated than the previous homework, every student should still follow the recommended schedule described in the previous assignment for getting particular phases accomplished ahead of time. Overall Problem 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, and the color Monopoly uses on the game board for a group of properties (see chart below). The goal is to determine how many houses will go on each. And to appear more conversational, the last line of output will use words to represent numbers instead of digits. To make the program simple, you may assume that you will not have enough money to build past four houses per property [twelve total). You do not need to convert the price of a house to a word {although that can be done rather simply). 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 3 100 red 3 150 yellow 3 150 green 3 200 dark blue 2 200 Problem Description The previous assignment had a simplifying assumption that the amount of money would be limited, such that the builder could not afford more than four houses on any property. This assignment will lift that restriction. There is nothing really special about building hotels in Monopoly. That purchase is simply equal to the price of ve houses, and is built ONLY in the same circumstances that would permit ve houses [no other property may have fewer than four). The inputs to the program will be essentially the same -- the color of a property group and the amount of money to be spent. But the following cases should be addressed: - if no building is affordable. display "You cannot afford even one house." instead of buildingO houses everywhere - If any property could have 5 houses, announce that such properties would have a hotel instead. - if any property could have more than 5 houses, still only build one hotel there, and nothing more - omit the word 'none' in the output (i..e don't say 'one property has none' or 'none have two') Comparing Homework 2 to Homework 3 The difference in these programs primarily appears in the nal output statement: Hypothetical Homework 2 Output Corresponding Homework 3 Output three will have none and none will have one You cannot afford even one house. one will have one and two will have two one will have one and two will have two one will have none and two will have one two will have one three will have one and none will have two three will have one three will have three and none will have four three will have three two will have four and one will have ve two will have four and one will have a hotel two will have ve and none will have six two will have a hotel one will have seven and two will have eight three will have a hotel Hint: The simplest and clearest solutions will use 'else' and 'elif' and will not need 'and' or 'or'. A portion of your grade is based on how clear your code is. and how well it avoids producing contradictory output. Note: All of these decisions in this chart are entirely based on the results of the previous program, so your code should do the same .. wait until the calculations are complete before deciding how to display the results. Do not make your program unnecessarily complicated by trying to identify the different cases before doing any math. Also Note: three hotels have the cost of 15 houses, which will require a slight modication to the collection of words used to display numbers in the previous assignment. If the number of houses one (an afford exceeds 15 (that last row above could have afforded 23). just display the numeric value itself, without converting to a word

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

What factors are commonly used to evaluate suppliers?

Answered: 1 week ago