+ 1

Is simple summation notation possible?

For example from ramge 5 to 20, n ^2=2840

15th Sep 2017, 8:45 PM
William Kindbom
William Kindbom - avatar
2 odpowiedzi
+ 9
print(sum(x**2 for x in range(5, 21)))
15th Sep 2017, 8:48 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
Basicakly what kuba did. Took numbers from 5 to 20 amd created a range object (sorta a list) Performed an operation to each **2 returned their sum
16th Sep 2017, 12:49 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar