How do i square, add and then square root all the items in a list? (python)Watch
number ** 2 -- this squares a number
sum(iterable) -- this sums the items in an iterable
number ** 0.5 -- this square roots a number
I have however, how would i apply that to a tuple I.e. If i had (1,3,5) how would I square, add and square root all those numbers in one step?
>>> sum(n ** 2 for n in (1, 3, 5)) ** 0.5 5.916079783099616
Thank you for the help but i meant as in inputted via a positional argument i.e
What is stopping your from doing it with a function? The code is still the same.
What does the function call look like? Are you calling the function like this numbers(1, 3, 5)?