Answer to Question #291954 in Python for Karan

Question #291954

you cannot use built-in functions or NumPy or Pandas!

1. Write a function which finds all Pythagorean triplets of triangles whose sides are no greater than a natural number N.

2. Given a list of integers, write a function that finds the smallest and the largest value of this list. Given a list of numbers, write a function which finds their standard deviation


1
Expert's answer
2022-02-01T06:32:49-0500
 1.
 def pythagoreanTriplets(limits):
     c, m = 0, 2
     while c < limits:
         for n in range(1, m):
             a = m * m - n * n
             b = 2 * m * n
             c = m * m + n * n
             if c > limits:
                 break
             print(a, b, c)
         m = m + 1#
 # Driver Code
 if __name__ == '__main__':
     limit = 20
     pythagoreanTriplets(limit)


# 2.
numbers = [4, 5, 8, 9, 10]

print('Minimum: ', min(numbers))
print('Maximum: ', max(numbers))

mean = sum(numbers) / len(numbers)
variance = sum([((x - mean) ** 2) for x in numbers]) / len(numbers)
res = variance ** 0.5

print('Standard deviation: ', res)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Suresh kumar R
01.02.22, 15:41

Thanks a lot at right time Assignment expert helps me again thanks a lot

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS