課程
/后端開發
/Python
/初識Python
編寫一個程序,提示用戶輸入一個整數,然后顯示顛倒各位數字后的數
2019-03-30
源自:初識Python 3-1
正在回答
x=int(input("請輸入一個整數:"))
y=0
a=0
while 1:
? ? a=x%10
? ? y=10*y+a
? ? x=(x-a)/10
? ? if x<1:
? ? ? ? break
print("反向數是:%d"%y)
#?-*-?coding:?utf-8?-*- a=input("請輸入一個數字") a=int?(a) if??a<=10?: ????print(a) elif?a>=10?and?a<100?: ????c=a//10 ????d=a%10 ????print(d*10+c) elif?a>=100?and?a<1000?: ????b=a//100 ????c=a//10%10 ????d=a%10 ????print(d*100+c*10+b) #else: #后面同理
舉報
學python入門視頻教程,讓你快速入門并能編寫簡單的Python程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2019-03-31
x=int(input("請輸入一個整數:"))
y=0
a=0
while 1:
? ? a=x%10
? ? y=10*y+a
? ? x=(x-a)/10
? ? if x<1:
? ? ? ? break
print("反向數是:%d"%y)
2019-03-30