Warmup

print("Hello, my name is NAME!")

Change "NAME" to your actual name and run it

Agenda

  • Complete form and accept invitation to Edube.org class (check your personal email)
  • Complete Assignment 1.3
  • Continue in Python Essentials 1 Module 1 (Quiz due Tuesday, Test due Wednesday)

Email address for Edube.org form

  • I created an assignment in Canvas that has a link to a google form. Please complete the form during class today.

Python as a Calculator

Python can do math instantly. Try these:

5 + 3
10 - 4
6 * 7

More Calculator Fun

20 / 4
2 ** 3
17 % 5

Challenge question: What do you think ** does? What about %?

Test your guess by trying different numbers

Storing Information in Variables

Instead of just calculating, we can save results:

my_age = 16
print(my_age)
favorite_number = 42
print(favorite_number)

Your turn: Create a variable with your actual age and print it

Variables Can Change

score = 10
print(score)
score = 25
print(score)

What happened? The variable score changed from 10 to 25

Try it: Create a variable called points and change it several times

Doing Math with Variables

length = 5
width = 3
area = length * width
print(area)

Code-along: Everyone type this rectangle area calculator

Next challenge: Make variables for your height and a friend's height, then find the difference

Getting Input from Users

name = input("What's your name? ")
print("Nice to meet you,", name)

Interactive time: Everyone run this and type your name when it asks

What's cool: The program waits for YOU to type something!

Input with Numbers

age = input("How old are you? ")
print("Wow, you are", age, "years old!")

Try it now: Run this code and enter your age

Your First Real Program

Let's combine everything into one program:

print("Welcome to my first Python program!")
name = input("What's your name? ")
age = input("How old are you? ")
print("Hello", name, "you are", age, "years old")
print("Thanks for trying Python!")

Make It Your Own

Now modify the program above to:

  • Ask for their favorite color
  • Ask for their favorite food
  • Print a message using all the information

5 minutes: Work on your personalized version

Quick Math Program

num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
result = int(num1) + int(num2)
print("The sum is:", result)

Don't worry about int() yet - we'll learn that soon!

Practice Time

Spend the last few minutes trying to write a program that:

  1. Asks for two of your favorite things
  2. Does a simple math calculation
  3. Prints everything in a nice message