提示:中混合顏色編程
的顏色紅,藍和黃的被稱爲原色,因爲它們 不能通過混合其他顏色製成。當您混合兩種原色時,您獲得 次要色彩: 當您混合紅色和藍色時,您會變成紫色。 當你混合紅色和黃色時,你會變得橙色。 當你混合藍色和黃色時,你會變綠。
設計一個程序,提示用戶輸入兩個原色 一次一個的名稱。如果用戶輸入「紅色」,「藍色」或 「黃色」以外的任何內容,則程序應打印「您沒有輸入兩個原色。」 否則,它應該打印格式如下的東西:
「當你混合紅色和藍色時,你會變成紫色。」 (假設用戶輸入「紅」「藍」。)
我的計劃一直得到錯誤的標準輸出
這是我寫的:
primary_colora = input("Enter primary color:")
primary_colorb = input("Enter primary color:")
primary_colors = primary_colora or primary_colorb
if primary_colora == (red, blue, yellow):
primary_colora = True
elif primary_colorb == (red, blue, yellow):
primary_colorb = True
elif primary_colors == red or blue:
print("When you mix red and blue, you get purple")
elif primary_colors == yellow or blue:
print("When you mix yellow and blue, you get green")
elif primary_colors == yellow or red:
print("When you mix yellow and red, you get orange")
else: print("You didn't input two primary colors.")
這就是衆多問題之一... Im相當肯定'primary_colors = primary_colora或primary_colorb'做不要做他認爲的事...... –