Created
February 18, 2019 13:14
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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