<jupyter_start><jupyter_text>Beginner's Python—Session Two Finance/Economics - Questions  Analysing blue-chip stocks Figures 1, 2, 3, and 4 below illustrate the stock price time series of four different tech companies (Apple, Facebook, Amazon and Netflix) over the last year. We will use this data to derive some insights on these stocks during the aforementioned period.<jupyter_code># Run this cell to get stock data as lists. DO NOT MODIFY THE CODE ON THIS CELL
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
standard_palette = list(sns.color_palette("muted"))

url = 'https://raw.githubusercontent.com/warwickdatascience/beginners-python/master/session-two/subject_questions/session_two_files/' 

aapl = pd.read_csv( url + "AAPL.csv").rename(columns={"Open": "Price ($USD)", "Date":"Time"})
fb = pd.read_csv(url + "FB.csv").rename(columns={"Open": "Price ($USD)", "Date":"Time"})
amzn = pd.read_csv(url + "AMZN.csv").rename(columns={"Open": "Price ($USD)", "Date":"Time"})
nflx = pd.read_csv(url + "NFLX.csv").rename(columns={"Open": "Price ($USD)", "Date":"Time"})
datasets = {"AAPL": aapl,"FB": fb,"AMZN": amzn,"NFLX": nflx}

aapl_prices = aapl["Price ($USD)"].tolist()
fb_prices = fb["Price ($USD)"].tolist()
amzn_prices = amzn["Price ($USD)"].tolist()
nflx_prices = nflx["Price ($USD)"].tolist()

i = 1
fig = plt.figure(figsize=(10,8))
for key in datasets:
    dataset = datasets[key]
    fig.add_subplot(2,2,i, title= "Figure {}: ".format(i) + key + " stock price (Oct.2019 - Oct.2020)")
    ax = sns.lineplot(data=dataset, y="Price ($USD)", x="Time", color=standard_palette[i-1])
    ax = ax.xaxis.set_tick_params(bottom=False, labelbottom=False)
    ax
    i+=1
    
plt.tight_layout()
plt.show()<jupyter_output><empty_output><jupyter_text>To make this analysis easier, we assinged the price data to the following lists:- `aapl_prices`- `fb_prices`- `amzn_prices`- `nflx_prices`Did all companies record the same number of stock price observations? Find the number of observations (given by the length of the price lists) for each company and print the results below. What was the average price of Facebook stocks during the last year? Calculate your answer in the cell below, round it to two decimal places, assign it to variable `fb_avg_price_1` and print out the result. (Hint: Your should use the sum(), len(), and round() functions). What was the maximum price of an Amazon stock during the last year? Calculate and print your answer below, rounding to two decimal places. What was the minimum price of Apple stocks during the last year? Calculate and print the answer below, rounding to two decimal places. What range of values did the price of Netflix stocks have during the last year? Calculate and print the answer below. (Hint: Is it a problem if you use 'range' as a variable name? Why?) Most financial analysts predict that Facebook stocks will open tomorrow with a price of $265 USD. You, however, know that Facebook will anounce its adquisition of a hot new startup that will likely boost its revenue stream significantly.Do you think the opening FB stock price will be higher or lower than the forecast given? In the cell below, ask the user to input its prediction for the opening FB price tomorrow, assign it to the variable `fb_pred`, and print its datatype WITHOUT using a print statement. The variable `fb_pred` is non-numerical, which means that we won't be able to use it in further calculations. Cast this variable as float-type and add it to the list `fb_prices`. (Hint: To add this variable you will need to use the .append() function. An example of how this is done is shown in the cell below)<jupyter_code># Example use of the .append() function to add items at the end of a list
my_list = [1,2,3,4,5,6]
print("This is my list at the start: ", my_list)

# Adding 7 to my list
my_list.append(7)
print("This is my list after adding 7 at the end of it: ", my_list)

# Adding 99 to my list
my_list.append(99)
print("This is my list after adding 99 at the end of it: ", my_list)<jupyter_output>This is my list at the start:  [1, 2, 3, 4, 5, 6]
This is my list after adding 7 at the end of it:  [1, 2, 3, 4, 5, 6, 7]
This is my list after adding 99 at the end of it:  [1, 2, 3, 4, 5, 6, 7, 99]
{'fraction_non_alphanumeric': 0.10609268407433545, 'fraction_numerical': 0.015055281110326982, 'mean_word_length': 4.800818553888131, 'pattern_counts': {'":': 12, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '247562', 'license': 'MIT', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1281, 'n_words': 590, 'path': 'session-two/subject_questions/session_two_finecon_questions.ipynb', 'repo_name': 'Precel2000/beginners-python', 'size': '4251'}