Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »
Python / Jupyter – Assignment 2
Assignment 2.1 - Scalar variables, templating and datetimes¶
· create the following variables:
sales = " XXXXXXXXXX"
commission_rate = " XXXXXXXXXX"
· Convert sales to a float, and print it as a string with a preceeding $ sign and comman separation every 000s using the as_cu
ency 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 orde
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_cu
ency 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 co
sponding 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 e
or messages occu
·
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, XXXXXXXXXX,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, XXXXXXXXXX,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, XXXXXXXXXX,370.31,370.31,2040697,0,1
12/23/2020, XXXXXXXXXX,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, XXXXXXXXXX,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, XXXXXXXXXX,4501555,0,1
12/10/2020,366.75,369.214,365.811,368.08, XXXXXXXXXX,3151144,0,1
12/9/2020,372.28,372.42,367.325,368.28, XXXXXXXXXX,3758194,0,1
12/8/2020,369.07,372.16,369.06,371.53, XXXXXXXXXX,3491095,0,1
12/7/2020,370.43,370.99,369.12,370.5, XXXXXXXXXX,3162331,0,1
12/4/2020,368.68,371.2, XXXXXXXXXX,371.19, XXXXXXXXXX,4091844,0,1
12/3/2020, XXXXXXXXXX, XXXXXXXXXX,366.88,368.03, XXXXXXXXXX,3068483,0,1
12/2/2020,366.16,368.27,365.55,368.1, XXXXXXXXXX,4121854,0,1
12/1/2020,366.9,368.99,366.27,367.32, XXXXXXXXXX,3664972,0,1
11/30/2020,364.18,364.39,360.5,363.32, XXXXXXXXXX,4093350,0,1
11/27/2020,365.19,365.52,363.97,364.98, XXXXXXXXXX,1354562,0,1
11/25/2020,364.4,364.48,362.8,363.99, XXXXXXXXXX,3826470,0,1
11/24/2020,361.52,365.1, XXXXXXXXXX,364.51, XXXXXXXXXX,3512360,0,1
11/23/2020,358.65,360.05,356.17,358.77, XXXXXXXXXX,2728517,0,1
11/20/2020,358.79,359.04,356.53,356.63, XXXXXXXXXX,2697897,0,1
11/19/2020,356.845,359.5,355.49,359.04, XXXXXXXXXX,3321607,0,1
11/18/2020,362.21,362.82,357.53,357.59, XXXXXXXXXX,3179144,0,1
11/17/2020,361.27,363.24,359.69,361.95, XXXXXXXXXX,2656620,0,1
11/16/2020,362.34,363.87,360.93,363.8, XXXXXXXXXX,3332428,0,1
11/13/2020,356.52,360.188,355.99,359.34, XXXXXXXXXX,2685415,0,1
11/12/2020,356.85,357.69,352.54,354.52, XXXXXXXXXX,3794928,0,1
11/11/2020,357.66,358.86, XXXXXXXXXX,357.93, XXXXXXXXXX,2485781,0,1
11/10/2020,354.77,356.42, XXXXXXXXXX,355.37, XXXXXXXXXX,5174082,0,1
11/9/2020,365.29,365.69,355.34,355.83, XXXXXXXXXX,9109230,0,1
11/6/2020,351.17,352.76,348.95,351.44, XXXXXXXXXX,2871848,0,1
11/5/2020,350.54,353.445, XXXXXXXXXX,351.47, XXXXXXXXXX,6900518,0,1
11/4/2020,342.07,349.19,340.74,344.73, XXXXXXXXXX,6499142,0,1
11/3/2020,334.86,339.43,334.35,337.28, XXXXXXXXXX,6559410,0,1
11/2/2020,331.38, XXXXXXXXXX,328.38,331.36, XXXXXXXXXX,4658487,0,1
10/30/2020,329.42,330.82,323.72,327.62, XXXXXXXXXX,6634052,0,1
10/29/2020,328.1,334.54,326.26,331.15, XXXXXXXXXX,5163505,0,1
10/28/2020,333.24,334,327.3,327.88, XXXXXXXXXX,7096185,0,1
10/27/2020, XXXXXXXXXX,341.3,339.16,339.43, XXXXXXXXXX,4227596,0,1
10/26/2020,343.32,344.19,336.81,340.59, XXXXXXXXXX,4327232,0,1
10/23/2020,347.164,347.19,344.36,346.96, XXXXXXXXXX,1796836,0,1
10/22/2020,344.2,346.45,341.88,345.86, XXXXXXXXXX,2461179,0,1
10/21/2020,344.52,346.79,343.63,343.9, XXXXXXXXXX,3689177,0,1
10/20/2020,344.67,348.1,343.89,344.57, XXXXXXXXXX,2816247,0,1
10/19/2020,349.88,350.52, XXXXXXXXXX,343.22, XXXXXXXXXX,2973436,0,1
10/16/2020,350.27,351.97,348.34,348.45, XXXXXXXXXX,2768044,0,1
10/15/2020,344.92,349.24,344.31,348.76, XXXXXXXXXX,3021176,0,1
10/14/2020,351.95,353.085,348.37,349.19, XXXXXXXXXX,2373076,0,1
10/13/2020,353.51,353.6,350.33,351.39, XXXXXXXXXX,2664589,0,1
10/12/2020,350.78,355.25,350.28,353.69, XXXXXXXXXX,2301131,0,1
10/9/2020,346.79,348.54,346.09,348.01, XXXXXXXXXX,3377059,0,1
10/8/2020,344.07,345.03,343.06,344.98, XXXXXXXXXX,4166927,0,1
10/7/2020,339.28,342.8,339.28,341.9, XXXXXXXXXX,3121992,0,1
10/6/2020,341.13,343.35,335.56,336.06, XXXXXXXXXX,3934679,0,1
10/5/2020,337.21,341.12,337.2,340.9, XXXXXXXXXX,3208467,0,1
10/2/2020,332.82,337.09,332.385,335.05, XXXXXXXXXX,4092570,0,1
10/1/2020,338.83,339.87,336.18,338.24, XXXXXXXXXX,3381645,0,1
9/30/2020,334.34, XXXXXXXXXX,334.1,336.06, XXXXXXXXXX,4750895,0,1
9/29/2020,335.21,335.895,332.78,333.51, XXXXXXXXXX,2540790,0,1
9/28/2020,334.36,336.1,333.31,335.36, XXXXXXXXXX,3411162,0,1
9/25/2020,323.74,330.71,322.75,329.88, XXXXXXXXXX,4178642,0,1
9/24/2020, XXXXXXXXXX,327.9,320.92,324.6, XXXXXXXXXX,4232095,0,1
9/23/2020,332.09,332.38,323.22,323.75, XXXXXXXXXX,4366063,1.5058,1
9/22/2020, XXXXXXXXXX,333.57,328.5,332.97, XXXXXXXXXX,2864816,0,1
9/21/2020,328.42,329.74,324.35,329.63, XXXXXXXXXX,6177811,0,1
9/18/2020,338.17,338.21,330.64,333.34, XXXXXXXXXX,3204653,0,1
9/17/2020,334.94,339.01,334.341,337.29, XXXXXXXXXX,3097858,0,1
9/16/2020,342.95,344.47,339.95,340.21, XXXXXXXXXX,2453201,0,1
9/15/2020,342.52,343.42, XXXXXXXXXX,341.57, XXXXXXXXXX,2553912,0,1
9/14/2020,338.86,341.66,338.32,339.84, XXXXXXXXXX,2830727,0,1
9/11/2020,337.12,338.27,332.35,335.38, XXXXXXXXXX,3490163,0,1
9/10/2020,343.26,343.91,334.21,335.22, XXXXXXXXXX,5060220,0,1
9/9/2020,338.98,343.89,337.98,341.18, XXXXXXXXXX,5378531,0,1
9/8/2020,338.05,339.4,334.23,334.63, XXXXXXXXXX,5003489,0,1
9/4/2020,347.6,349.29,336.26,343.98, XXXXXXXXXX,5359409,0,1
9/3/2020,357.38, XXXXXXXXXX,344.02,346.82, XXXXXXXXXX,7771371,0,1
9/2/2020,356.18,360.26,354.93,359.24, XXXXXXXXXX,3596614,0,1
9/1/2020,351.68,354.18,350.7,354.06, XXXXXXXXXX,3700409,0,1
8/31/2020,351.81,352.77,350.51,350.77, XXXXXXXXXX,5757749,0,1
8/28/2020,350.89,352.19,349.66,352, XXXXXXXXXX,2520823,0,1
8/27/2020,349.66,351.32,347.98,349.76, XXXXXXXXXX,3767591,0,1
8/26/2020,346.11,349.27,345.58,349, XXXXXXXXXX,3674797,0,1
8/25/2020,344.96,345.6,343.711,345.49, XXXXXXXXXX,4004390,0,1
8/24/2020,343.52,344.42,342.45,344.35, XXXXXXXXXX,2083972,0,1
8/21/2020,339.23,341.05,338.95,340.85, XXXXXXXXXX,2063327,0,1
8/20/2020,336.73, XXXXXXXXXX,336.59,339.66, XXXXXXXXXX,1804711,0,1
8/19/2020,340.4,340.999,338.02,338.62, XXXXXXXXXX,1911489,0,1
8/18/2020,339.72,340.46,337.98,340, XXXXXXXXXX,1634618,0,1
8/17/2020,339.32,339.72,338.87,339.28, XXXXXXXXXX,1630600,0,1
8/14/2020, XXXXXXXXXX,338.79,337.05,338.19, XXXXXXXXXX,1716097,0,1
8/13/2020,338,339.615,337.18,338.22, XXXXXXXXXX,2643209,0,1
8/12/2020,336.85, XXXXXXXXXX,336.8,338.8, XXXXXXXXXX,2907862,0,1
8/11/2020,338.24,338.88,333.38,334.14, XXXXXXXXXX,3603710,0,1
8/10/2020,336.42,337.15,334.33,336.96, XXXXXXXXXX,2222132,0,1
8/7/2020,334.6,336.18, XXXXXXXXXX,335.95, XXXXXXXXXX,3050296,0,1
8/6/2020,332.85,335.81,332.48,335.71, XXXXXXXXXX,3301089,0,1
8/5/2020,332.83,333.7,332.52,333.45, XXXXXXXXXX,2435103,0,1
8/4/2020,329.19,331.4,329.19,331.3, XXXXXXXXXX,3581597,0,1
8/3/2020,329.66,330.93, XXXXXXXXXX,330.11, XXXXXXXXXX,2835276,0,1
7/31/2020,327.21,327.89,322.63,327.82, XXXXXXXXXX,4683442,0,1
7/30/2020,323.19,325.71,320.9,325.26, XXXXXXXXXX,3287164,0,1
7/29/2020,323.41,327.015,323.36,326.38, XXXXXXXXXX,2339925,0,1
7/28/2020,323.67,324.93,322.14,322.5, XXXXXXXXXX,2513072,0,1
7/27/2020,322.89,324.69, XXXXXXXXXX,324.5, XXXXXXXXXX,3434018,0,1
7/24/2020,322
Answered Same Day Jul 09, 2021

Solution

Neha answered on Jul 09 2021
145 Votes
87731 - python/assignment 2.1.py
import math
sales = "9589220.12"
commission_rate = "0.13456999"
def as_cu
ency(sales):
sales = float(sales)
truncA = math.trunc(sales)
print(f"${truncA:,}")
as_cu
ency(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_cu
ency(amount):
cu
ency = "${:,.2f}".format(amount)
print(cu
ency)
amount = 250
ate = 3
time = 10
si = (amount * time * rate)/100
as_cu
ency(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 e
or.
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)
es = 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