
- Practice writing Python
- Create Logical Statements Yourself
- Create a fun Color Mixing Game
H2
You're already learning a lot about Python, and now let's make a simple exercise. Afterall, Practice is the best way to learn programming!
In this lesson, we'll write a fun script where we provide 2 colors and get the result of mixing them. So if we provide Yellow + Red we should see Orange as a result. I think it's quite fn and you get to practice Python.
Before we begin, make sure you try to do it on your own. And don't worry if you see errors or get stuck. That's part of the learning process.
Ready? Set. Code!
Pseudo-Code
Before starting to code, it's best to brainstorm and layout all the steps. You can write it on the paper, or use comments inside your script. It's often called 'Pseudo-Code' or 'Skeleton Code'.
So for this script:
In this case it's very simple, but you're building a habit so you can do the same with 10-20 steps too.
Get User Input
Let's begin with getting user input():
💡Don't forget to apply .lower() to avoid issues with lower and upper case comparisons.
Logic - Calculate New Color
The logic is very simple. We are going to check color_1 and color_2 and then print the resulting color. But keep in mind that your combination can be reversed, so you'll need multiple if statements to do it right.

This starts to work, but code looks really ugly🤮. But we can fix it.
To simplify the if-statement we need to combine colors in a list, then we can check if colors are inside with membership-operators. This will make it look much nicer:
This way you don't care the order of colors that user provides. It will work both ways.
Improve Print Statements
Now, let's add more color combinations and make our print statements spicer 🧂.
Now we're getting somewhere!
Combine User Inputs
Check Same Colors
Check Different Colors
Ensure only allowed colors used
Here's how it looks in the console:

Improve Same Color Combination
Since we're practicing logic, let's add another statement to get the right emoji for the same colors. For that we just need to check what is the color1 and return the right emoji.
Great, now we can display the right color emoji in the console if color1 == color2:
Final Code:
Let's bring it all together:
Happy Coding!
🙋♂️ See you in the next lesson.
- EF
Now it's your turn.
I hope that you've already tried to make this script on your own without looking at my code or full tutorial. But either way, make sure to try this code in your own script.
You won't become python expert by watching me code. You need to write code yourself too. And it's also best if you're going to experiment, make changes and learn something new along the way.
⌨️ Happy Coding!
