Printing boolean variables

You want students who you liked teaching to know that you enjoyed having them as students.

1
2
3
4
5
6
7
name = "Aditya"
score = 98
liked = True

message = "Hi %s. You achieved a score of %d. It's [---] that I enjoyed having you as a student." % (name, score, liked)

print message

What do you use to replace [---] so that the output is:

1
Hi Aditya. You achieved a score of 98. It's True that I enjoyed having you as a student.

%d %b %s %f

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Enamul Hassan
Jul 20, 2014

As it prints a string, it should be %s. you can also print it with %f and %d, but it will express the floating point and integer equivalent value 1.00000000 and 1 respectively. %b is totally invalid and the purpose of this option is to make you confused!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...