Day 49 : Python Functions & Arguments Today I understood the functions and arguments and its usage. Hands-on : - Today I learned about functions in Python, which help organize code into reusable blocks. I started with the basic syntax of a function, understanding how to define and call functions for specific tasks. - I then explored arguments in functions, which allow passing data into functions. - I practiced using multiple arguments to handle more than one input. - ------ Moving forward, I learned about arbitrary arguments (*args), which let functions accept a variable number of positional inputs. - I also worked with keyword arguments, where values are passed using parameter names for better clarity. - Finally, I explored **arbitrary keyword arguments (kwargs), which allow passing a variable number of named arguments into a function. - These concepts are essential for writing flexible and reusable code in real-world applications. Result : - Successfully understood how to create functions and use different types of arguments to make code more modular and dynamic. Key Takeaways : - Functions help in code reusability and modular programming. - Arguments allow passing data into functions. - Multiple arguments enable handling several inputs. - *args allows variable positional arguments. - Keyword arguments improve readability. - **kwargs allows variable named arguments. #Python #Programming #DataAnalytics #LearningJourney #Functions #CodingBasics #DataScience #BeginnerPython #AnalyticsSkills
Mastering Python Functions & Arguments
More Relevant Posts
-
🚀 Just Published My First Medium Article! I’m excited to share my first blog on Medium: 👉 Python Basics – Part 1 As a beginner, I started exploring Python and realized something important — strong fundamentals make everything easier later. In this article, I’ve covered: ✔️ Variables and data types ✔️ Basic syntax and operations I also tried to keep it simple and beginner-friendly, so anyone starting their coding journey can understand it easily. 💡 Learning is not about knowing everything at once — it’s about starting small and staying consistent. This is just the beginning of my journey into tech and self-improvement. 🔗 Read my full article here: https://lnkd.in/dfFnCFm2 I’d love to hear your feedback and suggestions! #Python #LearningJourney #Beginners #Coding #SelfImprovement #WomenInTech
To view or add a comment, sign in
-
🚀 Today I Learned: Operator Overloading in Python While exploring Object-Oriented Programming in Python, I came across an interesting concept — Operator Overloading. 👉 It allows us to define how operators like "+", "-", "*" behave for our own custom objects. 💡 Simple Idea: Instead of using operators only for numbers, we can use them for our own classes too! 🔧 Example: class Number: def __init__(self, value): self.value = value def __add__(self, other): return Number(self.value + other.value) def __str__(self): return f"{self.value}" n1 = Number(10) n2 = Number(20) print(n1 + n2) # Output: 30 🔥 Here, "+" is not just adding numbers — it’s calling "__add__()" behind the scenes! 📌 Key Takeaways: ✔ Operator overloading improves code readability ✔ Uses special methods (dunder methods like "__add__") ✔ Makes objects behave like real-world entities ✔ Important concept in OOP & interviews 💭 Learning how small features like this work internally really changes the way we write code. #Python #OOP #CodingJourney #100DaysOfCode #Programming #Learning
To view or add a comment, sign in
-
Modules are one of the most powerful features in Python that help you write clean, reusable, and organized code. * A module is simply a file that contains Python code (functions, variables, or classes) which you can reuse in other programs. * Why use modules? * Code reusability * Better organization * Easy maintenance * Faster development 🔧 Example: # math_module.py def add(a, b): return a + b # main.py import math_module result = math_module.add(5, 3) print(result) * Instead of writing the same logic again and again, modules allow you to write once and use anywhere. * Python also provides built-in modules like: * math * random * datetime #Python #Programming #DataAnalytics #Coding #Learning #PythonBasics
To view or add a comment, sign in
-
Today I continued my Python functions practice and learned the remaining two important types. Type 3 — Without Arguments & With Return Theory: Function does not take parameters Takes input inside the function Returns the result to the caller Output is printed outside the function Use case: When a function acts like a small tool that collects data and gives back a result. def sum_digits(): n = int(input("Enter number: ")) s = 0 while n > 0: s += n % 10 n //= 10 return s print(sum_digits()) Type 4 — With Arguments & With Return Theory: Function takes input as parameters Does not take input inside Returns the result This type is used in interviews, and real projects Use case: Reusable logic that can be called multiple times with different values. def sum_digits(n): s = 0 while n > 0: s += n % 10 n //= 10 return s print(sum_digits(1234)) Key Learning Same problem can be written in different function types depending on the need. Understanding function design is more important than the problem itself. I’m improving my Python fundamentals step by step #Python #Programming #Learning #CodingJourney #Functions
To view or add a comment, sign in
-
Day 26 of #100DaysOfCode👩💻🚀 Today I learned about Getter, Setter, and 3 types of methods in Python OOP. Getter & Setter methods: Getters are used to access private data safely → `get_name()` Setters are used to update private data with validation → `set_age()` They help protect data and add control over how variables are read or changed. 3 Types of Methods in Python: 1. Instance method → Uses `self`, works with object data. Called by objects. 2. Class method → Uses `@classmethod` and `cls`, works with class variables. Called by class. 3. Static method → Uses `@staticmethod`, doesn’t use `self` or `cls`. Like a normal function inside class. One more step toward writing clean, secure OOP code. Special thanks to the CEO G.R NARENDRA REDDY Sir for constant guidance and motivation. #Python #OOP #GetterSetter #100DaysOfCode #LearningJourney #Programming
To view or add a comment, sign in
-
-
🚀 Mastering Loops in Python 🐍 Loops in Python are essential for repeating tasks efficiently. They allow you to iterate over a sequence of elements such as lists or strings, executing the same block of code multiple times. This is incredibly useful for automating repetitive operations and processing large amounts of data in your programs. For developers, understanding loops is crucial as they form the backbone of many algorithms and data processing tasks. By mastering loops, you can write more concise and elegant code, improving the efficiency and readability of your applications. 🔎 Let's break it down step by step: 1️⃣ Initialize a counter variable 2️⃣ Set the condition for the loop to continue 3️⃣ Execute the code block inside the loop 4️⃣ Update the counter to progress through the sequence ```python # Example of a for loop in Python for i in range(5): print("Iteration", i) ``` 🚩 Pro Tip: Use `enumerate()` to access both the index and value of an item in a loop effortlessly. ❌ Common Mistake: Forgetting to update the counter variable in a loop, leading to an infinite loop and crashing your program. 🤔 What's your favorite use case for loops in Python? 🌐 View my full portfolio and more dev resources at tharindunipun.lk #PythonProgramming #DeveloperTips #CodingCommunity #LearnToCode #LoopInPython #CodeNewbie #TechTalks #ProgrammingLife
To view or add a comment, sign in
-
-
🚀 Day 12 of Python Coding Challenge 📌 Problem: Count Total Number of Characters in a File Understanding file handling is a fundamental skill in Python. Today’s task is to count the total number of characters in a given file. 💡 Approach: Open the file in read mode Read the file content Use len() to count characters 🧠 Python Code: def count_characters(file_path): try: with open(file_path, 'r') as file: content = file.read() return len(content) except FileNotFoundError: return "File not found." # Example usage file_path = "sample.txt" result = count_characters(file_path) print("Total characters in file:", result) ✅ Sample Output: Total characters in file: 12 🔍 Key Learnings: File handling using open() Using with statement for safe file operations Applying len() on strings 📢 Pro Tip: If you want to exclude spaces or newline characters, you can filter them before counting! 🔥 Keep Learning, Keep Growing! Follow along for more daily Python problems. #Python #CodingChallenge #Day12 #LearningJourney #30DaysOfCode
To view or add a comment, sign in
-
My Python Journey: Lists + Loops Today, I focused on building a strong foundation in Python with lists and loops. I practiced 10 essential problems, including: 🔹Printing all elements of a list 🔹Accessing elements at even indices 🔹Filtering even numbers 🔹Finding numbers greater than a threshold 🔹Calculating the sum of all elements (without sum()) 🔹Counting total elements (without len()) 🔹Counting numbers greater than 5 🔹Finding the smallest number (without min()) 🔹Printing a list in reverse (using loops) 🔹Creating a new list with squares of numbers 💡 Key takeaways: Loops are powerful for iteration and data manipulation Conditional checks inside loops make Python very flexible Practicing manually (without built-ins) strengthens problem-solving skills. Here’s a glimpse of my list of numbers I practiced on: nums = [14, 13, 27, 34, 20, 16, 23, 82, 49, 83] Feeling confident and ready for Day 2 challenges! 🔥 #Python #DataAnalytics #CodingJourney #100DaysOfCode #LearningByDoing #ProblemSolving
To view or add a comment, sign in
-
-
Day 31 of my python learning journey Today’s Python topic: Types of Inheritance in OOP🐍 Inheritance lets a child class reuse code from a parent class. No need to write the same code again. 5 Types in Python: 1. Single → One child, one parent `class Dog(Animal): pass` 2. Multiple → One child, many parents `class Child(Father, Mother): pass` 3. Multilevel → Grandparent → Parent → Child `class GrandChild(Child):` where `Child(Parent)` 4. Hierarchical → One parent, many children `Dog(Animal)`, `Cat(Animal)` 5. Hybrid→ Mix of two or more types above OOP becomes easier when you know how classes connect. Inheritance = less code, more reuse. Special thanks to the CEO G.R NARENDRA REDDY Sir for constant guidance and motivation. #Python #OOP #Inheritance #100DaysOfCode #LearningJourney #Coding
To view or add a comment, sign in
-
-
🛒 Shopping List Manager using Python I built a simple command-line application using Python to manage daily shopping items efficiently. 🔧 Features: ✔️ Add new items to the list ✔️ Modify existing items ✔️ Delete items ✔️ View complete shopping list ✔️ Count total items 💡 This project helped me strengthen my understanding of: Lists in Python Functions User input handling Looping and conditional statements 🖥️ The program runs through a menu-driven interface, making it easy for users to interact and manage their shopping list. 📌 Simple projects like this are a great way to build strong programming fundamentals. #Python #Programming #BeginnerProjects #Coding #LearningJourney #TechSkills
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