python怎么导出,如何将Python的输出导出到excel文件?

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)

解决方案

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值