+ 1
Help with the Ballpark problem in Python
I'm trying to get Python to index the user input, then to assign a price to each input and create a sum total. Then to finally print the total with an applied tax. Input: Four food items separated by spaces. If an item is not on the menu, order a coke instead. Output: total price with 7% tax input_string = input() userOrders = input_string.split() total = 0 if userOrders.index(Nachos): total += 6 elif userOrders.index(Pizza): total += 6 elif userOrders.index(Cheeseburger): total += 1 elif userOrders.index(Water): total += 4 elif userOrders.index(Coke): total += 5 print(int(total*0.93))
3 odpowiedzi
+ 1
You have to write 'Nachos' etc. instead of Nachos.
You haven't solved the part where people order something that's not on the list.
You are subtracting taxes, but you should be adding them.
Price of Cheeseburger isn't right.
0
Yes, with all of those fixes, I still get a traceback error to the userOrders.index(Nachos): line.
0
Complete the code below by reordering the remaining code to find three subgroups of wines based on measurements on alcohol and total_phenols using k-means.
X = wine[['alcohol', 'total_phenols']]
scale = StandardScaler()
scale.fit(X)
X_scaled = scale.transform(X)
kmeans = KMeans(n_clusters=3)
kmeans.fit(X_scaled)