+ 3

Write a python program to sum the sequence .......... 1^2 + 3^2 + 5^2 +....+ n^2

no description from my side

22nd Aug 2018, 4:59 PM
Himanshu
Himanshu - avatar
4 Réponses
22nd Aug 2018, 6:24 PM
Eduardo Petry
Eduardo Petry - avatar
+ 1
Show us your attempt by providing what you have coded so far and we will help you.
22nd Aug 2018, 5:20 PM
Steppenwolf
Steppenwolf - avatar
+ 1
def qsum(n): sum = 0 for i in range(1,n+1,2): sum += i**2 return sum
22nd Aug 2018, 5:34 PM
Chris
Chris - avatar
+ 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)
22nd Aug 2018, 5:55 PM
Alex