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 💻🔥
Python Fundamentals: Variables and Assignments
More Relevant Posts
-
🚀 Mastering Loops in Python 🐍 Loops in Python are essential for repeating tasks efficiently. They allow you to iterate over a sequence of elements such as lists or strings, executing the same block of code multiple times. This is incredibly useful for automating repetitive operations and processing large amounts of data in your programs. For developers, understanding loops is crucial as they form the backbone of many algorithms and data processing tasks. By mastering loops, you can write more concise and elegant code, improving the efficiency and readability of your applications. 🔎 Let's break it down step by step: 1️⃣ Initialize a counter variable 2️⃣ Set the condition for the loop to continue 3️⃣ Execute the code block inside the loop 4️⃣ Update the counter to progress through the sequence ```python # Example of a for loop in Python for i in range(5): print("Iteration", i) ``` 🚩 Pro Tip: Use `enumerate()` to access both the index and value of an item in a loop effortlessly. ❌ Common Mistake: Forgetting to update the counter variable in a loop, leading to an infinite loop and crashing your program. 🤔 What's your favorite use case for loops in Python? 🌐 View my full portfolio and more dev resources at tharindunipun.lk #PythonProgramming #DeveloperTips #CodingCommunity #LearnToCode #LoopInPython #CodeNewbie #TechTalks #ProgrammingLife
To view or add a comment, sign in
-
-
🚀 Python Basics Every Beginner Should Know Starting your journey in Python? 🐍 Here are some must-know basic commands that every beginner should master 👇 🔹 1. Print Output print("Hello World") 🔹 2. Take Input name = input("Enter your name: ") 🔹 3. Variables x = 10 name = "Python" 🔹 4. Data Types int, float, str, bool, list, tuple, dict 🔹 5. Conditional Statements if x > 5: print("Greater") else: print("Smaller") 🔹 6. Loops for i in range(5): print(i) 🔹 7. Functions def greet(): print("Hello!") 🔹 8. Lists fruits = ["apple", "banana", "mango"] 🔹 9. Dictionaries data = {"name": "John", "age": 25} 🔹 10. Import Libraries import math 💡 Mastering these basics is the first step towards becoming a Python Developer or Automation Tester. ✨ Consistency > Perfection 💬 What was the first Python command you learned? #Python #Programming #CodingForBeginners #AutomationTesting #QA #TechLearning #100DaysOfCode #Developers #LearnPython
To view or add a comment, sign in
-
11 Useful Python List Methods Working with lists is common in almost every Python project. Understanding these built-in methods makes your code cleaner and more efficient. Here are 11 essential list methods: 1) append() → Add a single item to the list. 2) extend() → Add multiple items individually. 3) insert() → Add an item at a specific index. 4) remove() → Remove the first matching item. 5) pop() → Remove and return an item. 6) index() → Find the position of an item. 7) count() → Count how many times an item appears. 8) sort() → Sort the list in place. 9) reverse() → Reverse the order of elements. 10) clear() → Remove all items from the list. 11) reverse() → Reverse the order of elements. These small methods are simple, but they appear frequently in real-world code. Mastering them improves readability and reduces unnecessary logic. Comment below, Which list method do you use the most? Comment below. Save this for quick revision later. 📌 I share simple Python and backend learnings here. #Python #LearnPython #Programming #Coding #SoftwareEngineering #PythonDeveloper
To view or add a comment, sign in
-
-
🚀 Python Basics: Lists & Tuples Every Beginner Should Know If you're starting with Python, understanding Lists and Tuples is a game changer 💡 🔹 1. What is a List? A list is a collection of items that is ordered, changeable (mutable) and allows duplicates Example: fruits = ["apple", "banana", "mango"] 🔹 2. Common List Methods ✔ append() → Add item at the end fruits.append("orange") ✔ sort() → Sort list (Ascending by default) numbers.sort() # Ascending numbers.sort(reverse=True) # Descending ✔ reverse() → Reverse the list fruits.reverse() ✔ insert() → Add item at specific index fruits.insert(1, "grapes") ✔ remove() → Remove specific item fruits.remove("banana") ✔ pop() → Remove item using index (last by default) fruits.pop() 🔹 3. What is a Tuple? A tuple is a collection that is ordered but NOT changeable (immutable) 🔒 Example: colors = ("red", "green", "blue") 💡 Key Difference: 👉 List = Mutable (can change) 👉 Tuple = Immutable (cannot change) 📌 Use lists when data can change, and tuples when data should remain constant. Mastering these will make your Python journey smoother 🚀 #Python #LearnPython #CodingForBeginners #Programming #AutomationTesting #SoftwareTesting #TechLearning #100DaysOfCode
To view or add a comment, sign in
-
🚀 Python for Beginners: Must-Know String & Basics Concepts Starting your Python journey? Here are some fundamental concepts you must master to build a strong foundation 👇 🔹 1. Concatenation Combine strings easily using + Example: "Hello" + " World" → "Hello World" 🔹 2. Length of String Use len() to find how many characters are in a string Example: len("Python") → 6 🔹 3. Indexing Access individual characters using index positions Example: "Python"[0] → 'P' 🔹 4. Slicing Extract parts of a string Example: "Python"[0:3] → 'Pyt' 🔹 5. String Functions Commonly used functions: ✔ upper() → Convert to uppercase ✔ lower() → Convert to lowercase ✔ strip() → Remove spaces ✔ replace() → Replace characters 🔹 6. Conditional Statements Make decisions using if-else Example: if age > 18: print("Adult") else: print("Minor") 🔹 7. Indentation (Very Important ⚠️) Python uses indentation (spaces/tabs) to define code blocks Wrong indentation = Error ❌ 💡 Pro Tip: Always keep your code clean and properly indented—it's the heart of Python syntax! 📌 Master these basics, and you're already ahead of many beginners. #Python #CodingForBeginners #LearnPython #Programming #SoftwareTesting #AutomationTesting #TechCareers #100DaysOfCode
To view or add a comment, sign in
-
Day 2 of my #100DaysOfCodewithAngelaYu journey with Python 💻 As a beginner, I spent the day exploring the fundamentals of programming and building my first small project — a Tip Calculator. Some of the key concepts I learned include: - Data types – understanding integers, floats, and strings. - Type errors, type checking, and type conversion – making sure inputs are valid and compatible for calculations. - Mathematical operations in Python – performing calculations and handling percentages. - Number manipulation and f-strings – formatting results neatly for the user. 𝐌𝐢𝐧𝐢 𝐏𝐫𝐨𝐣𝐞𝐜𝐭: Tip Calculator 💰 For my Day 2 project, I created a Tip Calculator in Python. This small program allows a user to: - Enter the total bill amount - Specify a tip percentage - Indicate how many people will split the bill The program then: - Calculates the tip based on the percentage - Adds it to the total bill - Divides the total by the number of people - Outputs the final amount per person, rounded to 2 decimal places using f-strings This project helped me see how these building blocks come together to create a working, interactive program. I’m excited to continue my journey and explore more Python projects, including interactive apps with Streamlit, in the coming days! 🚀 #Python #100DaysOfCode #LearningByDoing #CodingJourney #Streamlit
To view or add a comment, sign in
-
🚀 Just built a simple Calculator using Python! Today I practiced basic programming concepts and created a calculator that can perform: ✅ Addition ✅ Subtraction ✅ Multiplication ✅ Division (with zero error handling) This project helped me understand: 🔹 if-elif-else conditions 🔹 User input handling 🔹 Basic error handling in Python Here’s a small snippet of my code 👇 num1 = float(input("Enter your first num: ")) num2 = float(input("Enter your second: ")) print("Select operation:") print("1 Add") print("2 Subtract") print("3 Multiply") print("4 Divide") choice = input("Enter choice (1/2/3/4): ") if choice == '1': print("Result:", num1 + num2) elif choice == '2': print("Result:", num1 - num2) elif choice == '3': print("Result:", num1 * num2) elif choice == '4': if num2 == 0: print("Error: Division by zero") else: print("Result:", num1 / num2) else: print("Invalid Input") Learning & Improving Every Day 🚀 💡 Today I practiced Python by building a simple calculator! Always exploring, always growing. #Python #Programming #Learning #Coding #Beginner #MdMoiz929
To view or add a comment, sign in
-
-
🚀 Just built a simple Calculator using Python! Today I practiced basic programming concepts and created a calculator that can perform: ✅ Addition ✅ Subtraction ✅ Multiplication ✅ Division (with zero error handling) This project helped me understand: 🔹 if-elif-else conditions 🔹 User input handling 🔹 Basic error handling in Python Here’s a small snippet of my code 👇 num1 = float(input("Enter your first num: ")) num2 = float(input("Enter your second: ")) print("Select operation:") print("1 Add") print("2 Subtract") print("3 Multiply") print("4 Divide") choice = input("Enter choice (1/2/3/4): ") if choice == '1': print("Result:", num1 + num2) elif choice == '2': print("Result:", num1 - num2) elif choice == '3': print("Result:", num1 * num2) elif choice == '4': if num2 == 0: print("Error: Division by zero") else: print("Result:", num1 / num2) else: print("Invalid Input") Learning & Improving Every Day 🚀 💡 Today I practiced Python by building a simple calculator! Always exploring, always growing. #Python #Programming #Learning #Coding #Beginner #MdMoiz929
To view or add a comment, sign in
-
-
🚀 Just built a simple Calculator using Python! Today I practiced basic programming concepts and created a calculator that can perform: ✅ Addition ✅ Subtraction ✅ Multiplication ✅ Division (with zero error handling) This project helped me understand: 🔹 if-elif-else conditions 🔹 User input handling 🔹 Basic error handling in Python Here’s a small snippet of my code 👇 num1 = float(input("Enter your first num: ")) num2 = float(input("Enter your second: ")) print("Select operation:") print("1 Add") print("2 Subtract") print("3 Multiply") print("4 Divide") choice = input("Enter choice (1/2/3/4): ") if choice == '1': print("Result:", num1 + num2) elif choice == '2': print("Result:", num1 - num2) elif choice == '3': print("Result:", num1 * num2) elif choice == '4': if num2 == 0: print("Error: Division by zero") else: print("Result:", num1 / num2) else: print("Invalid Input") Learning & Improving Every Day 🚀 💡 Today I practiced Python by building a simple calculator! Always exploring, always growing. #Python #Programming #Learning #Coding #Beginner #MdMoiz929
To view or add a comment, sign in
-
More from this author
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development