🔤 Strings in Python – Quick Guide Strings are used to store text data in Python. They are simple, powerful, and used everywhere — from data cleaning to report generation. Creating Strings s1 = 'Hello' s2 = "Python" s3 = """Multi-line string""" Access & Slicing text = "Python" text[0] # P text[-1] # n text[0:3] # Pyt Common Operations "Hello" + " World" # Concatenation "Hi " * 3 # Repetition Useful String Methods text = " hello world " text.upper() # HELLO WORLD text.lower() # hello world text.strip() # remove spaces text.replace("world","Python") text.split() String Formatting (Best Practice) name = "Maha" print(f"Hello {name}") Important: Strings are immutable (cannot be changed directly) text = "hello" text = "H" + text[1:] #Python #PythonBasics #DataAnalytics #Programming #LearnPython #Coding #DataScience #PythonForBeginners #100DaysOfCode
Python String Guide: Creation, Access, and Operations
More Relevant Posts
-
Python Data Types — One Post Cheat Sheet Understanding data types is fundamental to writing efficient Python code. Here’s a quick overview: 🔢Numeric int → 10 float → 10.5 complex → 2+3j 🔤 String (str) Ordered & immutable Example: "Hello Python" 📋 List Ordered, mutable, allows duplicates Example: [10, 20, 30] 📦 Tuple Ordered, immutable Example: (10, 20, 30) 🔁 Set Unordered, no duplicates Example: {10, 20, 30} 📖 Dictionary Key–value pairs, mutable Example: {"name": "Maha", "age": 25} 🧠 Boolean True / False Used in conditions 🔍 Check Type type(variable) Choosing the right data type improves performance, readability, and data handling. #Python #DataTypes #PythonBasics #Programming #LearnPython #Coding #DataAnalytics #PythonForBeginners
To view or add a comment, sign in
-
-
90% of Data Work = Cleaning. SQL & Python Side‑by‑Side. Cleaning isn’t just prep it’s analysis. Here’s how SQL and Python mirror each other when tackling: Missing values Duplicates Formatting Outliers 👉Full break down here : https://lnkd.in/gUuRJExK #DataScience #SQL #Python #Analytics #BigData #MachineLearning #CareerGrowth
To view or add a comment, sign in
-
Most Python classes I've seen in DS projects do too much! They load data, clean it, transform it, run the model, and log results... all in one place. It feels efficient until you need to change one thing and have to re-test everything else. That's the cost of ignoring the Single Responsibility Principle. 🐍 In my latest article, I break down what SRP actually means for Python data pipelines: https://lnkd.in/esKz_ARk This is post 1 of 5 in a series on SOLID principles applied to Data Science code. What's the messiest class you've inherited on a DS project? 👇 #Python #DataScience #SoftwareEngineering #SOLID #DataEngineering
To view or add a comment, sign in
-
🚀 #python #Ep 2: Understanding #Data Types in Python In Python, everything is an object, and every object has a data type. Data types define what kind of value a variable holds and what operations you can perform on it. 🔗 Code reference: https://lnkd.in/ei6STRqT 🧠 Why Data Types Matter? Prevent errors in your code Help Python understand how to store and process data Make your programs efficient and readable 📌 Common Python Data Types 🔢 Numeric Types int → Whole numbers (10, -5) float → Decimal numbers (3.14) complex → Complex numbers (2+3j) 📝 String (str) Used to store text Example: "Hello Python" ✅ Boolean (bool) Only two values: True or False 📦 Sequence Types list → Ordered & mutable → [1, 2, 3] tuple → Ordered & immutable → (1, 2, 3) 🗂️ Mapping Type dict → Key-value pairs → {"name": "Hari"} 🔁 Set Types set → Unordered & unique values → {1, 2, 3} 💡 Pro Tip Python is dynamically typed, meaning you don’t need to declare data types explicitly — Python figures it out at runtime 🔍 Example x = 10 # int y = 3.14 # float name = "Hari" # str is_active = True # bool 📣 Final Thought Mastering data types is the foundation of Python programming. Once you understand them, everything else becomes easier! #Python #Coding
To view or add a comment, sign in
-
-
Stop using + to join strings in Python! 🐍 When you are first learning Python, it is tempting to use the + operator to build strings. It looks like this: name = "Gemini" status = "coding" print("Hello, " + name + " is currently " + status + ".") The Problem? In Python, strings are immutable. Every time you use +, Python has to create a brand-new string in memory. If you are doing this inside a big loop, your code will slow down significantly. The Pro Way: f-strings (Fast & Clean) Since Python 3.6, f-strings are the gold standard. They are faster, more readable, and handle data types automatically. The 'Pro' way: print(f"Hello, {name} is currently {status}.") Why use f-strings? Speed: They are evaluated at runtime rather than constant concatenation. Readability: No more messy quotes and plus signs. Power: You can even run simple math or functions inside the curly braces: print(f"Next year is {2026 + 1}") Small changes in your syntax lead to big gains in performance. Are you still using + or have you made the switch to f-strings? Let’s talk Python tips in the comments! 👇 #Python #CodingTips #DataEngineering #SoftwareDevelopment #CleanCode #PythonProgramming
To view or add a comment, sign in
-
Python: sort() vs sorted() Have you ever had to pause for a second and think: “Do I need sort() or sorted() here?” 😅 This is the common Python confusions. Let’s clear it up. 🔹 list.sort() ◾ A method (belongs to list objects) ◾ Works only on lists ◾ Sorts the list in-place ◾ Changes the original list ◾ Returns None Example: numbers = [3, 1, 4, 2] numbers.sort() print(numbers) # [1, 2, 3, 4] 🔹 sorted() ◾ A function (built-in Python function) ◾ Returns a new sorted list ◾ Does NOT change the original ◾ Works on any iterable Example: numbers = [3, 1, 4, 2] new_numbers = sorted(numbers) print(new_numbers) # [1, 2, 3, 4] print(numbers) # [3, 1, 4, 2] The key difference: sort() → changes your original data sorted() → keeps your original data safe 💡 Quick way to remember: 👉 If you want to keep the original, use sorted() 👉 If you want to modify the list directly, use sort() #Python #Programming #LearnPython #DataScience #LearningJourney #WomenInTech
To view or add a comment, sign in
-
-
📘 **Day 11 – File Handling in Python** Today I learned about **File Handling in Python** 📂 👉 File handling allows us to **create, read, write, and update files**. It helps store data permanently instead of keeping it only in memory. 🔹 **Types of Modes:** * `r` → Read file * `w` → Write (overwrites file) * `a` → Append (adds data) * `x` → Create new file 🔹 **Basic Example:** ```python # Writing to a file file = open("example.txt", "w") file.write("Hello, Python!") file.close() # Reading from a file file = open("example.txt", "r") print(file.read()) file.close() ``` 💡 **Best Practice:** Use `with` statement (auto closes file) ```python with open("example.txt", "r") as file: data = file.read() print(data) ``` ✨ **Key Learning:** File handling is important for saving data like logs, user input, and reports. 🚀 Step by step becoming better in Python! #Day11 #Python #CodingJourney #FileHandling #SkillCourse #DataAnalyst
To view or add a comment, sign in
-
🚀 Escape Sequences & Raw Strings in Python (Beginner Friendly!) 🐍 Understanding strings is one of the first steps to writing clean Python code. 🔹 Escape Sequences Special characters used inside strings: - "\n" → New line - "\t" → Tab space - "\\" → Backslash 🔹 Raw Strings (r"") Treat backslash as normal text (no special meaning) 👉 Example: print("Hello\nWorld") print(r"C:\Users\Name\Documents") 🎥 I’ve explained this clearly with examples in my latest video 👇 👉 [https://lnkd.in/gv45tifv] 💡 This is very useful when working with: ✔ File paths ✔ Regular expressions ✔ Clean string formatting If you're starting Python or Data Science, this is a must-know concept! #Python #CodingForBeginners #DataScience #LearnPython #YouTubeLearning
To view or add a comment, sign in
-
SQL or Python — which one should you learn for data analysis? 🤔 The truth is: you don’t have to choose one over the other. 🔹 SQL helps you extract and manage structured data 🔹 Python helps you analyze, automate, and visualize it Together, they make a powerful combo for any data professional. 💡 Start with SQL for data handling, then level up with Python for deeper insights. #DataAnalytics #SQL #Python #DataScience #LearningJourney
To view or add a comment, sign in
-
-
I’ve been exploring Python visualization tools recently, and realized I was choosing libraries based on habit more than understanding. This helped me a lot: https://lnkd.in/dRWuftDb It gives a simple, clear view of the ecosystem and when to use each tool. Sometimes all you need is the right map. What’s your go-to visualization library in Python? #Python #DataVisualization #DataScience #MachineLearning #SoftwareEngineering #Plotly #Matplotlib #Seaborn #Streamlit #Dash
To view or add a comment, sign in
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