Course Content
Week 1: Getting Started
In week 1 the basis goal is to get started with the basics.
0/2
Week 2: Variables & Data Types
Variables are containers that computer programs use to store information pertinent to what that computer program will do. Data Types are the different types of Variables and how Python uses these variables when building logic
0/2
Week 3: Making Decisions
In both computer programs and the AI world, computer programs need a way to make decisions. Booleans and Conditionals provide a way to make this happen.
0/2
learning Python Programming and also Intro to Games

Lesson 4: Numbers and Math

Topics Covered:

  • Working with numbers in Python
  • Basic arithmetic operations
  • Converting between strings and numbers

Working with Numbers

You can store numbers in variables and do math with them:

a = 10
b = 3
sum = a + b
print(sum)

Basic Math Operators

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • % Modulus (remainder)
  • ** Exponentiation
print(5 * 4)   # 20
print(8 / 2)   # 4.0
print(7 % 3)   # 1
print(2 ** 3)  # 8

Combining Input with Math

Use int() or float() to convert input to numbers:

num1 = int(input("Enter a number: "))
num2 = int(input("Enter another number: "))
print("The sum is:", num1 + num2)

Challenge Task

  • Ask the user for two numbers.
  • Print the result of adding, subtracting, and multiplying them.
a = float(input("First number: "))
b = float(input("Second number: "))

print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)