Tuples Business#

Section Title: Tuples Business

Business Applications#

Question-1: Production Data Analysis#

The following two tuples represent the annual production and the corresponding years for a company over a 10-year period.

production = (3000, 2500, 5000, 4750, 2250, 6300, 8000, 7500, 9000, 8700)
years = (2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021)
  • Calculate the total, average, and highest production using methods from numpy.

  • Determine the year with the highest production using the index() method.

Question-2: Profit and Loss#

The following three tuples represent the revenue, cost, and the corresponding years for a company over a 10-year period.

revenue = (2000, 4500, 5000, 6000, 3000, 4000, 8000, 2000, 6000, 3000)
cost    = (2500, 3500, 3750, 4500, 4000, 3500, 4500, 3000, 4500, 4000)
years   = (2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021)
  • Calculate the total profit and total loss.

  • Create a tuple consisting of the years when the company lost money.

  • Determine the overall profit during these 10 years

Question-3: Total Cost#

The following tuple represents the unit price-quantity pairs for various items. Write a program that computes the total cost using a for loop.

price_quantity = ((8 dollars, 100 items), (4 dollars, 300 items), (23 dollars, 150 items), (89 dollars, 75 items))

Question-4: Stock Symbols#

Given the following tuple containing stock symbols, write a program that returns a new tuple with the following modifications:

  • Remove duplicate stock symbols while preserving the original order.

  • Replace any ‘.’ characters in the symbols with ‘-’ characters.

symbols = ['MMM', 'BF.B', 'CAT', 'AMZN', 'BRK.B', 'AAL', 'CAT', 'GOOG', 'MMM', 'AEP']

Question-5: Stock Value Calculation#

The initial stock price is 200. A tuple of daily percentage changes for the next ten days is provided.

  • Calculate the stock price at the end of each day for the next ten days.

pct_changes = (0.02, 0.03, -0.01, 0.04, 0.01, 0.08, 0.03, -0.01, 0.04, 0.01)