Skip to content

Instantly share code, notes, and snippets.

@KeitetsuWorks
Created February 18, 2019 13:14
Show Gist options
  • Select an option

  • Save KeitetsuWorks/31fa8ed2a97935219b7024e62eb268d8 to your computer and use it in GitHub Desktop.

Select an option

Save KeitetsuWorks/31fa8ed2a97935219b7024e62eb268d8 to your computer and use it in GitHub Desktop.
Ask user for colour1 and ask user for colour2 (as strings). Then print the result of mixing these two colours.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
## @file colour.py
## @brief Sample Code
## @author Keitetsu
## @date 2019/02/18
## @copyright Copyright (c) 2019 Keitetsu
## @par License
## This software is released under the MIT License.
##
if __name__ == "__main__":
"""
Ask user for colour1 and ask user for colour2 (as strings).
Then print the result of mixing these two colours as follows:
"""
# Python 2で実行する場合は,raw_input()に置き換えてください.
colour1 = input("Colour1: ")
colour2 = input("Colour2: ")
if ((colour1 == "blue") and (colour2 == "yellow")
or (colour1 == "yellow") and (colour2 == "blue")):
print("Result Colour: green")
elif ((colour1 == "blue") and (colour2 == "red")
or (colour1 == "red") and (colour2 == "blue")):
print("Result Colour: purple")
elif ((colour1 == "red") and (colour2 == "yellow")
or (colour1 == "yellow") and (colour2 == "red")):
print("Result Colour: orange")
else:
print("Result Colour: unknown")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment