👉 Question for you: Can you solve this without using loops? Python Program – Sum of Odd & Even Numbers (1 to n) Today I practiced writing a Python program using functions to calculate the sum of: ✔️ All odd numbers from 1 to n ✔️ All even numbers from 1 to n 🔹 What I implemented: Created a function to calculate odd number sum Used loop + condition (i % 2) Took user input dynamically Printed results using formatted output 📚 Concepts Practiced: ✔️ Functions in Python ✔️ Looping with range() ✔️ Conditional logic ✔️ Clean and reusable code This helped me understand how to break problems into smaller reusable functions, which is very important in real-world programming. Small improvements every day → Strong coding foundation 🚀 Let’s connect if you're also learning Python 🤝 #Python #PythonProgramming #CodingPractice #LearnToCode #Functions #DeveloperJourney #100DaysOfCode #ComputerScience #LogicBuilding
Bro code glt hai
If you want, you could use sum() and filter(), it's still an iterator, but you're not using a manual loop.
You could do it recursively
Yes i can, number = int(input("Enter number : ")) print(["Even","Odd"][number % 2])
yes we can do it using filter and sum..
Too Easy !
Bro i think u forgot to declare sum_even(n) function