+ 3
Write a python program to sum the sequence .......... 1^2 + 3^2 + 5^2 +....+ n^2
no description from my side
4 Réponses
+ 6
One-liner program:
https://code.sololearn.com/c6rE0V77zwiQ/?ref=app
+ 1
Show us your attempt by providing what you have coded so far and we will help you.
+ 1
def qsum(n):
sum = 0
for i in range(1,n+1,2):
sum += i**2
return sum
+ 1
n = int(input("Enter value for n: "))
sum = 0
for i in range(1, n+1, 2):
sum += i*i
print("The sum is: ", sum)