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.
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)
Comments
Thanks a lot at right time Assignment expert helps me again thanks a lot
Leave a comment