Q:

Write a python program to use string.format() method to format the following three variables as per the expected output

belongs to collection: Python Input and Output Exercises

-1

Format variables using a string.format() method.

Write a program to use string.format() method to format the following three variables as per the expected output

Given:

totalMoney = 1000
quantity = 3
price = 450

Expected Output:

I have 1000 dollars so I can buy 3 football for 450.00 dollars.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution:

quantity = 3
totalMoney = 1000
price = 450
statement1 = "I have {1} dollars so I can buy {0} football for {2:.2f} dollars."
print(statement1.format(quantity, totalMoney, price))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a python program to check if the given file ... >>
<< Write a python program to take three names as inpu...