sum([i ** 2 for i in range(initial, initial + terms)])
or
sum(map(lambda x: x ** 2, range(initial, initial + terms)))
both will work as the same way.
More Related Contents:
- Builtin function not working with Spyder
- How to use variables from a function in a different function
- How to use a return statement in a for loop?
- How to run Spyder in virtual environment?
- What are good uses for Python3’s “Function Annotations”?
- What is the naming convention in Python for variable and function?
- How can I use `return` to get back multiple values from a for loop? Can I put them in a list?
- Function chaining in Python
- ImportError: No module named ‘google’
- How to make function decorators and chain them together in Python?
- Is it possible to not return anything from a function in python?
- How to Open a file through python
- How to check if a variable is a function in Python?
- Python decorator? – can someone please explain this? [duplicate]
- Python Turtle.Terminator even after using exitonclick()
- How to apply a function to each sublist of a list in python?
- Python how to get the calling function (not just its name)?
- Code to clear console and variables in Spyder
- Correct Use Of Global Variables In Python 3
- List and maximum numbers
- How to get a function name as a string?
- Python 3 ImportError: No module named ‘ConfigParser’
- How do you input integers using input in Python
- Reloading module giving NameError: name ‘reload’ is not defined
- List comprehension and lambdas in Python [duplicate]
- How to upload a file to Google Cloud Storage on Python 3?
- Understanding the main method of python [duplicate]
- Is having a concurrent.futures.ThreadPoolExecutor call dangerous in a FastAPI endpoint?
- How can I use f-string with a variable, not with a string literal?
- Switch between python 2.7 and python 3.5 on Mac OS X