''' DS2000 Spring 2020 Sample code from class: breaking down a number into 100s digit, 10s digit, and 1s digit. January 10, 2020 Test cases: * 167 --> 1, 6, 7 * 2048 --> 0, 4, 8 * 123789 --> 7, 8, 9 ''' def main(): orig = int(input('Enter a non-negative integer\n')) # To isolate the hundreds digit: # orig // 100 gives us how many 100-units there are # % 10 helps us with leftover, if the orig was 1000 or higher hundreds = (orig // 100) % 10 print('hundreds =', hundreds) # To isolate the tens digit: # orig // 10 gives us how many 10-units there are # % 10 helps us with leftover, if orig is 100 or higher tens = (orig // 10) % 10 print('tens =', tens) # Finally, to isolate the ones digit, it's just a simple %10 ones = orig % 10 print('ones =', ones) main()