Python / Jupyter – Assignment 2 Assignment 2.1 - Scalar variables, templating and datetimes¶ · create the following variables: sales = " XXXXXXXXXX" commission_rate = " XXXXXXXXXX" · Convert sales to...

1 answer below »
See attached


Python / Jupyter – Assignment 2 Assignment 2.1 - Scalar variables, templating and datetimes¶ · create the following variables: sales = "9589220.12" commission_rate = "0.13456999" · Convert sales to a float, and print it as a string with a preceeding $ sign and comman separation every 000s using the as_currency function. Drop the values after the decimal place. · Convert commission_rate to a float, and print it as a string followed by the % sign with 3 decimal places. Assignment 2.2 - Lists · Create a list caled travel_destinations with the following elements: Italy, France, Australia, Germany, China · Create a new list of only the 4th and 5th list entries · Add South Africa to travel_destinations as the first entry · Remove Germany from the list travel_destinations · Sort the list travel_destinations into reverse alphabetical order Assignment 2.3 - Dictionaries¶ · Create a dictionary with the following names (as the keys) and their ranking (as the value) · Soccer: 1 · Football: 3 · Tennis: 7 Basketball: 2 · Add the key:value of Rugby:9 to this list · Remove the entry for Football. · Assignment 2.4 - Operators · Find the investment value of $250 invested at a 3 percent return over 10 years. · Format your results using the as_currency function with 2 decimal places. · Using a country list with the elements Italy, France, Australia, Germany, China - Generate a boolean (True or False) to see if Bulgaria is in the list - Generate a boolean (True of False) to see if China is in the list Assignment 2.5 - Math functions on scalars and lists · Create a list with the values corrsponding to years of experience of members of your analytics team. experience = [4, 7, 23, 9, 10] · Among the math functions .prod(x), .log(x), .sqrt(x), which can accept the variable x as the experience list? · Comment on why any error messages occur · Assignment 2.6 - Statistic functions on lists · import the file daily_adjusted_IVV.csv, and convert the close column to a list. · Calculate the mean, standard deviation and quartiles from this list · Verify your calculations by also performing them in Excel timestamp,open,high,low,close,adjusted_close,volume,dividend_amount,split_coefficient 1/7/2021,377.4711,381.26,377.28,380.47,380.47,6051650,0,1 1/6/2021,371.02,378.37,370.46,374.92,374.92,4343066,0,1 1/5/2021,369.44,373.83,369.44,372.67,372.67,4310505,0,1 1/4/2021,376.69,376.82,366.16,370.22,370.22,7103724,0,1 12/31/2020,373.2,376.04,372.6,375.39,375.39,4713052,0,1 12/30/2020,373.74,374.4309,372.95,373.3,373.3,2727467,0,1 12/29/2020,375.15,375.4,372.2,372.81,372.81,5401585,0,1 12/28/2020,373.15,373.94,372.44,373.53,373.53,2335819,0,1 12/24/2020,369.42,370.36,368.8098,370.31,370.31,2040697,0,1 12/23/2020,369.6301,370.955,368.7,368.88,368.88,3234329,0,1 12/22/2020,369.49,369.67,367.42,368.56,368.56,3441988,0,1 12/21/2020,366.3,370.14,363.38,369.27,369.27,5221646,0,1 12/18/2020,372.36,372.48,368.36,370.49,370.49,6697564,0,1 12/17/2020,371.69,372.195,369.8745,371.96,371.96,6485616,0,1 12/16/2020,369.62,370.91,368.625,369.9,369.9,5512871,0,1 12/15/2020,367.14,369.35,365.69,369.31,369.31,8472663,0,1 12/14/2020,368.44,369.57,364.21,364.35,364.35,3797572,1.6102,1 12/11/2020,366.27,367.93,364.615,367.62,366.002475,4501555,0,1 12/10/2020,366.75,369.214,365.811,368.08,366.460451,3151144,0,1 12/9/2020,372.28,372.42,367.325,368.28,366.659571,3758194,0,1 12/8/2020,369.07,372.16,369.06,371.53,369.895271,3491095,0,1 12/7/2020,370.43,370.99,369.12,370.5,368.869803,3162331,0,1 12/4/2020,368.68,371.2,368.6194,371.19,369.556767,4091844,0,1 12/3/2020,368.0199,369.5299,366.88,368.03,366.410671,3068483,0,1 12/2/2020,366.16,368.27,365.55,368.1,366.480363,4121854,0,1 12/1/2020,366.9,368.99,366.27,367.32,365.703795,3664972,0,1 11/30/2020,364.18,364.39,360.5,363.32,361.721395,4093350,0,1 11/27/2020,365.19,365.52,363.97,364.98,363.374091,1354562,0,1 11/25/2020,364.4,364.48,362.8,363.99,362.388447,3826470,0,1 11/24/2020,361.52,365.1,360.5973,364.51,362.906159,3512360,0,1 11/23/2020,358.65,360.05,356.17,358.77,357.1914149,2728517,0,1 11/20/2020,358.79,359.04,356.53,356.63,355.0608309,2697897,0,1 11/19/2020,356.845,359.5,355.49,359.04,357.4602269,3321607,0,1 11/18/2020,362.21,362.82,357.53,357.59,356.0166069,3179144,0,1 11/17/2020,361.27,363.24,359.69,361.95,360.3574229,2656620,0,1 11/16/2020,362.34,363.87,360.93,363.8,362.199283,3332428,0,1 11/13/2020,356.52,360.188,355.99,359.34,357.7589069,2685415,0,1 11/12/2020,356.85,357.69,352.54,354.52,352.9601149,3794928,0,1 11/11/2020,357.66,358.86,356.4275,357.93,356.3551109,2485781,0,1 11/10/2020,354.77,356.42,351.8682,355.37,353.8063749,5174082,0,1 11/9/2020,365.29,365.69,355.34,355.83,354.2643509,9109230,0,1 11/6/2020,351.17,352.76,348.95,351.44,349.8936669,2871848,0,1 11/5/2020,350.54,353.445,350.1254,351.47,349.9235349,6900518,0,1 11/4/2020,342.07,349.19,340.74,344.73,343.2131908,6499142,0,1 11/3/2020,334.86,339.43,334.35,337.28,335.7959707,6559410,0,1 11/2/2020,331.38,333.5271,328.38,331.36,329.9020187,4658487,0,1 10/30/2020,329.42,330.82,323.72,327.62,326.1784747,6634052,0,1 10/29/2020,328.1,334.54,326.26,331.15,329.6929427,5163505,0,1 10/28/2020,333.24,334,327.3,327.88,326.4373307,7096185,0,1 10/27/2020,340.9267,341.3,339.16,339.43,337.9365108,4227596,0,1 10/26/2020,343.32,344.19,336.81,340.59,339.0914068,4327232,0,1 10/23/2020,347.164,347.19,344.36,346.96,345.4333788,1796836,0,1 10/22/2020,344.2,346.45,341.88,345.86,344.3382188,2461179,0,1 10/21/2020,344.52,346.79,343.63,343.9,342.3868428,3689177,0,1 10/20/2020,344.67,348.1,343.89,344.57,343.0538948,2816247,0,1 10/19/2020,349.88,350.52,342.2987,343.22,341.7098348,2973436,0,1 10/16/2020,350.27,351.97,348.34,348.45,346.9168228,2768044,0,1 10/15/2020,344.92,349.24,344.31,348.76,347.2254588,3021176,0,1 10/14/2020,351.95,353.085,348.37,349.19,347.6535668,2373076,0,1 10/13/2020,353.51,353.6,350.33,351.39,349.8438869,2664589,0,1 10/12/2020,350.78,355.25,350.28,353.69,352.1337669,2301131,0,1 10/9/2020,346.79,348.54,346.09,348.01,346.4787588,3377059,0,1 10/8/2020,344.07,345.03,343.06,344.98,343.4620908,4166927,0,1 10/7/2020,339.28,342.8,339.28,341.9,340.3956428,3121992,0,1 10/6/2020,341.13,343.35,335.56,336.06,334.5813387,3934679,0,1 10/5/2020,337.21,341.12,337.2,340.9,339.4000428,3208467,0,1 10/2/2020,332.82,337.09,332.385,335.05,333.5757827,4092570,0,1 10/1/2020,338.83,339.87,336.18,338.24,336.7517468,3381645,0,1 9/30/2020,334.34,339.4688,334.1,336.06,334.5813387,4750895,0,1 9/29/2020,335.21,335.895,332.78,333.51,332.0425587,2540790,0,1 9/28/2020,334.36,336.1,333.31,335.36,333.8844187,3411162,0,1 9/25/2020,323.74,330.71,322.75,329.88,328.4285307,4178642,0,1 9/24/2020,322.3177,327.9,320.92,324.6,323.1717626,4232095,0,1 9/23/2020,332.09,332.38,323.22,323.75,322.3255026,4366063,1.5058,1 9/22/2020,331.2297,333.57,328.5,332.97,329.9701997,2864816,0,1 9/21/2020,328.42,329.74,324.35,329.63,326.6602905,6177811,0,1 9/18/2020,338.17,338.21,330.64,333.34,330.3368663,3204653,0,1 9/17/2020,334.94,339.01,334.341,337.29,334.2512799,3097858,0,1 9/16/2020,342.95,344.47,339.95,340.21,337.144973,2453201,0,1 9/15/2020,342.52,343.42,340.4102,341.57,338.4927204,2553912,0,1 9/14/2020,338.86,341.66,338.32,339.84,336.7783064,2830727,0,1 9/11/2020,337.12,338.27,332.35,335.38,332.3584875,3490163,0,1 9/10/2020,343.26,343.91,334.21,335.22,332.199929,5060220,0,1 9/9/2020,338.98,343.89,337.98,341.18,338.106234,5378531,0,1 9/8/2020,338.05,339.4,334.23,334.63,331.6152444,5003489,0,1 9/4/2020,347.6,349.29,336.26,343.98,340.8810082,5359409,0,1 9/3/2020,357.38,357.8759,344.02,346.82,343.695422,7771371,0,1 9/2/2020,356.18,360.26,354.93,359.24,356.0035275,3596614,0,1 9/1/2020,351.68,354.18,350.7,354.06,350.8701953,3700409,0,1 8/31/2020,351.81,352.77,350.51,350.77,347.6098356,5757749,0,1 8/28/2020,350.89,352.19,349.66,352,348.8287543,2520823,0,1 8/27/2020,349.66,351.32,347.98,349.76,346.6089349,3767591,0,1 8/26/2020,346.11,349.27,345.58,349,345.8557819,3674797,0,1 8/25/2020,344.96,345.6,343.711,345.49,342.3774043,4004390,0,1 8/24/2020,343.52,344.42,342.45,344.35,341.2476748,2083972,0,1 8/21/2020,339.23,341.05,338.95,340.85,337.7792071,2063327,0,1 8/20/2020,336.73,340.1505,336.59,339.66,336.5999281,1804711,0,1 8/19/2020,340.4,340.999,338.02,338.62,335.5692976,1911489,0,1 8/18/2020,339.72,340.46,337.98,340,336.9368649,1634618,0,1 8/17/2020,339.32,339.72,338.87,339.28,336.2233516,1630600,0,1 8/14/2020,337.7601,338.79,337.05,338.19,335.1431716,1716097,0,1 8/13/2020,338,339.615,337.18,338.22,335.1729013,2643209,0,1 8/12/2020,336.85,339.6403,336.8,338.8,335.747676,2907862,0,1 8/11/2020,338.24,338.88,333.38,334.14,331.129659,3603710,0,1 8/10/2020,336.42,337.15,334.33,336.96,333.9242529,2222132,0,1 8/7/2020,334.6,336.18,333.6507,335.95,332.9233523,3050296,0,1 8/6/2020,332.85,335.81,332.48,335.71,332.6855145,3301089,0,1 8/5/2020,332.83,333.7,332.52,333.45,330.4458753,2435103,0,1 8/4/2020,329.19,331.4,329.19,331.3,328.3152451,3581597,0,1 8/3/2020,329.66,330.93,329.0639,330.11,327.1359661,2835276,0,1 7/31/2020,327.21,327.89,322.63,327.82,324.8665972,4683442,0,1 7/30/2020,323.19,325.71,320.9,325.26,322.3296608,3287164,0,1 7/29/2020,323.41,327.015,323.36,326.38,323.4395705,2339925,0,1 7/28/2020,323.67,324.93,322.14,322.5,319.5945263,2513072,0,1 7/27/2020,322.89,324.69,322.0595,324.5,321.5765078,3434018,0,1 7/24/2020,322
Answered Same DayJul 09, 2021

