Python Most Important Interview Questions Question 1: Calculate the average stock price for Company X over the last 6 months.
Question 2: Identify the month with the highest total sales for Company Y using their monthly sales data.
Question 3: Find the maximum and minimum stock price for Company Z on any given day in the last year.
Question 4: Create a column in the DataFrame showing the percentage change in stock price from the previous day for Company X.
Question 5: Determine the number of days when the stock price of Company Y was above its 30-day moving average. Question
6: Compare the average stock price of Companies X and Z in the first quarter of the year.
#Data#
----------------------------------------------
import pandas as pd
data = { 'Date': pd.date_range(start='2023-01-01', periods=180, freq='D'), 'CompanyX_StockPrice':
pd.np.random.randint(50, 150, 180), 'CompanyY_Sales':
pd.np.random.randint(20000, 50000, 180), 'CompanyZ_StockPrice':
pd.np.random.randint(70, 200, 180) }
df = pd.DataFrame(data)