Formatted Strings

Run Settings
LanguagePython
Language Version
Run Command
# 1 What would be the output of the below 4 print statements? #Try to answer these before you click RUN! print("Hello {}, your balance is {}.".format("Cindy", 50)) #Hello Cindy, your balance is 50. print("Hello {0}, your balance is {1}.".format("Cindy", 50)) #Hello Cindy, your balance is 50. print("Hello {name}, your balance is {amount}.".format(name="Cindy", amount=50)) #Hello Cindy, your balance is 50. print("Hello {0}, your balance is {amount}.".format("Cindy", amount=50)) #Hello Cindy, your balance is 50. # 2 How would you write this using f-string? (Scroll down for answer) user_name = "Cindy" amount = 50 print(f"Hello {user_name}, your balance is {amount}.")
Editor Settings
Theme
Key bindings
Full width
Lines