Modules in Python

Free Video Tutorial and Guide

In this video, we're going to look at how to use Modules in Python

Video Transcription

Python for Data Science Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Hi, my name is Art and I teach Python at Noble Desktop. In this video, I'm going to show you how to use modular to solve a popular problem in Python.

The problem is to ask the user for a number and then print if the number is even or odd. First, let's ask the user for the number. We can use the built-in function "input": "Give me a number".

When the user runs the program, they will be prompted to enter a number, let's say 5. The input is stored with the variable, but it is a string. In order to do math with the number, we need to convert it to a numeric data type. We can use the same variable name and the "int" function to convert it to an integer.

Now we can use an if-else statement to check if the number is even or odd. We can use the modulo operator to check for a remainder. If the number is divisible by two and the remainder is zero, then we can print "even number". Otherwise, the number is odd.

Thank you.

How to Learn Python

Master Python with hands-on training. Python is a popular object-oriented programming language used for data science, machine learning, and web development. 

Yelp Facebook LinkedIn YouTube Twitter Instagram