Quick actions

cmd+k|ctrl+k

Navigation

Languages

# Formatted Strings

Snippet info

Language

Python

Visibility

public

Author

harshdeepsaini2757

Created

2025-11-02T19:25:58.471836Z

Updated

2025-11-02T19:26:07.991886Z

# Formatted Strings

name = 'John'
age = 21

print('hi ' + name+ '. You are ' + str(age) + ' years old.')
print(f"hi {name}. You are {age} years old.")
print("hi {}. You are {} years old.".format(name,age))

n_name = 'Cindy'
amount = 50

print("Hello {}, your balance is {}.".format("Cindy", 50))
print("Hello {0}, your balance is {1}.".format("Cindy", 50))
print("Hello {name}, your balance is {amount}.".format(name="Cindy", amount=50))
print("Hello {0}, your balance is {amount}.".format("Cindy", amount=50))
print(f"Hello {n_name}, your balance is {amount}.")



INFO