Python Learning Series · @onlysamarrr · Day 2 / 30

Day 2: Data Types

Day 2 covers the four basic data types: int for whole numbers, float for decimals, str for text, and bool for True or False. The type() function tells you which type a value has.

Phase: Beginner · Reels: 6/450 – 10/450

Quick Answer

Day 2 covers the four basic data types: int for whole numbers, float for decimals, str for text, and bool for True or False. The type() function tells you which type a value has.

What You Will Learn

Code

age = 21
price = 99.5
name = "Arhan"
is_pro = False
print(age, type(age))
print(price, type(price))
print(name, type(name))
print(is_pro, type(is_pro))
print("5" + "5")
print(5 + 5)

Output

21 <class 'int'>
99.5 <class 'float'>
Arhan <class 'str'>
False <class 'bool'>
55
10

Code Explained, Line by Line

  1. int is a whole number, like 21. float has a decimal point, like 99.5.
  2. str is text inside quotes, like "Arhan". bool is only True or False.
  3. type(value) returns the type of a value, for example type(21) is int.
  4. "5" is text and 5 is a number. They look alike but behave differently.
  5. "5" + "5" gives "55" (text joins), while 5 + 5 gives 10 (numbers add).
Common Mistake: Adding text and a number, like "5" + 5, raises a TypeError. Convert first with int("5") or str(5) so both sides match.

Real-Life Use

Data types are everywhere: prices are floats, ages are ints, names are strings, and login status is a bool.

Practice Task: Guess the type of 3.0, "3" and True, then run type() on each to check your guesses.

Test Yourself — MCQs

Select (tick) an option, then tap Check answer to see instantly whether your answer is right or wrong, with an explanation. You can change your answer and check again.

Q1. What is the type of 3.5?

Q2. What happens with "5" + 5 in Python?

Q3. Which value is a bool?

Today's 5 Reels (from the 90-Day Plan Excel)

6/450Conceptint, float, str, bool kya hain
7/450Live demotype() se data type check
8/450Common mistake"5" aur 5 mein farak
9/450QuizQuiz: guess the type
10/450Interview / real lifeReal life: data types kahan use hote
← Day 1Day 3 →