there’s line in code where it is written
print( 'marks : " { :d }" ’ . format(self.marks) )
what is :d in the brackets?
can’t we directly write
print( "marks : { } " . format(self.marks) )
there’s line in code where it is written
print( 'marks : " { :d }" ’ . format(self.marks) )
what is :d in the brackets?
can’t we directly write
print( "marks : { } " . format(self.marks) )
hey @muditarya31 ,
this is just a kind printing values with types defined.
its just stating that value to be printed is a decimal .
In the above case it works the same with both line of codes.
But take an example where you want to directly print binary of a decimal number
we can write it as
print("{:b}".format(2))
it output as 10 ( 2 in binary )
I hope this would have resolved your doubt.
Thank You and Happy Learning .
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.