write a python program to add the odd numbers up to a given number n and print the result
Answers
Answered by
0
Answer:
Algorithm to print even and odd numbers from 1 to N
Use the python input() function that allows the user to enter the maximum limit value.
Next, Run for a loop and Add the current value of n to num variable.
Next, Python is going to print even and odd numbers from 1 to the user entered a maximum limit value.
Answered by
2
Answer:
upto = int(input("Enter a number:"))
tot = 0
for i in range(upto):
if(i%2 == 1):
tot = tot + i
print("The sum of odd numbers upto" , upto , "is" , tot)
Explanation:
Similar questions