Python Basics: Type Casting, f-Strings, Indexing & Lists

🐍 Python Basics – Must-Know Concepts for Beginners If you're starting your Python journey, here are some core concepts you should understand 👇 🔹 Type Casting (Old Style Formatting) Used to format strings using % Example: "My name is %s and age is %d" 👉 %s = string 👉 %d = integer 🔹 f-Strings (Modern Way 🚀) The best and most readable way to format strings Example: f"My name is {name} and age is {age}" ✅ Clean ✅ Fast ✅ Easy to understand 🔹 Raw String (r-string) Used when dealing with paths and escape characters Example: r"c:\vijay\new\tamil\movies" 👉 Prevents \n, \t from acting as special characters 🔹 Index (Position of Elements) Python starts indexing from 0 Example: text = "python" 👉 text[0] = 'p' 👉 text[-1] = 'n' (reverse indexing) 🔹 List (Collection of Data) Stores multiple values in one variable Example: [10, 20, 30, 40] Common operations: ✔ Add → append() ✔ Remove → remove() ✔ Sort → sort() ✔ Descending → sort(reverse=True) 🔹 count() Function Counts how many times a value appears Example: "vijay tamil movies".count("a") → 2 #Python #Programming #Coding #Learning #DataScience

To view or add a comment, sign in

Explore content categories