Formatting a variable that has an integer value

1
2
3
4
score = 98
message = "You achieved a score of [---]." % score

print message

Assuming the above code is python, what would you use to replace [---] so that the output is:

1
You achieved a score of 98.

%r %s None of the above %d

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.

3 solutions

Yasir Khan
Dec 11, 2014

the data type is integer.. so %d for decimal %f for char %c for strings %s

Isn't "%f" for float data type?

Prasun Biswas - 6 years, 4 months ago

lol i didn't know that but i got the correct answer xD

aldrin de guzman - 6 years, 4 months ago
Quy Nguyen
Nov 30, 2014

Answer: %d Of course: data type is Decimal integer in C programming For example: printf(" Enter score "); scanf("%d", &socre); ....

Rajdeep Das
Nov 28, 2014

Also we can use %d .Because In C , "%d" --> Decimal integer. As We See score variable store a integer value , so we can Use %d

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...