Computer Science
Write Python programs to sum the given sequences:
12 + 32 + 52 + ….. + n2 (Input n)
Python
Python Control Flow
17 Likes
Answer
n = int(input("Enter the value of n: "))
i = 1
sum = 0
while i <= n :
sum += i ** 2
i += 2
print("Sum =", sum)
Output
Enter the value of n: 9
Sum = 165
Answered By
7 Likes
Related Questions
Write Python programs to sum the given sequences:
2/9 - 5/13 + 8/17 …… (print 7 terms)
Write a program to accept the age of n employees and count the number of persons in the following age group:
(i) 26 - 35
(ii) 36 - 45
(iii) 46 - 55Write a Python program to sum the sequence:
1 + 1/1! + 1/2! + 1/3! + ….. + 1/n! (Input n)
Write a Python program to print every integer between 1 and n divisible by m. Also report whether the number that is divisible by m is even or odd.