题型:综合题 题类:常考题 难易度:困难
浙江省绍兴市海亮高级中学2020-2021学年高一下学期信息技术期中考试试卷
def convert(s):
m=0
le=len(s)
key=s[le-1]
if key=="B":
n=2
elif key=="D":
①
else:
n=16
i=0
while i<=le-2:
c=s[le-1-i]
if c>="0"and c<="9":
a=ord(c)-ord("0")
elif c>="A"and c<="F":
a=ord(c)-ord("A")+10
②
i+=1
return m
s=input("请输入算式")
result=0;suanfu1="";suanfu2="";s1=""
for i in range(len(s)):
c=s[i]
if c=="+" or c=="-" or c=="=":
③
suanfu1=suanfu2
suanfu2=c
if suanfu1=="":
result=t
if suanfu1=="+":
result=result+t
if suanfu1=="-":
result=result-t
s1=""
else:
s1=s1+c
print("计算结果为"+str(result)+"D")
① ② ③
试题篮