【发布时间】:2018-02-20 19:00:32
【问题描述】:
int_one =input("Please enter a three-digit number thats first number is greater than last ")
int_one_swap = (int_one[-1]+int_one[1:-1]+int_one[0])
print (int_one_swap)
print (int(int_one) - int(int_one_swap))
math_one = (int(int_one)-int(int_one_swap))
print (math_one)
int_two_swap = (int(math_one[-1]+int(math_one[1:-1])+ int(math_one[0]))
print (int_two_swap)
final = (int_two_swap + math_one)
print (final)
if final == 1089:
print ("Your result is 1089")
else:
print ("Your result is not 1089 so your first and last digits must have differed by less than 2")
遇到语法问题。 需要让程序运行所有这些命令并努力让它工作。教授说了一些关于整数和字符串的转换,但我就是不明白。请帮忙
【问题讨论】:
-
1.请格式化代码和 2) 你使用什么编程语言?
标签: python string numbers integer mixing