Why does Python start counting from 0, not 1? "Why is the first item at index [0]?" — Every Python beginner asks this. 🐍 fruits = ['apple', 'banana', 'cherry'] print(fruits[0]) # Prints 'apple', not fruits[1] The reason: It's not random! It's based on memory offsets. Think of it like house addresses on a street: • Index 0 = "0 steps from the start" • Index 1 = "1 step from the start" • Index 2 = "2 steps from the start" This makes math in programming faster and is why almost all modern languages (C, Java, JavaScript) follow the same rule. Fun fact: Some older languages like MATLAB start from 1, which causes confusion when switching! Did this finally make sense? Or do you still prefer counting from 1? 😄 #Python #ZeroIndexing #ProgrammingLogic #PythonBasics #LearnToCode #TechExplained #CodingFundamentals
Bhavya L Hegde’s Post
More Relevant Posts
-
🐍 Python Tip for Beginners: Variables Don’t Need a Type Declaration One of the coolest things about Python is how simple it makes working with variables. In many programming languages, you must declare the data type first (int, string, float, etc.). But in Python… you don’t. Python already knows. 💡 x = 10 # Python knows this is an integer name = "Ali" # Python knows this is a string price = 9.99 # Python knows this is a float Python is a dynamically typed language, which means the type is determined automatically at runtime. ✅ Less code ✅ Faster development ✅ Beginner-friendly ✅ More focus on logic, less on syntax This is one of the reasons Python is widely used in AI, automation, web development, and data science. If you're starting your coding journey, Python is a great first language. #Python #Programming #Coding #LearnToCode #Beginners #SoftwareDevelopment #AI
To view or add a comment, sign in
-
#DAY 21/ 50DaysChallenge #Python Modules 🔥 Module: A module is a file that contains Python code (functions, variables, classes) which we can reuse in another program. 👉 Python has built-in modules. Example: math random datetime ✅ Import a Module: Code import math print(math.sqrt(16)) Output 4.0 👉 sqrt() means square root. ✅ Using math module: Code import math print(math.pow(2,3)) print(math.factorial(5)) Output 8.0 120 ✅ Import specific function: Instead of importing full module. Code from math import sqrt print(sqrt(25)) Output 5.0 ✅random Module: Used to generate random numbers. Code import random print(random.randint(1,10)) Output Example: 7 (Random value each time) ✅ Create Your Own Module: #Step 1: Create file mymodule.py def greet(name): print("Hello", name) #Step 2: Use it in another file import mymodule mymodule.greet("Durga") Output Hello Durga 🎯 Task : 👉 Generate a random number between 1 and 100 ✅ Code import random num = random.randint(1,100) print("Random number:", num) Output Random number: 57 #50dayschallenge #coding #pythonbasics #ECE #BVCEC
To view or add a comment, sign in
-
🔥 Day 11/100 – Learning Python Loops 🐍 Today I explored one of the most important concepts in Python — Loops. Loops help us execute a block of code multiple times, making our programs more efficient and powerful. 🔹 For Loop with String We can iterate through each character in a string: Example: Looping through "banana" prints each letter one by one. 🔹 For Loop with range() Using range() helps generate a sequence of numbers. Example: range(6) starts from 0 and ends at 5. 🔹 Nested Loops We can also use a loop inside another loop. Example: Combining adjectives and fruits like: red apple, big banana, tasty cherry. 🔹 Keywords Used in Loops ✔ break ✔ continue ✔ else Understanding loops is very important for data analysis, automation, and problem-solving — especially as I continue learning Python for my tech career. Consistency is the key 🚀 See you tomorrow for Day 12! #Day11 #100DaysOfCode #Python #Programming #LearningJourney #BCA #FutureDataAnalyst If you want, I can also give you a shorter version or a more beginner-friendly version.
To view or add a comment, sign in
-
-
📅 Day 23 of My Python Full-Stack Journey — Logical Operators! Today I explored one of the most essential building blocks in programming — Logical Operators in Python 🐍 These three operators control the logic flow of your entire program: 🟠 and → Both conditions must be True 🟣 or → At least one condition must be True 🔵 not → Flips the boolean value pythonage = 20 has_id = True if age >= 18 and has_id: print("Access granted") # ✅ if age >= 18 or is_member: print("Welcome in!") # ✅ print(not False) # True Simple? Yes. But combine these and you can build powerful decision-making logic for login systems, access control, form validation, and more! The more I progress, the more I realize Python reads almost like plain English — and that's what makes it beautiful. 💡 📍 23 days down, 77 to go. Let's gooo! 🔥 #Python #LogicalOperators #Day23 #100DaysOfCode #FullStack #PythonForBeginners #LearningInPublic #CodingJourneyDay23 linkedinCode ·
To view or add a comment, sign in
-
-
Here’s something I used to debate with my friends 😅 Is Python just a programming language, or not ? Over time, I realized that Python’s biggest strength is its flexibility. From data science and machine learning to web development, automation, and scripting — Python makes many complex tasks easier to implement compared to some lower-level languages. For example, working with very large numbers is straightforward in Python because of its built-in support for arbitrary-precision integers, while in some languages it requires extra handling or libraries. That’s why I like to think of Python as the “potato” of programming languages it goes well with almost everything! 🥔
To view or add a comment, sign in
-
-
The "Level Up" Stop writing Python like it’s 2010. 🐍 Python is one of the most readable languages in the world, but only if you use it correctly. Writing "working code" is the first step—writing "Pythonic code" is how you stand out as a senior developer. In these flashcards, I’ve broken down 4 common transformations: Swapping: Goodbye temp variables, hello tuple unpacking. Lists: Turning 4 lines of logic into 1 clean list comprehension. Dictionary Safety: Using .get() to prevent your app from crashing on missing keys. Merging: The modern "|" operator for cleaner data handling. The Question: Which one of these was the biggest "lightbulb moment" for you when you first started? Let’s chat in the comments! 👇 #Python #CleanCode #ProgrammingTips #SoftwareDevelopment #CodingLife
To view or add a comment, sign in
-
-
Greetings everyone! 👋 Today I worked on a Python program to check whether a number is an Armstrong number. This was a great exercise to strengthen my understanding of loops, mathematical operations, and number manipulation logic in Python. 🔹 What the Program Does: The program takes a number as input from the user and checks if it is an Armstrong number. An Armstrong number is a number where the sum of its digits raised to the power of the total number of digits is equal to the number itself. 🔹 How the Logic Works: • The program first takes user input. • It calculates the number of digits using string conversion. • Using a while loop, it extracts each digit. • Each digit is raised to the power of the total number of digits. • The results are added and compared with the original number. 🔹 Example Outputs: ✔ 153 → Armstrong Number ❌ 54 → Not an Armstrong Number 🔹 What I Learned: • Practical use of loops and conditions • Mathematical logic implementation in Python • Working with numbers and digit extraction • Writing clean and simple algorithm-based programs This small project helped me improve my problem-solving skills and strengthened my programming fundamentals. Harish M #Python #Programming #LearningJourney #Coding #DataAnalytics #PythonBasics
To view or add a comment, sign in
-
-
🚀 Python Multithreading in Action 🧵⚡ Today I practiced Multithreading in Python using the threading module. 🔹 Created two thread classes 🔹 Overrode the run() method 🔹 Executed tasks simultaneously using .start() 💡 What I Learned: ✅ Threads run concurrently ✅ start() internally calls run() ✅ sleep() controls execution timing ✅ Output may interleave because threads execute in parallel 🧠 Code Concept: Class A(Thread) → prints "Hello" Class B(Thread) → prints "Pune" Both threads run 5 times with a 2-second delay Output runs simultaneously ⚡ This is the power of concurrent execution in Python. 🔥 Why Multithreading? ✔ Improves performance ✔ Best for I/O-bound tasks ✔ Used in real-world apps like: Web servers 🌐 Background processing ⚙ APIs 🔄 💬 Small practice today… 🏆 Big step towards becoming an Advanced Python Developer. #Python #Multithreading #Threading #AdvancedPython #CodingJourney #WomenInTech #MCA #LearningDaily
To view or add a comment, sign in
-
Today I learned what actually happens behind the scenes when we modify variables in Python. In Python, everything is an object. Variables don’t store values directly — they store references to objects in memory. 🔹 Immutable Data Types (int, float, bool, str, tuple, frozenset, bytes) When you try to change their value, Python creates a new object and updates the reference. Example: x = 10 x = x + 5 Here, 10 is not modified. A new object (15) is created and x now points to it. 🔹 Mutable Data Types (list, set, dictionary, bytearray, array) These objects can be modified in place. Example: lst = [1, 2, 3] lst.append(4) Here, the same list object is updated in memory. So it’s not about “variable refresh”. It’s about object identity and memory references. Understanding this changes how you think about Python functions, memory, and debugging. Grateful to Hitesh Choudhary sir for explaining this concept so clearly. #LearnInPublic #Python #BackendDevelopment #Programming
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