print(f"day's digit:",num/1)
print("<<Number extraction operation>>")
num=int (input ("▣four-digit integer =>"))
print ("==== output result ====")
print (f"cloth digits:",num/1000)
num=num%1000
print (f"back digit:",num/100)
num=num%100
print (f"digit:",num/10)
num=num%10
I'm going to do it like the picture above The results of the four-digit integer spacing and the digit output are different, so I'd like your help!
python coding
The %
operation is to obtain the remainder.
To achieve the desired result, you must perform a quotient operation.
Of course, if you immediately perform a quotient operation for each digit, you can get more than two digits.
Combine the operations of finding the remainder with the operations of finding the quotient
print("<<Number extraction operation for name>>")
num = int (input ("four-digit integer => ")))
a = num // 1000
b = (num - a * 1000) // 100
c = (num - a * 1000 - b * 100) // 10
d = (num - a * 1000 - b * 100 - c * 10) // 1
print ("===== output result =====")
print("A Thousand Digits:", a)
print("back digit:", b)
print("10 digits:", c)
print("Position of work:", d)
I don't need five lines of // 1 but I put it in.
578 Understanding How to Configure Google API Key
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
623 Uncaught (inpromise) Error on Electron: An object could not be cloned
614 GDB gets version error when attempting to debug with the Presense SDK (IDE)
924 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.