- 3

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
3 Antworten
+ 4
wherearetheavocados , before you are asking for help, you should do a try by yourself. As it looks like a homework, it makes no sense to present a ready code here. this does not help to develop coding skills of the asker. It will be more helpful to give some hints, how to do a task. Also do not duplicate a post.
12th Oct 2020, 3:40 PM
Lothar
Lothar - avatar
+ 3
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:48 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 2
Erialdo Meta 🇦🇱 When I wrote the code inside a comment and tried as much as possible to keep the indentation, but when copying the comment and pasting it into the IDE, all you have to do is configure the indentation.
13th Oct 2020, 4:16 PM
Muhammad Galhoum
Muhammad Galhoum - avatar