THE CHOICES
Every day we are challenged with making choices. The Python game below prods the user to make choices, and those choices determine what happens next.
For me, I am choosing to expand my coding knowledge and make myself a better computer programmer. How about you? Are you choosing to make great choices today?
As for today’s project, I programmed a short interactive game where the user is on a hunt to find a treasure chest. This is Day 3 of the #100 Days of Coding Challenge. If you missed Day 2, click HERE.
Life is a matter of choices, and every choice you make makes you. John C. Maxwell
THE WHAT IFs ?
Python coding, like many other coding languages, involves using the “if” statements. Python makes use of not only the “if” statement with a condition, but also the “elif” and “else” statements.
The “else” gives ways to a catch-all – where if the “if” statement condition is not met, then the code executes the “else” statement. While the “elif” statement allows for optional conditions to be considered.
For example in this coding challenge, at one point in the game, you can choose between the three different colored doors. This is coded with an “elif” statement.
Now that was a mouthful of jargon! But if you digest it again, I am confident you will get it!
THE FLOWING CHARTS
To create a good program it needs to follow a logical thought process. This process can be better visualized using a flowchart. Flowcharts are a graphical way to diagram the flow of a program. It uses standardized shapes to represent the start, stops, input/output, processing (calculations), decisions, and connectors linked by flow lines.
Drawing out the logic of what you want your program to accomplish remains an excellent practice. Flowcharts provide great communication, act as a blueprint or guide, assist with debugging, help with analysis, and serve as good documentation.
To create your own free flowchart, visit draw.io
THE INPUT
Specifically, in addition to reinforcing “if” statements, this project also demonstrates gaining the user’s input regardless if they use lowercase, uppercase, or a combination of both with the lower() method.
The string lower() method converts all uppercase characters in a string into lowercase characters and returns it. The parathesis () does not have any parameters, and they are left empty. Similarly, the upper() method can be utilized one wishes to convert the input answers to uppercase.
However, this does not correct any misspellings, which is usually my downfall!
THE ASCII ART
Ever wonder how art can be created only using the keys from your keyboard? Ever wondered who would take the time to type such an intensive graphic?
It has been stated this practice has been around since 1867. Old newspapers show advertisements with visual art created from typewriters.
Today, ASCII art used. It is a graphic design technique that uses computers for presentation and consists of pictures pieced together from the 95 printable (from a total of 128) characters defined by the ASCII Standard from 1963 and ASCII compliant character sets with proprietary extended characters (beyond the 128 characters of standard 7-bit ASCII)- Wikipedia. And as the art form has progressed, you can find some quite intricate animated ASCII art often created from GIF files.
This coding project has a treasure chest that appears when you run the code.
Check out more ASCII art at https://ascii.co.uk/art.
THE GAME – DAY 3
Welcome to Hidden Treasure. I had fun with this challenge, although I have to admit, it was not that difficult.
Follow along by answering the questions to see if your choices allow you to find the Hidden Treasure.
Start click the green button below. To restart the game click the “x” in the tab arrow at the top “right” of the python screen. Enjoy!