In: Computer Science
Code in python the grocery receipt the following steps using the knowledge you have. declare a string variable called card_number. Assign a value of “xxx8974” declare a string variable called date and assign a string value of “9\7\2020” You need to use an escape sequence for the slashes in this string. See Mosh’s video 2.4-Escape Sequence if needed. You do not need to use a date class variable as we have not learned that data type yet. Use a simple string variable. declare a float number variable called cookies_cost and assign value of 3.15 Save and test frequently to catch errors early declare a float number variable called chips_cost and assign value of 3.15 declare a float number variable called salsa cost and assign value of 5.10 declare a float number variable called total_cost and assign a value that adds cookies_cost plus ships_cost plus salsa_cost. Use multiple print() functions to print the following receipt as exampled in the following figure Consider using string interpolation to combine text and number variables on the same line. String interpolation example: print(f”Borrower does not qualify at {rate}”) How will you format 5.1 to display 5.10? Search Google for “python display two decimals” and read the articles. We want you to be able to learn from good online articles.
Answer:
here is the python code as per your requirements or instructions in the code
Raw code:
#card number
card_number="xxx8974"
#date using escape sequences
date="9\\7\\2020"
#assingning float values
cookies_cost=3.15
chips_cost=3.15
salsa_cost=5.10
#total cost by adding all the cost
total_cost=cookies_cost+chips_cost+salsa_cost
#let the rate be 5.1
rate=5.1
#string interpolation and printing the 5.1 as 5.10 using rate:.2f for decimal points
print(f"Borrower does not qualify at {rate:.2f}")
Editor:
output:
Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.
"Please refer to the screenshot of the code to understand the indentation of the code".
Thank you! Do upvote.