Answer To: Python / Jupyter – Assignment 2 Assignment 2.1 - Scalar variables, templating and datetimes¶ ·...

Neha answered on Jul 09 2021
143 Votes
87731 - python/assignment 2.1.py
import math
sales = "9589220.12"
commission_rate = "0.13456999"
def as_currency(sales):
sales = float(sales)
truncA = math.trunc(sales)
print(f"$
{truncA:,}")
as_currency(sales)
commission_rate = float(commission_rate)
print(f"{commission_rate:.3f}%")
87731 - python/assignment 2.2.py
travel_destinations = ['Italy', 'France', 'Australia', 'Germany', 'China']
new_list = travel_destinations[3:5]
print(new_list)
travel_destinations.insert(0, "South Africa")
print(travel_destinations)
travel_destinations.remove('Germany')
print(travel_destinations)
travel_destinations.sort(reverse=True)
print(travel_destinations)
87731 - python/assignment 2.3.py
gamedict = {'Soccer': 1, 'Football': 3, 'Tennis': 7,'Basketball':2}
gamedict['Rugby'] = 9
print(gamedict)
gamedict.pop('Football')
print[gamedict]
87731 - python/assignment 2.4.py
def as_currency(amount):
currency = "${:,.2f}".format(amount)
print(currency)
amount = 250
rate = 3
time = 10
si = (amount * time * rate)/100
as_currency(si)
country_list = ['Italy', 'France', 'Australia', 'Germany', 'China']
print(bool('Bulgaria'))
print(bool('China'))
87731 - python/assignment 2.5.py
import numpy as np
experience = [4, 7, 23, 9, 10]
output = np.sqrt(experience)
print(output)
log = np.log(experience)
print(log)
#the log and prod will not execute. For log we need to provide value with which we
#can calculate log. The product can be calculated between two elements so it
#will provide error.
87731 - python/assignment 2.6.py
import csv
import pandas as pd

df = pd.read_csv("dailyadjustedivv.csv")
print(df)
letters = df.close.to_list()
print(letters)
mean = sum(letters) / len(letters)
print("Mean is :", mean)
variance = sum([((x - mean) ** 2) for x in letters]) / len(letters)
res = variance ** 0.5

print("Standard deviation of sample is : " + str(res))
print(df.quantile(.2, axis = 0))
87731 -...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here