I have written a python program for Pythagoras theorem, I want to save the output in excel file for calculating for different values.
What I have tried:
import random
import math
a = float(input('Please Enter the Width of a Right Angled Triangle: '))
b = float(input('Please Enter the Height of a Right Angled Triangle: '))
def get_iteration(seed_values=None):
v = {} # variable holder
if seed_values is None:
# generate 'random' values for a new iteration
v['a'] = random.randint(1,30)
v['b'] = random.randint(1,30)
else:
v.update(seed_values)
# calculate remaining variables as needed and update v
v['area'] = 0.5 * v[a] * v[b]
v['c'] = math.sqrt[v[a * a] + v[b * b]]
v['perimeter'] = v[a] + v[b] + v[c]
return v
# calculate the area
Area = 0.5 * a * b
# calculate the Third Side
c = math.sqrt((a*a) + (b*b))
# calculate the Perimeter
Perimeter = a + b + c
print("\n Area of a right angled triangle is: %.2f" %Area)
print(" Other side of right angled triangle is: %.2f" %c)
print(" Perimeter of right angled triangle is: %.2f" %Perimeter)
解决方案