🔢 Python Numbers - Types of Numbers
Learn about the three types of numbers in Python!
📖 What are Number Types?
In Python, numbers come in three special types! Just like you have whole apples, half apples, or imaginary things, Python has different types for different kinds of numbers.
1. Integer (int) - Whole Numbers 🍎
Integers are whole numbers with no decimals. They can be positive, negative, or zero!
2. Float - Decimal Numbers 🍰
Floats are numbers with decimal points. Perfect for measurements!
3. Complex - Super Special Numbers 🌟
Complex numbers use "j" for imaginary parts. You'll learn more about these in advanced math!
Checking Number Types 🔍
Use type() to see what type a number is:
🎯 Quick Quiz
Question: What type is the number 3.14?
💻 Try It Yourself!
Create three variables: one integer, one float, and use type() to check them!
🔄 Python Casting - Converting Types
Learn how to change one type to another!
📖 What is Casting?
Casting is like a magic spell that changes one type into another! Sometimes you need a number as text, or text as a number.
int() - Make it a Whole Number 🎯
Converts to integer (whole number):
float() - Make it a Decimal 🎈
Converts to float (decimal number):
str() - Make it Text 📝
Converts to string (text):
Why Casting Matters? 🤔
Sometimes you can't mix types. Casting helps you fix that!
🎯 Quick Quiz
Question: What does int(7.8) give you?
💻 Try It Yourself!
Convert 3.99 to an integer and "25" to a number, then add them!
⚙️ Python Operators - Introduction
Learn about operators and what they do!
📖 What are Operators?
Operators are special symbols that tell Python to do something with values. Like + for adding or = for saving!
Types of Operators 🎨
Python has different groups of operators:
- Arithmetic Operators - Math stuff like +, -, *, /
- Assignment Operators - Saving values like =, +=, -=
- Comparison Operators - Comparing things like ==, >, << /li>
- Logical Operators - Logic like and, or, not
Simple Examples 🌟
Why Operators are Important 💡
Operators let you:
- Calculate math problems 🧮
- Store and update values 💾
- Compare numbers and make decisions 🤔
- Build logic in your programs 🧠
🎯 Quick Quiz
Question: Which operator is used for addition?
💻 Try It Yourself!
Use different operators: add two numbers, save a value, and compare two values!
➕ Arithmetic Operators - Math Power!
Master all the math operators in Python!
📖 Arithmetic Operators
These operators let you do math! Python is like a super calculator! 🧮
The Basic Four ➕ ➖ ✖️ ➗
Special Math Operators 🌟
Real Life Examples 🎮
Order Matters! 🎯
Python follows math rules (PEMDAS):
🎯 Quick Quiz
Question: What does 15 % 4 give you?
💻 Try It Yourself!
Calculate: 2 to the power of 5, then divide 20 by 3 using floor division!
📝 Assignment Operators - Smart Shortcuts!
Learn quick ways to update variables!
📖 Assignment Operators
These operators help you update variables faster! They're like shortcuts! ⚡
Regular Assignment =
The = operator saves a value:
Addition Assignment +=
Add to the current value:
All the Shortcuts! ⚡
Real Example: Game Score 🎮
🎯 Quiz
Question: If x = 10, what is x after running x += 5?
💻 Try It Yourself!
Start with points = 100, add 50, then multiply by 2!
⚖️ Comparison Operators - Compare Values!
Learn how to compare numbers and values!
📖 Comparison Operators
These operators compare two values and give you True or False! Like asking questions! 🤔
Equal To ==
Checks if two values are the same:
Not Equal To !=
Checks if two values are different:
Greater and Lesser 🎯
Greater or Equal, Less or Equal ≥ ≤
Real Example: Age Check 🎂
Important! ⚠️
- Use
==to compare (two equals signs!) - Use
=to assign (one equals sign!) - Don't mix them up!
🎯 Quick Quiz
Question: What does 7 < 10 give you?
💻 Try It Yourself!
Compare: Is 15 greater than or equal to 10? Is 8 equal to 9?
🤔 Python Conditions - Make Decisions!
Learn how to make your code smart with if statements!
📖 What are Conditions?
Conditions let your code make decisions! Like "IF it's raining, THEN bring an umbrella!" ☔
The if Statement 🎯
Run code ONLY if something is true:
The else Statement 🔄
Do something ELSE if the condition is false:
The elif Statement 🎨
Check multiple conditions! (elif = else if)
Important: Indentation! ⚠️
Python uses spaces/tabs to know what's inside the if block!
Real Example: Weather Check 🌤️
🎯 Quick Quiz
Question: What keyword do you use for "else if"?
💻 Try It Yourself!
Write a program that checks if a number is positive, negative, or zero!