Today's Python Tip: The Key Difference Between a Function With return and Without return When learning Python functions, one concept confuses many beginners: What is the difference between a function that has a return statement and one that does not? Here is the simple explanation Function WITH a return statement A function with return sends a value back to the place where the function was called in your python file. This means the result can be stored, reused, or used in calculations. Example: Creating a function with the return statement def get_greeting(): return "Hello from a function" The function call message = get_greeting() print(message) ✔ The function gives a value back ✔ The value can be stored in a variable ✔ The value can be reused later in the program Function WITHOUT a return statement A function without return simply performs an action, but it does not send a value back. Example: Creating the function without a return statement def greet(): print("Hello from a function") greet() ✔ The function performs an action (printing) ❌ Nothing is returned to be stored or reused Simple way to remember this: • A function with return gives you a result • A function without return just does something In real programs, using return makes functions more powerful and reusable because their results can be used elsewhere in your code. #Python #Programming #CodingForBeginners #LearnToCode #PythonFunctions
Python Functions: Return vs No Return
More Relevant Posts
-
📘 Python Learning Series – Day 5 🐍 Continuing my Python learning journey, today I explored If-Else Statements in Python. 🔹 What are If-Else Statements? If-Else statements are used to execute different blocks of code based on conditions. They help programs make decisions. 🔹 Basic Syntax age = 18 if age >= 18: print("You are an adult.") else: print("You are a minor.") 🔹 Output You are an adult. 🔹 How it Works ✔ Python checks if the condition is True or False ✔ If the condition is True, the "if" block executes ✔ If the condition is False, the "else" block executes If-Else statements are very important because they allow programs to make decisions and perform different actions based on conditions. 📅 Next Post: Day 6 – Python Loops Follow along as I continue sharing daily Python learning notes 🚀 #Python #PythonLearning #CodingJourney #LearnPython #Programming #Developers
To view or add a comment, sign in
-
-
📘 Python Learning Series – Day 7 🐍 Continuing my Python learning journey, today I explored Functions in Python. 🔹 What are Functions? Functions are reusable blocks of code that perform a specific task. They help in writing clean, organized, and efficient programs. 🔹 Why use Functions? ✔ Avoid code repetition ✔ Improve code readability ✔ Make code reusable ✔ Help in better organization 🔹 Basic Syntax def greet(name): return "Hello, " + name 🔹 Example Usage print(greet("Aastha")) 🔹 Output Hello, Aastha 📌 Key Points ✔ Functions make code modular ✔ They can take inputs (parameters) ✔ They can return outputs (results) Functions are very important for building real-world applications and scalable projects 🚀 📅 Next Post: Day 8 – Python Modules Follow along for more daily Python learning notes 💻✨ #Python #PythonLearning #CodingJourney #LearnPython #Programming #Developers
To view or add a comment, sign in
-
-
📘 Python Learning Series – Day 10 🐍 (Final Day) Today marks the final day of my Python learning series! 🚀 In this last post, I explored Exception Handling in Python. 🔹 What is Exception Handling? Exception handling is used to handle errors in a program gracefully without stopping the execution. 🔹 Why is it important? ✔ Prevents program crashes ✔ Handles runtime errors smoothly ✔ Improves user experience ✔ Makes code more reliable 🔹 Basic Syntax try: result = 10 / 0 except ZeroDivisionError: print("Cannot divide by zero!") finally: print("Execution completed.") 🔹 Output Cannot divide by zero! Execution completed. 📌 Key Points ✔ "try" → Code that may cause error ✔ "except" → Handles the error ✔ "else" → Runs if no error occurs ✔ "finally" → Always executes --- 🎉 Series Completed! From basics to important concepts, this journey helped me: ✅ Build strong fundamentals ✅ Stay consistent ✅ Improve coding confidence Grateful for everyone who followed along 🙌 This is just the beginning — more projects & learning coming soon! 💻✨ #Python #PythonLearning #CodingJourney #LearnPython #Developers #100DaysOfCode
To view or add a comment, sign in
-
-
Good Python notes for beginners While going through Python resources, I found this: “Complete Python for Beginners” by Rishabh Mishra It’s simple, well-structured, and covers most of the basics. This can be helpful if you: • Are just starting with Python. • Want quick revision notes. • Prefer structured learning. But one thing I’ve learned: - Reading notes alone is not enough. - You need to practice and build small projects to actually understand Python. Still, this is a good starting point, so sharing it here. (Full credit to the original creator ) 💬 How are you learning Python — notes, videos, or projects? 📌 I share simple Python and backend learnings here. #Python #LearnPython #Programming #Coding #Developers #TechLearning #PythonDeveloper #SoftwareEngineer
To view or add a comment, sign in
-
You don’t need 100 tutorials to learn Python. You just need the right notes. 📘⚡ Most beginners waste time jumping from video to video… And still feel confused. That’s where simple handwritten notes make the difference. Clear. Structured. Easy to revise. Inside these notes: • Python Basics & Syntax • Data Types & Variables • Loops & Conditionals • Functions & Modules • OOP Concepts No overwhelm. No confusion. Just clarity. Perfect for students, beginners & anyone serious about learning Python faster. 🚀 Save this post — you’ll need it later. 💬 What are you currently learning: Python or something else? #Python #PythonNotes #LearnPython #Coding #Programming #Developers #TechLearning
To view or add a comment, sign in
-
🚀 Python Basics to Advanced Learning Series – Day 12 Today’s session was focused on the Set data structure in Python. It helped me understand how to store and manage unique values efficiently. What I learned today: • What is a Set and how it works in Python • How to create a set using {} and set() function • How to create an empty set using set() (since {} creates a dictionary) • Understanding that sets store unique and unordered elements • Learning important built-in methods of sets: add() → to add a single element update() → to add multiple elements copy() → to create a duplicate set pop() → to remove a random element remove() → to remove a specific element (error if not found) discard() → to remove element without error • Understanding the difference between pop(), remove(), and discard() • Practiced examples to clearly understand how sets behave This session helped me understand how sets are useful when working with unique data and how different methods behave in real scenarios. I’m learning step by step as part of my Python Basics to Advanced Learning Journey at Global Quest Technologies, and I’m improving my concepts day by day. Excited to continue learning and building strong fundamentals 🚀 #Python #PythonProgramming #LearningJourney #Coding #DataStructures #Sets #ProblemSolving #SoftwareDevelopment #TechLearning #Developers #GlobalQuestTechnologies
To view or add a comment, sign in
-
-
Python Mini Project – Number Guessing Game Today I built a simple Number Guessing Game using Python 🐍 The program randomly selects a number between 1 to 10, and the user keeps guessing until they get it right. 🔹 Features: ✔️ Random number generation using random ✔️ Unlimited attempts until correct guess ✔️ Tracks incorrect attempts ✔️ Displays the correct number at the end 📚 Concepts Practiced: ✔️ Functions ✔️ while loop (infinite loop control) ✔️ Conditional statements ✔️ Random module ✔️ Basic game logic This was fun to build and helped me understand how logic is used in real interactive programs. Small projects like this make learning more exciting 🚀 👉 Question for you: How would you improve this game? (Hints, limited attempts, difficulty levels?) Let’s connect if you're also learning Python 🤝
To view or add a comment, sign in
-
-
Learning Python doesn’t have to be confusing — it just needs the right approach. Most beginners don’t quit because Python is hard. They quit because their learning is scattered. One YouTube video after another… Different tutorials… Saved links everywhere… but nothing completed. The real problem? Lack of structure. That’s where well-organized notes make a huge difference. I recently came across a 90-page beginner-friendly Python guide that covers everything step by step: • Python basics • Variables & data types • If-else and loops • Functions • Lists, tuples, sets, and dictionaries • Modules & popular libraries Everything is explained in a simple and clear way — perfect for beginners. Sometimes, you don’t need more resources. You just need one good resource and the discipline to follow it. Follow Rahul kumar for more tech content 🚀 #Python #Coding #Programming #CSE #TechLearning #Networking
To view or add a comment, sign in
-
🚀 Python Basics to Advanced Learning Series – Day 6 Today’s learning was all about working with strings in Python. It was a very interesting session because I got to understand how we can access, modify, and format text in different ways. What I learned today: • Understanding string indexing to access characters using positions • Learning slicing operation to extract parts of a string using "[start:end:step]" • Practicing different slicing variations, including reverse and step slicing • Solving problems based on string comparison and manipulation • Learning useful string methods like "strip()", "split()", "join()", "replace()", "upper()", "lower()", "title()" • Understanding how to clean and modify strings effectively • Learning string formatting techniques using "f-strings" and "format()" • Writing programs like reversing a string and checking equality of two strings This session helped me understand how important strings are in real-world programming. Practicing problems made the concepts much clearer and improved my confidence. I’m learning all these concepts as part of my Python Basics to Advanced Learning Series at Global Quest Technologies, and I can clearly see my improvement day by day. Excited to continue this journey and learn more 🚀 #Python #PythonProgramming #LearningJourney #Coding #Strings #ProblemSolving #SoftwareDevelopment #TechLearning #Developers #globalquesttechnologies #GQT
To view or add a comment, sign in
-
-
📘 Python Learning Series – Day 6 🐍 Continuing my Python learning journey, today I explored Loops in Python. 🔹 What are Loops? Loops are used to repeat a block of code multiple times, helping us automate repetitive tasks and write efficient programs. 🔹 Types of Loops in Python 1️⃣ for loop Used to iterate over a sequence like list, string, or range. 2️⃣ while loop Runs as long as a given condition is True. 🔹 Example Code for i in range(5): print("Iteration:", i) 🔹 Output Iteration: 0 Iteration: 1 Iteration: 2 Iteration: 3 Iteration: 4 📌 Key Points ✔ Reduces code repetition ✔ Helps in automation ✔ "for loop" → when iterations are known ✔ "while loop" → condition-based execution Loops are essential for writing clean, efficient, and scalable programs 🚀 📅 Next Post: Day 7 – Python Functions Follow along for more daily Python learning notes 💻✨ #Python #PythonLearning #CodingJourney #LearnPython #Programming #Developers
To view or add a comment, sign in
-
More from this author
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