from math import *
def hum (first,second):
res = 0
for i in range (first,second):
res += i
return res
f= int(input("Pleae add your First number \n"))
s= int(input("Please addd your second number \n"))
finalres = hum(first= f,second= s)
print("The sum of all numbers between",f ,"and", s,"is" , "(" ,finalres,")")
print("")
YorN = input("Do you want to get different type of this number? Yes = Y , No = N \n")
if YorN == "Y" or YorN == "y" :
iii= chr(finalres)
vv= bin(finalres)
vvv=hex(finalres)
kk=oct(finalres)
sinnn=round(sin(finalres))
print("")
print("Uni Code is ",iii,"\n")
print("Binary number is ",vv,"\n")
print("Hex number is ",vvv,"\n")
print("oct number is ",kk,"\n")
print("Sin is ", sinnn ,"\n")
newlst=[iii,vv,vvv,kk,sinnn]
with open("E:\EBRAHIM\rrd.txt","w") as fh:
for item in newlst:
fh.write(item)
我想创建一个包含结果编号的列表,在此路径中创建一个新文本文件,以将列表中的项目放入此文本文件中,但是上线(打开时...)却出现错误。 ) 有什么建议么? *我已经开始学习Python 2天了,仍然在学习,谢谢。