according to me this program output should be [0 0 6 2],but output is [0 0 2],why
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#request input from the user num = eval ( input ( "please enter an integer in the range 0....9999" )) if num< 0 : num = 0 if num> 9999 : num = 9999 print (end = "[" ) #extract and print thousand place digit digit = num / / 1000 print (digit,end = " " ) num % = 1000 #extract and print hundred place digit digit = num / / 100 print (digit,end = " " ) num % = 10 #remainder is the one place digit print (num,end = " " ) print ( "]" ) |
Moderator Larz60+: Added Python tags. Please do this in the future (see help, BBCODE)