From the course: Python Quick Start

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Storing data using variables

Storing data using variables - Python Tutorial

From the course: Python Quick Start

Storing data using variables

Did you ever play guessing games as a kid? If so, you may remember playing a game where one player, also known as Player 1, comes up with a word or a phrase, and the other player, also known as Player 2, has to guess it. So when is the game over? Well, the game is over when Player 2 either uses up all of their guesses without correctly guessing the word or they guessed the word correctly using the guesses they have. Either way, the players need to keep track of how many guesses are left throughout the game. So as a fun exercise, let's say you were tasked with coding to guessed the word game, meaning you're building the game so it can be played online. How exactly would you keep track of how many guesses are remaining? You do this by using a variable. A variable in programming is like a storage box. You can use a variable to store any kind of information or data. When programming, you will often encounter information that you will need to keep track of or reuse throughout your code…

Contents