Python Fundamentals: Variables and Assignments

Today, I learned some fundamental concepts in Python related to variables and assignments. 🐍 🔹 Multiple Variable Assignment We can assign multiple values to multiple variables in a single line: x, y, z = "John", "Vijay", "Dhoni" print(x, y, z) ✅ Output: John Vijay Dhoni 👉 The number of variables and values must match, otherwise Python will raise an error. ⚠️ 🔹 Assigning the Same Value to Multiple Variables We can assign the same value to multiple variables like this: a = b = c = "Python" print(a, b, c) ✅ Output: Python Python Python 🔹 Checking Data Type We can check the data type of a variable using the type() function: x = 5 print(type(x)) ✅ Output: <class 'int'> 🔹 Unpacking a List We can assign values from a list to variables: subjects = ["HTML", "CSS", "JS"] x, y, z = subjects print(x) ✅ Output: HTML 🚀 Step by step, I’m building my Python fundamentals and improving every day! #Python #Programming #Coding #Beginners 💻🔥

To view or add a comment, sign in

Explore content categories