- 5

Write a python program to print the sum of all odd numbers from 1 to 100.

12th Oct 2020, 2:39 PM
wherearetheavocados
wherearetheavocados - avatar
7 Answers
+ 5
P.M. I am sorry but Muhammad 's code is just gross. No regard for memory , time efficency or clarity for that matter.
12th Oct 2020, 4:23 PM
Erialdo Meta đŸ‡ŠđŸ‡±
Erialdo Meta đŸ‡ŠđŸ‡± - avatar
+ 4
I do that because he is beginner i can do it using one loop but i do this to facilate the code for him codemonkey
12th Oct 2020, 2:56 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 2
a=[] for i in range(1,101): if i % 2 == 1: a.append(i) sum=0 for j in a: sum+=j print("the sum of all odd numbers equal ", sum)
12th Oct 2020, 2:46 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 2
codemonkey clarity is more important than efficiency
12th Oct 2020, 3:21 PM
Bot
Bot - avatar
+ 1
If you know the basics of python you can implement that very easily ,why do you want others to code for you wherearetheavocados ? Is that going to help you in some assignment? If yes sololearn isn't a place for that ,show your attempt from next time and describe what you really Don't understand instead of ordering others to do it for you
12th Oct 2020, 3:08 PM
Abhay
Abhay - avatar
+ 1
P.M. I disagree. Not giving advice is a lot better than giving wrong advice, because you have to unlearn something understood wrong and learn the correct way. That means double the effort. And unlearning is harder than learning new things.
12th Oct 2020, 5:21 PM
Erialdo Meta đŸ‡ŠđŸ‡±
Erialdo Meta đŸ‡ŠđŸ‡± - avatar
0
Erialdo Meta đŸ‡ŠđŸ‡± well it can be optimised but its good enough for anyone to understand it at a glance he just wrote the cleanest solution a beginner can understand , be it efficient or not it can be gross for you, but it can be a diamond and help someone else, as the saying goes, "someone's trash may be another one's treasure"
12th Oct 2020, 4:34 PM
Bot
Bot - avatar