Name: GTID (903XXXXXX, etc.) Problem 2. Write 1-15 lines of code to answer the f
ID: 3718373 • Letter: N
Question
Name: GTID (903XXXXXX, etc.) Problem 2. Write 1-15 lines of code to answer the following questions. DO NOT write functions. Pay attention to the names of variables. (20 points) You are deciding whether or not to buy an item. The name of the item is stored in item. The price of the item is stored in price. Your maximum budget is stored in budget. Set the variable decision based on the following conditions: a. . If the first four letters of item are 'SALE (case sensitive) then reduce the price by 10% .If you buy the item and it was on sale then decision is 'Great Price' . If you buy the item and it was not on sale then deciaion is 'Not bought on sale If you do not buy the item then decision is 'Too expensive' e You buy the item if your budget is greater than or equal to the price. item will always be greater than 4 in length. (10 points) Examples item ?SALEtshirt, price 10 budget 8 decisionGreat price! item.. ?eggs price5 budget 3 decision-> ?Too expensive Name: GTID (903Xxxxxxx, ete.):_ b. You are given a 4xN array of doubles, temps, where each row has temperature samples from one of the seasons (Spring, Summer, Fall, and Winter, respectively). You are given a string season, that is one of the seasons listed above (case sensitive). Based on the season given, find the average temperature for that season and make a sentence of the format This , it was about . '.Store this sentence in weather. It is guaranteed that the average temperature will be an integer. (10 points) Example season # 'Sutter, temps 50, 60, 70; e spring 80, 90, 100 Summer 50, 40, 50: Fall (-Winter 30, 20, 401 weatherThis Summer, it was about 90.' Note: Spring will always be row 1, Summer row 2, Fall row 3, and Winter row 4Explanation / Answer
Since you have not stated any specific programming language to use the answer will be in python
PART a:
sale = 0
decision = NULL
if item[:5] == "SALE":
sale = 1
price = price - price*0.1
if price < budget and sale == 1:
decision = "Great Price"
elif price < buddget and sale == 0:
decision = "Not Bought on Sale"
elif pice > budget:
decision = "Too expensive"
PART b:
avgtemp = 0
if season == "Spring":
avgtemp = (temps[0][0]+temps[0][1]+temps[0][2])/3
elif seaseon = "Summer":
avgtemp = (temps[1][0]+temps[1][1]+temps[1][2])/3
elif seaseon = "Fall":
avgtemp = (temps[2][0]+temps[2][1]+temps[2][2])/3
elif seaseon = "Winter":
avgtemp = (temps[3][0]+temps[3][1]+temps[3][2])/3
weather = "This "+season+", it was about"+avgtemp
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.