Introduction

introduction

Introduction

Video Transcript

In this section, we're going to start learning about Python. Let's jump right in with some example code to see how Python works:
# Gets the user's name and greets them
my_name = "Jason"
user_name = input("Enter your name: ")
print(f"Hello {user_name}, nice to meet you. I am {my_name}\n")

# Gets the user's age and compares
my_age = 31
user_age = input("Enter your age: ")
difference = my_age - int(user_age)
print(f"I am {difference} years older than you")
If you run this code, the first thing you should see is that Python runs line by line. The computer starts at the first line and executes it, moves on to the second line and executes it, and so on. This is important to remember because we can think like a computer by examining each line one at a time, which can help us catch mistakes if we run into problems.
This program is made of five components: variables (which hold values to be used later in the program), functions (which perfom some action), operators (which assign and modify values), data (which are all the extra information we give the program), and comments (which a person can read but which are invisible to the computer).
In future sections, we'll learn how to put all these pieces together to make our very own Python programs.
Next section