fork download
  1. # Design a program that prompts the user to enter the names of two primary colors to mix. If
  2. # the user enters anything other than red, blue or yellow, the program should display an error
  3. # message. Otherwise the program should display the name of the secondary color that results.
  4.  
  5. print('You will be mixing two primary colors to get a resulting color.')
  6. print('Primary colors are blue, red and yellow \n')
  7.  
  8. red = 1
  9. blue = 2
  10. yellow = 3
  11.  
  12. color1 = input('Enter your first primary color: \n')
  13. color2 = input('Enter your second primary color: \n')
  14.  
  15. if color1 == 1 and color2 == 2:
  16. print('That makes purple!')
  17.  
  18. elif color1 == 2 and color2 == 1:
  19. print('That makes purple!')
  20.  
  21. elif color1 == 3 and color2 == 1:
  22. print('That makes orange!')
  23.  
  24. elif color1 == 1 and color2 == 3:
  25. print('That makes orange!')
  26.  
  27. elif color1 == 2 and color2 == 3:
  28. print('That makes green!')
  29.  
  30. elif color1 == 3 and color2 == 2:
  31. print('That makes green!')
  32.  
  33. else:
  34. print('You did not enter a primary color!')
  35.  
  36.  
  37.  
Success #stdin #stdout 0.03s 9628KB
stdin
def power_menu():
    print("Power Menu:")
    print("1. Power on")
    print("2. Power off")
    print("3. Restart")
    print("4. Hibernate")
    print("5. Exit")

    choice = int(input("Enter your choice: "))
    
    if choice == 1:
        print("Powering on...")
    elif choice == 2:
        print("Powering off...")
    elif choice == 3:
        print("Restarting...")
    elif choice == 4:
        print("Hibernating...")
    elif choice == 5:
        print("Exiting...")
    else:
        print("Invalid choice! Please enter a number between 1 and 5.")

power_menu()
stdout
You will be mixing two primary colors to get a resulting color.
Primary colors are blue, red and yellow 

Enter your first primary color: 
Enter your second primary color: 
You did not enter a primary color!