🐍 Day 11 of My 30-Day Python Learning Challenge Today I learned an important Python concept often asked in interviews. 📌 What will be the output? def func(value, lst=[]): lst.append(value) return lst print(func(1)) print(func(2)) print(func(3)) 🤔 Think before you answer! 📊 Options: A) [1] [2] [3] B) [1] [1,2] [1,2,3] C) Error D) None of these 💡 This question tests understanding of mutable default arguments — a common mistake many beginners make. Answer tomorrow 👇 #Python #CodingInterview #ProblemSolving #LearningInPublic #SoftwareDeveloper
Python Interview Question: Mutable Default Arguments
More Relevant Posts
-
Built Linear Regression from scratch using Python (no libraries) Wanted to understand what’s happening under the hood before moving to sklearn. So I implemented a simple model to predict marks based on hours studied using Gradient Descent. 🔹 What I did: Implemented the prediction function (y = wx + b) Calculated Mean Squared Error (MSE) manually Computed gradients and updated parameters over 1000 epochs 🔹 What I learned: How gradient descent updates weights step by step Why learning rate plays a critical role How loss decreases as the model learns 🔹 Result: The model successfully learned the relationship. Example: If a student studies 9 hours → predicted marks ≈ 89.3 🔗 Code: https://lnkd.in/gPHCenhB Next step: implementing this using NumPy and then sklearn. #MachineLearning #Python #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Python Learning Update Today, I revised concepts related to File Handling and List Comprehension in Python. Here’s what I focused on: ✅ File handling operations (open(), read(), write(), append()) ✅ Working with different file modes (r, w, a) ✅ Using with open() for better file management ✅ Writing concise and efficient code using list comprehension ✅ Applying conditions inside list comprehension This revision helped me improve both data handling and code optimization skills. Step by step, building stronger problem-solving ability 💪 #Python #LearningJourney #FileHandling #ListComprehension #Coding #KeepLearning
To view or add a comment, sign in
-
🐍 Python Interview Question 📌 What are iterators in Python? In Python, an iterator is an object that allows sequential access to elements one at a time without storing all values in memory at once. 🔹 Key Points: ✔ Implements Iterator Protocol • Uses __iter__() and __next__() methods ✔ Returns One Item at a Time • Useful for looping through collections efficiently ✔ Memory Efficient • Processes data lazily instead of loading everything at once ✔ Works with Generators • Generator functions automatically create iterators using yield 🔹 Extra Insight: • Iterators raise StopIteration when no elements remain 💡 In Short: Iterators make Python efficient for handling large datasets and sequential processing. 👉For Python Course Details Visit : https://lnkd.in/gf23u2Rh . #Python #Programming #PythonInterview #Iterators #Generators #Coding #TechSkills #ashokit
To view or add a comment, sign in
-
-
📅 Day 1 – Learning Python Strings 🐍 Today I started learning about strings in Python. 🧠 What is a String? A string is a sequence of characters used to store text data (e.g., "welcome"). 📚 What I learned: • Strings are immutable (cannot be changed after creation) • We can access characters using indexing • We can reverse a string using slicing 💻 I also tried a small program to reverse a string (added in image 👇) 🚀 Learning step by step. #Python #LearningJourney #100DaysOfCode #BeginnerDeveloper
To view or add a comment, sign in
-
-
🐍 Python Interview Question 📌 What are Generators in Python? In Python, generators are a simple way to create iterators efficiently. 🔹 What is a Generator? ✔ A generator is a function that uses the yield keyword ✔ It returns values one at a time instead of all at once 🔹 How it Works ✔ Execution pauses at each yield ✔ Function state is saved automatically ✔ Resumes from the same point when called again 🔹 Why Use Generators? ✔ Memory efficient for large datasets ✔ Faster than storing complete lists ✔ Useful for streaming data 🔹 Example • def nums(): yield 1; yield 2; yield 3 💡 In Short: Generators produce values lazily, making iteration efficient and memory-friendly 🚀🐍 👉For Python Course Details Visit : https://lnkd.in/gf23u2Rh . #Python #Generators #PythonInterview #Programming #Coding #InterviewPreparation #TechSkills
To view or add a comment, sign in
-
-
🐍 Python Interview Question 📌 What is the difference between range() and xrange()? 🔹 range() ✔ In Python 3, range() returns a lazy sequence object ✔ Generates numbers only when needed ✔ Memory efficient for large loops 🔹 xrange() ✔ Available only in Python 2 ✔ Returns an iterator-like object instead of a full list ✔ Designed for better memory efficiency in Python 2 🔹 Important Note: ✔ In Python 3, xrange() was removed ✔ range() now behaves like Python 2 xrange() 💡 In Short: Use range() in Python 3 — it already provides the memory-efficient behavior of old xrange() ⚡ 👉For Python Course Details Visit : https://lnkd.in/gf23u2Rh . #Python #PythonProgramming #Range #Xrange #CodingInterview #InterviewPreparation #TechLearning #AshokIT
To view or add a comment, sign in
-
-
Learn how to set matrix zeros in Python with ease. Discover the simple yet effective techniques for achieving zero matrices, essential for many data analysis and machine learning tasks. Python Matrix Zeroing for Data Analysis and Machine Learning Read the full article 👉 https://lnkd.in/dezNECw7 #Python #MatrixZeroing #ITfresher #DataAnalysis #MachineLearning #TechLab Code. Learn. Build. — TechLab by Neeraj
To view or add a comment, sign in
-
👉 We all use quotes in Python… But do you know when to use: ' vs " vs '''? Most beginners just use them randomly. Here’s the simple rule 👇 # Single quotes → simple text name = 'Ali' # Double quotes → when text has ' msg = "It's a good day" # Triple quotes → multi-line / docstrings text = '''This is multi-line text''' That’s it. No confusion. No overthinking. --- 💡 Good code is not just about working… It’s about being clear and readable. --- Do you follow this… or just use quotes randomly? #Python #LearnPython #CodingBasics #ProgrammingConcepts #PythonTips #CodeClarity #CleanCode #LearnWithMe #strings
To view or add a comment, sign in
-
-
🐍 Python Interview Question 📌 What is Variable Scope in Python? Variable scope defines where a variable can be accessed and how long it exists in a Python program. 🔹 Local Scope Variables created inside a function and accessible only within that function. 🔹 Global Scope Variables declared outside functions and accessible throughout the program. 🔹 Module-Level Scope Variables available across the current module or file. 🔹 Built-in / Outermost Scope Predefined names provided by Python, such as len(), print(), and range(). 💡 In Short: Python follows the LEGB rule — Local, Enclosing, Global, Built-in — to resolve variable names efficiently ⚡ 👉For Python Course Details Visit : https://lnkd.in/gf23u2Rh . #Python #PythonProgramming #VariableScope #LEGB #CodingInterview #InterviewPreparation #TechLearning #AshokIT
To view or add a comment, sign in
-
-
🐍 Python Interview Question 📌 What is a docstring in Python? In Python, a docstring is a documentation string used to describe modules, classes, functions, or methods. 🔹 Key Points: ✔ Written Using Triple Quotes • Declared with ''' ''' or """ """ ✔ Placed Immediately Below Definition • Added just below a function, class, or module declaration ✔ Used for Documentation • Explains purpose, parameters, and return values ✔ Accessible at Runtime • Retrieved using __doc__ or help() 🔹 Extra Insight: • Good docstrings improve code readability and support automatic documentation tools 💡 In Short: A docstring makes Python code easier to understand, maintain, and document professionally. 👉For Python Course Details Visit : https://lnkd.in/gf23u2Rh . #Python #Programming #PythonInterview #Docstring #Coding #TechSkills #SoftwareDevelopment #ashokit
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