🚀 𝐓𝐞𝐱𝐭 𝐕𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬 𝐢𝐧 𝐏𝐲𝐭𝐡𝐨𝐧: Python allows storing text in variables using either double quotes (" ") or single quotes (' ') — both behave the same way. 🔹 𝐒𝐢𝐧𝐠𝐥𝐞 𝐪𝐮𝐨𝐭𝐞𝐬 𝐯𝐬 𝐃𝐨𝐮𝐛𝐥𝐞 𝐪𝐮𝐨𝐭𝐞𝐬 - Both can be used to store strings. text = "Hello" print(text) text = 'Hello' print(text) 𝘖𝘶𝘵𝘱𝘶𝘵: Hello Hello 🔹 𝐌𝐮𝐥𝐭𝐢-𝐥𝐢𝐧𝐞 𝐭𝐞𝐱𝐭 𝐮𝐬𝐢𝐧𝐠 𝐭𝐫𝐢𝐩𝐥𝐞 𝐪𝐮𝐨𝐭𝐞𝐬 text = """ Hello Python """ print(text) 𝘖𝘶𝘵𝘱𝘶𝘵: Hello Python 🔹 𝐔𝐬𝐢𝐧𝐠 \𝐧 𝐟𝐨𝐫 𝐥𝐢𝐧𝐞 𝐛𝐫𝐞𝐚𝐤𝐬 text = """ Hello\nPython """ print(text) 𝘖𝘶𝘵𝘱𝘶𝘵: Hello Python Simple features like these make Python very convenient when formatting text and printing structured output #Python #Coding
Harini M S’ Post
More Relevant Posts
-
One of the most underrated features in Python is the dunder (double underscore) method system. These methods are what make Python objects behave like built‑ins. Examples: • __init__ → object initialization • __str__ → human readable representation • __len__ → behavior for len() • __add__ → custom + operator Example: class Vector: def __add__(self, other): return Vector(self.x + other.x, self.y + other.y) Now Python understands how to use + with your objects. Under the hood, Python transforms: a + b into: a.__add__(b) This is one reason Python feels so expressive and flexible. Understanding dunder methods means understanding how Python really works.
To view or add a comment, sign in
-
-
🧠 Python Concept: join() for Strings Stop using + in loops 😵💫 ❌ Traditional Way words = ["Python", "is", "awesome"] sentence = "" for word in words: sentence += word + " " print(sentence.strip()) ❌ Problem 👉 Slow 👉 Messy 👉 Hard to read ✅ Pythonic Way words = ["Python", "is", "awesome"] sentence = " ".join(words) print(sentence) 🧒 Simple Explanation Think of join() like a glue 🧴 ➡️ It connects all words ➡️ Uses a separator (" ") ➡️ Gives a clean result 💡 Why This Matters ✔ Much faster than + ✔ Cleaner code ✔ Used in real-world string processing ✔ Avoids unnecessary loops ⚡ Bonus Example data = ["2026", "03", "27"] date = "-".join(data) print(date) 👉 Output: 2026-03-27 🐍 Don’t build strings piece by piece 🐍 Join them smartly #Python #PythonTips #CleanCode #LearnPython #Programming #Join #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
VARIABLES AND DATATYPE 1. Variable is a name that refers to a value. It is used to store data in memory. 2. In Python, you can create a variable by simply assigning a value to it Example: x = 10 y = "Hello, World!" z = 3.14 3. Python is a dynamically typed language, which means you don't need to declare the type of a variable. The type is inferred from the value assigned to it. 4. You can change the value of a variable at any time, and it can also change its type. Example: x = 10 print(x) # Output: 10 x = "Now I'm a string!" print(x) # Output: Now I'm a string! 5. Python has several built-in data types, including: - Integer (int) - String (str) - Float (float) - Boolean (bool)
To view or add a comment, sign in
-
Basic data types in python :- 1) int : to declare integer numbers 2) float : to declare floating point numbers 3) strings : to declare strings 4) Boolean: to compare true and false values 5) list : to list the item into a array , mutable [. ] 6) set : represents in {. } 7) dic : values will be represented in key and values basis 8) tuple: ordered values and values defined we can't change it to get know the type of declared value : my_value = 'Learn something' type (my_value) type () :- function will provide the type of the value declared and defined #learn #python #beginner #content #creator #something #big #dreem #teach
To view or add a comment, sign in
-
-
Python: The "Mutable Default" Trap Topic: Function Definitions & Memory Difficulty: Intermediate Question: What is the output of the final line of this code? def add_item(item, box=[]): box.append(item) return box print(add_item("Apple")) print(add_item("Banana")) A) ['Apple'] then ['Banana'] B) ['Apple'] then ['Apple', 'Banana'] C) ['Apple'] then Error: box is not defined D) ['Banana'] then ['Banana'] Did you know Python evaluates default arguments only once at the time of function definition? If you chose B, you understand why we usually use box=None instead!
To view or add a comment, sign in
-
🧠 Python Concept: sorted() vs sort() ✨ Both sort data, but they behave differently. ✨ sorted() → Returns a new sorted list numbers = [5, 2, 8, 1] result = sorted(numbers) print(numbers) # Original list print(result) # Sorted list Output [5, 2, 8, 1] [1, 2, 5, 8] The original list stays unchanged. ✨ list.sort() → Sorts in place numbers = [5, 2, 8, 1] numbers.sort() print(numbers) Output [1, 2, 5, 8] The original list is modified. 🧒 Simple Explanation 📚 Imagine arranging books 📚 sorted() → makes a new sorted pile 📚 sort() → rearranges the same pile 💡 Why This Matters ✔ Understand side effects ✔ Avoid unexpected bugs ✔ Cleaner data processing ✔ Common interview question 🐍 In Python, sorted() and sort() look similar but behave differently 🐍 One creates a new list, the other modifies the existing one. #Python #PythonTips #PythonTricks #AdvancedPython #CleanCode #LearnPython #Programming #DeveloperLife #DailyCoding #100DaysOfCode
To view or add a comment, sign in
-
-
🧠 Python Concept: map() Apply a function to all items effortlessly 😎 ❌ Traditional Way numbers = [1, 2, 3, 4] squared = [] for num in numbers: squared.append(num * num) print(squared) ✅ Pythonic Way numbers = [1, 2, 3, 4] squared = list(map(lambda x: x * x, numbers)) print(squared) 🧒 Simple Explanation Think of map() like a machine 🏭 ➡️ It takes each item ➡️ Applies a function ➡️ Gives back results automatically 💡 Why This Matters ✔ Cleaner functional style ✔ No manual loops ✔ Useful in data processing ✔ Works great with lambda functions ⚡ Bonus Example names = ["alice", "bob", "charlie"] upper_names = list(map(str.upper, names)) print(upper_names) 🐍 Transform data like a pro 🐍 Let Python do repetitive work #Python #PythonTips #CleanCode #LearnPython #Programming #DeveloperLife #100DaysOfCode
To view or add a comment, sign in
-
-
Something shifted for me this week. I stopped learning Python. And started using it. There's a difference, and it's everything. Learning is following a tutorial, reproducing what someone shows you, and feeling clever when it works. Using is sitting in front of a blank file with a real problem and figuring it out. This week I built a script that analyzes weekly sales data for 6 products, calculates totals and averages, flags low-volume items, and saves results to CSV. Nobody told me how to structure it. I just built it. I broke it 4 times. Fixed it 4 times. And when it finally ran cleanly and printed the summary I needed that felt different from any tutorial win. That's the moment I think people mean when they say "it clicked." Not when you understand the syntax. When you forget about the syntax and just solve the problem. Have you had that moment yet? #Python #LearningInPublic #SupplyChain #BuildInPublic
To view or add a comment, sign in
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