From the course: Programming Foundations: Application Architecture

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Play the guess the number game

Play the guess the number game

Let's play the guess-the-number game. To run this application, we'll execute the Python script in the terminal. You can find the terminal on a Mac by using Spotlight and searching terminal. On Windows, you can search for the command prompt in the search bar. Before executing the script, we'll navigate to the proper folder using the cd command. In this case, the script is in our desktop, so I'll cd into the desktop. From here, we'll execute the Python script with python3 script. py because that's the name of the script. On Windows, the command would just be Python, and then the name of the Python script file, script.py. If you don't have Python already installed, you can install it from python.org/downloads. Be sure to install a version of Python 3. Now let's play the game. We'll start in the middle with a guess of 50. To submit our input to the program, we'll just press Enter. Looks like we're too high. Let's try 25, too low. 33, looks like it's 26. We've guessed the number. Let's…

Contents