🚀 Day 10 of My Python Learning Journey – Understanding Strings in Python 🐍 Strings are one of the most commonly used data types in Python. They are used to store text data like names, messages, addresses, and more. 🔹 What is a String? A string is a sequence of characters enclosed in: Single quotes → 'Hello' Double quotes → "Hello" Triple quotes → '''Hello''' or """Hello""" (for multi-line text) Python Copy code name = "Vani" message = 'Welcome to Python' 🔹 Key Features of Strings ✅ Strings are Immutable 👉 Once created, we cannot change the characters inside a string. Python Copy code text = "Python" # text[0] = "J" ❌ Error (Strings are immutable) ✅ Strings support Indexing Python Copy code word = "Python" print(word[0]) # P print(word[-1]) # n ✅ Strings support Slicing Python Copy code print(word[0:4]) # Pyth 🔹 Common String Methods Python Copy code text = "python learning" print(text.upper()) # PYTHON LEARNING print(text.lower()) # python learning print(text.title()) # Python Learning print(text.replace("python", "Java")) print(len(text)) # Length of string 🔹 String Concatenation Python Copy code first = "Hello" second = "World" print(first + " " + second) # Hello World 🎯 Why Strings are Important? Strings are used in: User input Displaying output Working with files Web development Data processing ✨ Day 10 Complete! Today I learned that strings are immutable, support indexing & slicing, and come with powerful built-in methods. #Python #100DaysOfCode #LearningJourney #Strings #Coding
Understanding Strings in Python with Vani
More Relevant Posts
-
Python Tip Every Beginner Should Know One concept that saves you from many bugs in Python Mutable vs Immutable Objects In Python, some objects can change after creation, while others cannot. 🔹 Immutable Objects (cannot change) Examples: int, float, string, tuple x = 10 x = x + 5 print(x) Here Python creates a new object instead of modifying the original one. Another example: name = "Python" name[0] = "J" # Error Strings are immutable, so their values cannot be changed. 🔹 Mutable Objects (can change) Examples: list, dictionary, set numbers = [1, 2, 3] numbers.append(4) print(numbers) Output: [1, 2, 3, 4] Here the same list object is modified. 💡 Why this matters? If you pass a list to a function, the original data can change. def add_item(lst): lst.append(100) data = [1, 2, 3] add_item(data) print(data) Output: [1, 2, 3, 100] Understanding this concept helps a lot in: ✔ Data Analysis ✔ Machine Learning ✔ Writing clean Python code 📌 Tip: If you want to avoid modifying the original list: new_list = old_list.copy() Small Python concepts like this make a big difference in writing better code. If you're learning Python, remember this: Mutable → Can change Immutable → Cannot change If you're learning Python, mastering small concepts like this makes a big difference. #Python #PythonProgramming #Coding #DataScience #LearnPython #ProgrammingTips #DataAnalyst
To view or add a comment, sign in
-
🐍 Python Challenge — Day 8 🚀 📚 String Manipulation String manipulation is one of the most essential skills in Python programming. Since strings represent textual data, they are widely used in data processing, automation, web development, and data analysis. 🔹What is String Manipulation? It refers to performing operations on text data such as modifying, searching, formatting, and analyzing strings, another words- Strings are simply text data in Python — like names, messages, or sentences. String manipulation means changing or working with that text. Think of it like editing text in WhatsApp or Word. 🔹 Common String Operations in Python ✅ Make text uppercase or lowercase text = "hello python" print(text.upper()) # HELLO PYTHON 👉 Changes text to capital letters. ✅ Replace words text = "Hello Python" print(text.replace("Python", "World")) 👉 Replaces Python with World → Hello World ✅ Remove extra spaces text = " Python " print(text.strip()) 👉 Removes spaces from beginning and end. ✅ Split sentence into words text = "I love Python" print(text.split()) 👉 Converts sentence into a list → ['I', 'love', 'Python'] ✅ Join words together words = ["I", "love", "Python"] print(" ".join(words)) 👉 Combines words into a sentence. 💡 Simple Idea to Remember: ➡️ Strings = Text ➡️ String Manipulation = Editing Text Using Code 🚀 Learning string manipulation makes handling user input, data cleaning, and automation much easier. #Python #Programming #LearningInPublic #DeveloperJourney #30DaysChallenge
To view or add a comment, sign in
-
-
🔹 Sorting in Python – A Simple Guide for Beginners Sorting is a very common operation in programming. It helps us arrange data in a specific order, such as ascending or descending. Sorting makes it easier to search, analyze, and organize data efficiently. In Python, there are two main ways to sort data: 1️⃣ sort() Method The "sort()" method is used to sort lists. It modifies the original list. Example: numbers = [5, 2, 9, 1, 7] numbers.sort() print(numbers) Output: [1, 2, 5, 7, 9] Descending Order numbers.sort(reverse=True) print(numbers) Output: [9, 7, 5, 2, 1] 2️⃣ sorted() Function The "sorted()" function returns a new sorted list without changing the original data. Example: numbers = [5, 2, 9, 1, 7] sorted_numbers = sorted(numbers) print(sorted_numbers) Output: [1, 2, 5, 7, 9] --- Custom Sorting using key Python also allows sorting based on specific criteria using the "key" parameter. Example: Sort words by their length. words = ["apple", "kiwi", "banana", "grape"] words.sort(key=len) print(words) Output: ['kiwi', 'apple', 'grape', 'banana'] 1. `sort()` vs `sorted()` 2. Ascending & Descending 3. Sorting Strings 4. Sorting Dictionaries 5. Sorting Custom Objects 6. Stable Sorting 7. Reversing Lists 8. `itemgetter` (faster than lambda) 9. `heapq` for partial sorting 10. Timsort internals + a **cheat sheet table** 💡 Conclusion Understanding sorting is an essential skill for every Python developer. It helps in organizing data, improving search efficiency, and solving many real-world problems. #Python #Programming #LearningPython #CodingJourney #PythonBasics #100DaysOfCodeIf
To view or add a comment, sign in
-
-
When I started learning Python, I used lists for almost everything. But as I progressed, I realized something important: Choosing the wrong data structure can make your code slower, messy, and harder to maintain. While writing this article, I researched and went deeper into understanding how Python data structures actually work behind the scenes — hashing, mutability, and memory behavior — and then tried to simplify those concepts into a beginner-friendly decision guide. 🧠 Choosing the Right Python Data Structure: List, Tuple, Set, or Dictionary In this blog, I explain: • When to use List vs Tuple • Why Sets are powerful for fast lookups • How Dictionaries power real-world systems • A simple decision framework to choose the right structure Writing this blog helped me strengthen both my Python fundamentals and my ability to explain technical concepts clearly. If you're starting your Python journey and want to understand not just what to use but why, this might save you hours of confusion. 🔗 Read here: https://lnkd.in/d2zYBfwi Would love your feedback! Innomatics Research Labs #Python #DataStructures #BeginnerFriendly #LearningInPublic #ArtificialIntelligence #CodingJourney #InnomaticsResearchLabs
To view or add a comment, sign in
-
Ever wondered why your Python script slows down when your data grows? 🐍 I used to think of Lists and Dictionaries as just simple "containers," but digging into how Python handles memory "under the hood" changed my perspective on writing efficient code. In my latest blog post, I break down: 🔹 The "Moving Day" problem: How Lists actually grow in memory. 🔹 The Library GPS: Why Dictionaries are so much faster than Lists. 🔹 Why Tuples are the lightweight "speedsters" of Python. If you're a student or developer looking to move from just "making it work" to "making it smart," this one is for you. #Python #Coding #DataStructures #SoftwareEngineering #LearningJourney
To view or add a comment, sign in
-
🐍 Python Challenge — Day 1 🚀 📚 Variables & Data Types Variables are one of the fundamental building blocks in Python. They allow us to store data so it can be reused, updated, and processed throughout a program. Instead of repeating values multiple times, we assign them to meaningful names — which makes code cleaner and easier to read. Data types tell Python what kind of value is stored (text, number, etc.). ✨ Here are the main Python data types you’ll use : 🔢 1. Numbers • int → Whole numbers (10, -3) • float → Decimal numbers (3.14, 99.9) • complex → Advanced numbers (2+3j) 📝 2. Strings (str) Used to store text → "Hello World" Perfect for names, messages, and user input. 📦 3. Lists (list) Ordered & changeable collection → [1, 2, 3] Great when you need to add or remove items. 📍 4. Tuples (tuple) Ordered but unchangeable → (1, 2, 3) Useful when data should stay fixed. 🗂️ 5. Dictionaries (dict) Data stored as key–value pairs → {"name":"Alex", "age":21} Super useful for real-world data handling. 🎯 6. Sets (set) Unordered collection of unique values → {1, 2, 3} Helps remove duplicates easily. ✔️ 7. Boolean (bool) Only two values → True or False Used in decisions and conditions. ⚙️ Use: Store and manage data while a program runs. 🕒 When to use: Whenever you need to save values for later use. 💻 Code: name = "Python" age = 10 print(name, age) 🧩 Code Explanation (Concepts): • name = "Python" → Stores text (string) in a variable. • age = 10 → Stores a number (integer). • print() → Displays output on the screen. 🧠 Practice Questions: 1️⃣ Create variables for your name and age. 2️⃣ Print three different data types. 🔥 Small takeaway: Variables are the foundation of programming. #Python #Programming #LearningInPublic #DeveloperJourney #30DaysChallenge
To view or add a comment, sign in
-
-
🚀 Excited to share my first Python project – Unlimited Calculator ♾️ Today, as a beginner in Python, I built an Unlimited Calculator that can perform:✅ Addition✅ Subtraction✅ Multiplication✅ Division✅ Solve BODMAS expressions✅ Run continuously until user exits This project helped me understand important Python concepts like:• User input handling• Conditional statements (if-elif-else)• Infinite loops (while loop)• Break statement• Writing real-world logic Here is the code I wrote: print("===== Unlimited Calculator =====") while True: print("\nSelect operation:") print("1. Addition") print("2. Subtraction") print("3. Multiplication") print("4. Division") print("5. BODMAS Expression") print("6. Exit") choice = input("Enter choice (1-6): ") if choice == "1": num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) print("Result =", num1 + num2) elif choice == "2": num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) print("Result =", num1 - num2) elif choice == "3": num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) print("Result =", num1 * num2) elif choice == "4": num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) if num2 != 0: print("Result =", num1 / num2) else: print("Cannot divide by zero") elif choice == "5": expression = input("Enter expression: ") print("Result =", eval(expression)) elif choice == "6": print("Calculator closed.") break else: print("Invalid choice") 🌱 This is just the beginning of my Python journey. Looking forward to building more projects in Python, Data Science, and Analytics. #Python #Beginner #LearningPython #CodingJourney #Programming #DataScience #WomenInTech
To view or add a comment, sign in
-
Variables in python: 💡 What if I told you… In Python, a “variable” doesn’t actually store data? Yes! Let that sink in for a second. When I first started learning Python, I thought: num = 100 means the variable(num) stores 100. But that’s not entirely true. 🔎 Here’s what really happens: 🔹 Variables A variable is just a name that references an object in memory. It points to data — it doesn’t physically store it. When you reassign: - num = 100 - num = 200 You’re not “changing the box.” You’re making the name point to a new object. That small understanding changes how you think about Python. 🔒 What About Constants? Python doesn’t truly enforce constants. Instead, we follow a professional convention: PI = 3.14 MAX_USERS = 1000 Uppercase indicates = “Please don’t change this.” It’s discipline, not enforcement, and discipline makes better developers. Constants is also the value that variable holds. For every constant there will be a specific memory. 🧠 And Then There Are Data Types… Every value in Python has a type: Integers → Whole numbers (25,-34) Float → Decimal numbers (99.99) String → Anything written inside '.....', "......." ,'''.....'''' or """....""" will be called as a string value. - it can be a character, a word or a sentence or even other datatypes Example-("Hello", " 65",'0.86','"false"') Boolean → True / False Data types define how Python behaves with that value. Add two integers? ✅ Add a string and an integer? ❌ Error. Programming isn’t about memorizing code. It’s about understanding how things actually work behind the scenes. Excited for what’s next 🚀 #DataScience #Python #SQL #ProgrammingBasics #LearningInPublic #CareerGrowth
To view or add a comment, sign in
-
-
I have published my blog on “Choosing the Right Python Data Structure: A Beginner’s Decision Guide.” In this article, I explained lists, tuples, sets, and dictionaries in simple language with practical examples to help beginners understand when to use each one. This helped me strengthen my fundamentals in Python data structures. You can read the full blog here: https://lnkd.in/gD4avGDs. Innomatics Research Labs #Python #DataStructures #Learning #InnomaticsResearchLabs
To view or add a comment, sign in
-
#Day 11 /50DaysChallenge #Strings in Python ✨String: A string is a collection of characters inside quotes. Example: name = "Python" ✅ String Indexing text = "Python" print(text[0]) # P print(text[3]) # h ✅ String Slicing text = "Python" print(text[0:3]) # Pyt print(text[2:6]) # thon ✅ String Methods (Important) text = "python programming" print(text.upper()) # PYTHON PROGRAMMING print(text.lower()) # python programming print(text.title()) # Python Programming print(text.replace("python", "java")) Task: Take a string from user and print: - Length - Uppercase - Lowercase - Reverse string Code: text = input("Enter a string: ") print("Length:", len(text)) print("Uppercase:", text.upper()) print("Lowercase:", text.lower()) print("Reverse:", text[::-1]) ✅ Example Output: Enter a string: Python Length: 6 Uppercase: PYTHON Lowercase: python Reverse: nohtyP #50Dayschallenge #coding #pythonbascis #ece #bve
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