SOLUTION COMPREHENSIVE SCRIPT 2026
COMPLETE QUESTIONS AND SOLUTIONS
GRADED A+
⩥ total_purchase_cost. Answer: Total cost of the grocery store items
purchased, adjusted for discounts based on quantity.
⩥ discount for 10-20 items. Answer: If between ten and twenty items
(inclusive) are purchased, the purchase gets a 5% discount.
⩥ discount for 21 or more items. Answer: If twenty-one or more items
are purchased, the purchase gets a 10% discount.
⩥ sentence. Answer: A new sentence string composed of three existing
words from a text file.
⩥ file_name. Answer: The name of a text file or CSV file input by the
user.
⩥ CSV file. Answer: A file containing two rows of comma-separated
values to be imported as dictionaries.
, ⩥ num_stock. Answer: An integer input identifying how many shares of
stock are to be purchased.
⩥ item_purchased. Answer: A string input representing a grocery store
item.
⩥ num_items. Answer: An integer input identifying the number of items
purchased.
⩥ Total price output format. Answer: Output format for stock purchase:
Total price: $cost_of_stocks
⩥ Grocery purchase output format. Answer: Output format for grocery
purchase: item_purchased $total_purchase_cost
⩥ File read and write. Answer: Using open(), write(), and read()
methods to interact with a text file.
⩥ Dictionary creation from CSV. Answer: Creating a dictionary of
key:value pairs for each row of comma-separated values in a CSV file.
⩥ Example of stock selection. Answer: TSLA, BBBY, AAPL, SOFI,
KIRK, AURA, AMZN, EMBK, LVLU