Complete the code to insert the variable name into the string using format().
greeting = "Hello, {}!".[1](name) print(greeting)
format() method is used to insert variables into strings where curly braces {} are placed.Complete the code to format the number pi to 2 decimal places using format().
pi = 3.14159 formatted_pi = "{:.[1]f}".format(pi) print(formatted_pi)
.2f formats the number to 2 decimal places.Fix the error in the code to correctly format the string with two variables name and age.
info = "Name: {}, Age: {}".[1](name, age) print(info)
format().Fill both blanks to create a formatted string that aligns name left and score right within 10 spaces.
result = "Name: {0:[1]10} Score: {1:[2]10}".format(name, score) print(result)
^ instead of left or right.< to align left and > to align right inside the format specifier.Fill all three blanks to format a dictionary data into a string showing key uppercased, value, and only keys with values greater than 10.
formatted = ", ".join("{0}: {1}".format([1], [2]) for k, v in data.items() if v [3] 10) print(formatted)
k.lower() instead of uppercasing keys.< or ==.k.upper() to uppercase keys, v for values, and > to filter values greater than 10.