如何将Python的输出导出到excel文件? [英] How to export the output of a Python to excel file?

查看:618
本文介绍了如何将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)

推荐答案

python excel - Google搜索 [ ^ ]


这篇关于如何将Python的输出导出到excel文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