What does this print?>>> print("{:d} Mission street, {}".format(972, "San Francisco"))“972 Mission street, San Francisco”72 Mission street, SanSan Francisco Mission street, 972972 Mission street, San Francisco
Question
What does this print?>>> print("{:d} Mission street, {}".format(972, "San Francisco"))“972 Mission street, San Francisco”72 Mission street, SanSan Francisco Mission street, 972972 Mission street, San Francisco
Solution
The correct answer is "972 Mission street, San Francisco". The format() function in Python is used to format the specified value(s) and insert them inside the string's placeholder. The placeholder is defined using curly brackets: {}. In this case, {:d} is a placeholder for a decimal (integer) number, and {} is a general placeholder for any type of data. So, 972 replaces {:d} and "San Francisco" replaces {}.
Similar Questions
What does this command line print?>>> print(f"{98} Battery street, {'San Francisco'}")“98 Battery street, San Francisco”8 Battery street, San98 Battery street, San FranciscoSan Francisco Battery street, 98
What does this command line print?>>> a = "Hello, world!">>> print(a[:5])orld!Helloworld!I don't know
What does the program below display?full_name = "Jane"full_name = full_name + "Brown"print( full_name )*
What do these lines print?>>> for i in ["Hello", "Holberton", "School", 98]:>>> print(i, end=" ")0 1 2 31 2 3 4Hello Holberton School 98
What is the output of the following program :print "Hello World"[::-1]
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.