Let's get started! 🔥🔥🔥 In this video, we will show you how to write a small PYTHON 🐍 game that uses the while loop 🔁 statement and will keep looping over a code block with the dice 🎲 game logic required to generate and evaluate a random value. In this lesson, you will learn some basics in just 10 minutes!
In this video, you will learn how to:
★ 0:09 Add code to loop through a code block by using the while statement.
★ 2:58 Use the optional statements break and else.
★ 6:44 Handle the case where the user enters nothing by using the continue statement.
Tips and Tricks:
► The while statement allows you to create a looping structure that continues to loop through a code block until a Boolean expression evaluates to False.
► Add the *break* statement to exit out of a code block prematurely before the Boolean expression evaluates to False.
► Add the *else* statement to provide a second code block that runs after the while statement's Boolean expression evaluates to False.
► Add the *continue* statement to skip over the remainder of the code block and set the execution path back to the Boolean expression.
► The string helper function *strip()* removes any leading (spaces at the beginning) and trailing (spaces at the end) characters (space is the default leading character to remove).
WANT MORE PYTHON TUTORIALS?
🐍 Python Coding for Beginners:
For the setup, please read the followings before you begin:
1. Download latest Python: https://www.python.org/downloads/
2. Install Python and remember to select "Add Python... to PATH" when asked.
3. Download and install latest Visual Studio Code: https://code.visualstudio.com/Download
4. Install the Python extension for Visual Studio Code: Go to View and select Extensions, or select the Extensions icon, then search for python.
Python - a programming language used by world-class companies such as Amazon.com, Alphabet (Google), Facebook, Twitter, and NASA.
👇 SUBSCRIBE TO CODING WITH KIDS 👨🏻💻👩🏻💻 YOUTUBE CHANNEL NOW 👇