How to Code PYTHON: Perform Data-Type and Value Checks on Numeric Data – Mathematical Operations

How to Code PYTHON: Perform Data-Type and Value Checks on Numeric Data - Mathematical Operations

Let's get started! 🔥🔥🔥 In this video, we will show you how to write a few PYTHON 🐍 scripts to perform data-type and value checks on input data from users or other systems before you perform actual operations on or with the data when building real-world Python programs. There are several built-in and string helper functions you can use. In this lesson, you will learn some basics in about 10 minutes!

In this video, you will learn how to:
★ 0:07 Show how it's possible for users to enter a value that can't be converted to a numeric data type.
★ 3:28 Use the isnumeric() function to determine whether a string can be converted into a number.
★ 5:45 Demonstrate a list of is__() helper functions in the str data type.
★ 11:53 Use an if statement and the isnumeric() function to validate an input.
★ 17:06 Use logical or operator to validate multiple inputs.

Tips and Tricks:
► Practice "Treating input as evil" approach - Developers should always anticipate that input from users or other systems could be out of the acceptable range of values.
► isnumeric() function tells you if a value could be converted and used as an int or float data type.
► Use the exit() function to end the execution of your program immediately.
► Consider using a while loop when validating an input, it could provide a better user experience than ending the entire execution.

Some is__() helper functions mentioned in the video:
⦿ isalnum() ensures that the string has no special characters, such as %, $, #, @, or !.
⦿ isalpha() ensures that the string contains only letters of the alphabet.
⦿ isdecimal() ensures that the string contains only decimal values (numbers). Unlike isnumeric(), it only returns true if all characters in the string are decimal characters. For example, it returns false for ⅛.
⦿ istitle() ensures that the string follows the rules of capitalization, like "Hello, Welcome To My World!".
⦿ isupper() ensures that the string contains only uppercase letters.
⦿ islower() ensures that the string contains only lowercase letters.

WANT MORE PYTHON TUTORIALS?
🐍 Python Coding for Beginners:
https://www.youtube.com/playlist?list=PLYnuuwG097TxI0viOUfWD7sx_D_wRsGbo

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 👇
https://www.youtube.com/channel/UCsPTo-vWxs0uBa2ZdPd9Y_Q?sub_confirmation=1

#CodingWithKids #PythonProgramming #PythonForBeginners

Reply