Let's get started! 🔥🔥🔥 In this video, we will show you how to write a short PYTHON 🐍 program that takes a user input and decides what to do next - printing one of several messages to the user. First, it prompts the user about whether they want to continue or not. There is a total of three scenarios:
• If the user responds with either 'y' or 'yes', then it will print the phrases 'Continuing...' and 'Complete!'.
• If the user responds with either 'n' or 'no', then it will print the phrase 'Exiting'.
• If the user responds with anything else, then it will print the phrase 'Please try again and answer with a yes or no'.
In this lesson, you will learn some basics in less than 10 minutes!
In this video, you will learn how to :
★ 0:08 Create a Python code file and execute that code in the terminal of Visual Studio Code.
★ 0:20 Write code to send a text message to the command line.
★ 0:20 Write code to accept user input from the command line.
★ 0:38 Use the if ... elif ... else statements to add decision logic to your Python code.
Tips and Tricks:
► Hit Ctrl+S to quickly save the changes to your file!
► Single equal is an assignment operator used to assign the values to the variables. But, double equal is relational operator used to compare two variable values whether they are equal are not.
► Python strings are CASE-SENSITIVE, so user inputs such as 'Y', 'YES', or 'yEs' won't take you to the first code branch, for example.
► If you want to do CASE-INSENSITIVE string comparison, remember to convert user input with .lower() to match the string it's compared to. For example, value = input(...).lower()
WANT MORE PYTHON TUTORIALS?
🐍 Python Coding for Beginners:
• 🐍 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 KIDS' 👨🏻💻👩🏻💻 YOUTUBE CHANNEL NOW 👇
/ @codingwithkids
#CodingWithKids #PythonProgramming #PythonForBeginners
Auf dieser Seite können Sie das Online-Video How to Code PYTHON: Branch Code Execution Based on User Input mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Coding With Kids 11 September 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 255 Mal angesehen und es wurde von 9 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!