Decision Making (if-else) Today I learned how Python makes decisions using conditions. This is one of the most important concepts in programming. 🔹 What is Decision Making? It allows a program to take actions based on conditions. 🔸 if Statement Used to execute code only if a condition is true. Example: age = 18 if age >= 18: print("You can vote") 🔸 if-else Statement Executes one block if condition is true, otherwise another block. Example: age = 16 if age >= 18: print("Eligible") else: print("Not eligible") 🔸 if-elif-else Statement Used when we have multiple conditions. Example: marks = 75 if marks >= 90: print("Grade A") elif marks >= 60: print("Grade B") else: print("Grade C") 💡 Key Learning: Indentation is very important in Python. It defines the structure of code. 🧪 Practice Task: Create a program that checks whether a number is even or odd. 🎯 Interview Question: What is the difference between if and elif? Answer: "if" checks a condition independently, while "elif" is used to check multiple conditions in sequence. #Python #Learning #CodingJourney #Day4 #Programming #SDET Masai #dailylearning #masaiverse
Rohit Verma’s Post
More Relevant Posts
-
I used to write code to solve problems… now I’m learning how to structure it. Today’s Python MahaRevision 🧩 Chapter 10: Object-Oriented Programming This chapter introduced concepts that actually make code feel organized: → Classes & Objects → Class attributes vs Instance attributes → Understanding “self” (this one took a moment to click) → init() constructor → @staticmethod At first, all these terms felt a bit overwhelming. But while doing the practice set, things started making more sense. Practice set done: Created classes, worked with objects, used constructors, and experimented with different types of methods. Biggest takeaway: Good code isn’t just about making it work… it’s about making it structured and reusable. Still learning, but definitely seeing growth. #Python #LearningInPublic #CodingJourney #Programming #OOP
To view or add a comment, sign in
-
🚀 Python Learning Series – Day 3 Aaj maine Loops (for & while) ke baare me seekha 👇 Programming me loops ka use ek hi kaam ko baar-baar repeat karne ke liye hota hai, bina code ko multiple baar likhe. 🔹 for loop Jab hume kisi sequence (list, range, string) par iterate karna ho tab use hota hai 🔹 while loop Jab tak condition true rahe, tab tak code repeat hota rehta hai 💡 Simple Example (for loop): for i in range(1, 6): print(i) 👉 Output: 1 se 5 tak numbers print honge 💡 Simple Example (while loop): i = 1 while i <= 5: print(i) i += 1 👉 Yeh bhi 1 se 5 tak numbers print karega 📌 Real Life Example: Jaise daily routine — jab tak kaam complete na ho, tab tak karte rehna 🔄 ✨ Aaj ka learning: Loops help in reducing code repetition and make programs efficient. #Python #Learning #CodingJourney #Loops #ForLoop #WhileLoop #Beginners
To view or add a comment, sign in
-
📘 Python Learning – Day 4 Highlights 🐍 Today’s class was about Lists & Basic List Operations — super useful for handling multiple data! 🔹 What is a List? An ordered, changeable collection that allows duplicates 🔹 Accessing Data: Indexing & slicing (list[0], list[1:4]) 🔹 List Operations: ✔ Add → append(), insert() ✔ Remove → remove(), pop(), clear() 🔹 Built-in Functions: len(), sum(), max(), min(), sort(), reverse() 🔹 Practice Program: Created a simple menu-driven program to add, remove, and display list items 💡 Lists make data handling easier and more dynamic in Python Step by step, getting more comfortable with coding 🚀 #Python #Programming #Coding #LearningJourney #Beginner #TechSkills
To view or add a comment, sign in
-
-
Day 35 of python learning journey Today’s Python topic: Types of Patterns 👩💻🔥 Practiced how to build logic using patterns. As shown in the image, I covered 4 main types: 1. Star Patterns → Using `*` to create shapes like triangles and pyramids. Helps understand loops and spacing. 2. Number Patterns→ Arranging numbers in increasing or decreasing order. Builds strong logical thinking. 3. ABC Patterns → Printing alphabets A, B, C in order. Great for understanding sequences. 4. Pyramid Patterns → Centered shapes using spaces + symbols. Best way to learn alignment and indentation. Why patterns matter: They improve programming skills, help with loops, build logic, and are super useful in coding interviews. Bottom line from today: *Patterns = Practice + Logic + Creativity* Special thanks to the CEO G.R NARENDRA REDDY Sir for constant guidance and motivation. #Python #PatternProgramming #Loops
To view or add a comment, sign in
-
-
Day 15 of my Python learning journey: Today I tried a problem with a very interesting name. Problem: Container With Most Water The name itself made me curious. You are given an array where each element represents the height of a vertical line. You have to find two lines such that they form a container that can hold the maximum amount of water. Example: arr = [1,8,6,2,5,4,8,3,7] Output: 49 What I understood: The amount of water depends on: width (distance between two lines) height (minimum of the two lines) Water = width × min(height) Better approach (Two Pointer): Start one pointer from the left Start one pointer from the right Then: • Calculate area • Move the pointer with smaller height Code I wrote: arr = [1,8,6,2,5,4,8,3,7] left = 0 right = len(arr) - 1 max_area = 0 while left < right: width = right - left height = min(arr[left], arr[right]) area = width * height if area > max_area: max_area = area if arr[left] < arr[right]: left += 1 else: right -= 1 print(max_area) Problems I faced while coding this: At first I tried checking all pairs, which was too slow. I did not understand why we move the pointer with smaller height. It felt wrong to ignore some pairs, but the logic still worked. What I finally understood: Moving the smaller height pointer helps us try to find a better height while reducing width. This avoids unnecessary comparisons and makes the solution efficient. Time and Space Complexity: Time Complexity: O(n) Space Complexity: O(1) Question: Why do we always move the pointer with the smaller height? Today’s realization: Sometimes the best solution is not checking everything, but skipping the right things. #Python #DSA #Coding #Programming #LearningInPublic #100DaysOfCode #PythonProgramming
To view or add a comment, sign in
-
-
I used to be scared of coding. Then I learned 1 concept that changed everything. Python Variables. Here's what blew my mind 🤯 Your computer has RAM — billions of tiny memory boxes. A variable is just a labeled box you control. Python That's it. That's the magic. But here's what nobody tells beginners: → 🔢 int stores whole numbers age = 20 → 💧 float stores decimals price = 9.99 → 📝 str stores text name = "Alex" → ✅ bool stores True/False is_winner = True Python figures out the type automatically. No need to declare it. Just assign and go. The workflow is simple: 1️⃣ Declare → score = 0 2️⃣ Use → print(score) 3️⃣ Update → score = 100 4️⃣ Combine → msg = "You scored: " + str(score) 5️⃣ Done → Python cleans memory for you 🎉 Why does this matter? Because instead of writing 0.18 50 times in your code — you write tax_rate = 0.18 once. Change it in one place → updates everywhere. That's reusability. That's real programming thinking. Day 1 of Python felt overwhelming. But once variables clicked? Everything else started making sense. If you're learning Python right now — you're doing the right thing. Drop a 🐍 in the comments if you're on this journey too. ♻️ Repost to help someone start their coding journey today. #Python #CodingJourney #LearnToCode #100DaysOfCode #PythonBeginner #Programming #Tech #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 9 of learning Python Today was all about diving deep into the "What if?" of programming. I spent the day exploring how to make my code more resilient and user-friendly by mastering Bugs and Exceptions in Python. 🐍💻 Here’s a breakdown of the key takeaways from my learning documentary today: 1. The Anatomy of a Mistake: Bugs vs. Exceptions Not all errors are created equal. I learned to distinguish between the two major categories: Bugs: These are the logic flaws. The program might run to the end, but it gives the wrong answer—like a calculator saying 2+2=5. Exceptions: These are the "show-stoppers." They happen during execution and will crash the program immediately if they aren't handled. 2. Identifying the Culprits I spent time matching specific error types to their causes. Recognizing these early is a superpower for any developer: SyntaxError: You missed a colon or a bracket. IndexError: You tried to access the 10th item in a list that only has 5. ValueError: You tried to turn the word "Apple" into an integer. NameError: You called a variable that hasn't been defined yet. 3. The Power of try/except The most exciting part of today was learning how to predict the unpredictable. Instead of letting a program crash when an error occurs, I can use a try/except block. The try block tests a piece of code. The except block provides a "safety net" to catch the error and keep the program running smoothly. 🛡️ The big lesson? A good developer doesn't just write code that works; they write code that knows what to do when things go wrong. Onwards to the next challenge! 📈 #Python #CodingJourney #SoftwareDevelopment #LearningToCode #TechSkills #ErrorHandling #PythonProgramming #Sololearn
To view or add a comment, sign in
-
-
🚀 Today’s Learning: Python Conditional Statements (if, elif, nested if) 🧠🐍 Today in class, I learned how decision-making works in Python using if, elif, and nested if statements. 🔹 Key Takeaways: ✔️ if-else → Used when there are two possible outcomes (True / False) ✔️ if-elif-else → Used when checking multiple conditions (order matters ⚠️) ✔️ nested if → Used for multi-level decision making (filter → then decide) ✔️ Writing clean and optimized code is as important as writing working code 💡 One important lesson: 👉 “Code running ≠ Code correct” 👉 Logic and optimization make a real difference in programming 🔧 Also learned about common mistakes like: ❌ Wrong condition order ❌ Indentation errors ❌ Repeating unnecessary code 📌 Practiced real examples like: Marks grading system Discount calculation Finding largest number Even/Odd check with proper logic This session helped me understand how to think logically while coding, not just write code. #Python #LearningJourney #DataScience #Programming #CodingBasics #IfElse #LogicBuilding #StudentLife
To view or add a comment, sign in
-
-
🚀 Python Learning Series – Day 4 Aaj maine Functions in Python ke baare me seekha 👇 Functions ka use code ko reusable aur organized banane ke liye hota hai. Ek baar function likho, aur use multiple baar use karo. 🔹 Function kya hota hai? Ek block of code jo specific task perform karta hai 🔹 Kaise banate hain? "def" keyword ka use karke function define kiya jata hai 🔹 Parameters & Return Value - Parameters: input jo function ko diya jata hai - Return: output jo function wapas deta hai 💡 Simple Example: def add(a, b): return a + b result = add(5, 3) print(result) 👉 Output: 8 📌 Real Life Example: Jaise ek machine jo input leti hai aur output deti hai ⚙️ ✨ Aaj ka learning: Functions help in writing clean, reusable, and efficient code. #Python #Learning #CodingJourney #Functions #Programming #Beginners
To view or add a comment, sign in
-
🐍 Day 7 of Learning Python — and things are getting real! Today's session was all about making Python programs robust and practical. Here's what I covered: 🔴 Python Errors & Exception Handling → Understood common errors: ZeroDivisionError, ValueError, NameError, IndexError, FileNotFoundError → Learned try / except / else / finally to handle errors gracefully instead of crashing → Used Exception as e to catch and print meaningful error messages 📐 Math Module → sqrt(), pow(), ceil(), floor(), and math.pi — Python makes math clean and simple 🎲 Random Module → randint(), randrange(), choice(), choices(), and shuffle() — great for building games and simulations 📅 DateTime Module → Getting today's date, formatting with strftime(), and doing date arithmetic with timedelta 🗂️ OS Module → Navigating the file system with listdir(), getcwd(), mkdir(), and rmdir() — right from Python! The biggest mindset shift today? Errors aren't failures — they're information. Wrapping code in try/except means your program can fail gracefully and keep going. 💡 7 days in and I'm genuinely enjoying every session. The journey continues! 🚀 #Python #100DaysOfCode #LearningInPublic #PythonProgramming #CodingJourney #Day7 #LearnPython #PythonDeveloper #CodeNewbie #TechLearning #Programming #SoftwareDevelopment #Coding #DataScience #MachineLearning #AI #TechCommunity #Developer #OpenToWork #Upskilling #Growth #StudentLife #PythonBeginners #CodeEveryDay #ProgrammingLife #Tech #Innovation #LinkedInLearning #CareerGrowth #FutureOfTech
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