0

I'm doing an assignment guys and new to this programming thing.X=2.5 print ("The value of x is %d" %x) The output is?

Assignment question.

6th Mar 2017, 9:51 PM
Malesela Mosuwe
Malesela Mosuwe - avatar
2 odpowiedzi
+ 7
Use %f to format float, or 'format' method in Python 3.x ( to handle auto type cast ): print("The value of x is {}".format(x)) More stuff about format() method and comparison old/new formatting style: https://pyformat.info/
7th Mar 2017, 3:33 AM
visph
visph - avatar
+ 2
"%d" stands for decimal signed integer and used when you want to print such an integer. Take a look at the following link for more information. https://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/FUNCTIONS/format.html By the way, I think the output is 2.
6th Mar 2017, 10:04 PM
Reza Karimi
Reza Karimi - avatar