Why do I Get This Output?


#1

why did the output come out to be so when I accidentally typed an ‘O’ instead of a 0 in %04d?


FAQ: Learn Python - Date and Time - Hot Date
#2

why do you use d in the %02d instead of %02s.

It prints the same result.


#3

Hi @apurvmarathe,

%o converts the integer to octal. Octal is based off of the number 8, instead of 10 like we’re used to with the decimal counting system. In decimal, 11 would mean (10 * 1) + (1), but in octal it means (8 * 1) + (1). So "%o" % (2018) is just printing out 2018 converted into octal.