✅ Python Data Types! 🐍✨ Data types define what kind of value a variable stores in Python. name = "Python" age = 25 price = 99.99 is_easy = True 1. String (str): Used to store text values. language = "Python" city = 'Delhi' ✔ Written inside quotes "" or '' ✔ Used for names, messages, text data 2. Integer (int): Used to store whole numbers. age = 25 marks = 95 ✔ No decimal point ✔ Positive or negative numbers allowed 3. Float (float): Used to store decimal numbers. price = 99.99 temperature = 36.6 ✔ Numbers with decimal values 4. Boolean (bool): Used for True or False values. is_logged_in = True is_admin = False ✔ Mostly used in conditions and comparisons 5. List (list): Stores multiple values in one variable. fruits = ["apple", "banana", "mango"] ✔ Ordered collection ✔ Can store duplicate values ✔ Uses square brackets [] 6. Tuple (tuple): Similar to list but cannot be changed. colors = ("red", "blue", "green") ✔ Immutable unchangeable ✔ Uses parentheses () 7. Set (set): Stores unique values only. nums = {1, 2, 3, 3, 4} print(nums) ✔ Output → {1, 2, 3, 4} ✔ Removes duplicates automatically 8. Dictionary (dict): Stores data in key-value pairs. student = { "name": "Alex", "age": 22 } ✔ Uses curly braces {} ✔ Access values using keys 9. Check Data Type: Use type() to check variable type. name = "Python" print(type(name)) ✔ Output → 10. Type Conversion: Convert one data type into another. age = int("25") price = float("99.5") ✔ int() → Integer ✔ float() → Decimal ✔ str() → String 11. Practice Examples: ✔ Add integers a = 10 b = 20 print(a + b) ✔ Print list items fruits = ["apple", "banana"] print(fruits) ✔ Access dictionary value student = {"name": "Alex"} print(student["name"]) 💡 Understanding data types is important because every Python program uses them. 💬 Tap ❤️ if this helped you!
23