Chat with us, powered by LiveChat No.1:  The following dictionary of dates and stock prices is defined in the scaffold below: prc_dic = { ˜3000-01-15™: | Wridemy

No.1:  The following dictionary of dates and stock prices is defined in the scaffold below: prc_dic = { ˜3000-01-15™:

No.1: 

The following dictionary of dates and stock prices is defined in the scaffold below:

prc_dic = { ‘3000-01-15’: 7.0400, 
 ’2020-01-14′: 7.1100, 
 ’2020-01-13′: 7.0200, 
 ’2020-01-02′: 7.1600, 
 ’2020-01-03′: 7.1900, 
 ’2020-01-06′: 7.0000, 
 ’2020-01-07′: 7.1000, 
 ’2020-01-08′: 6.8600, 
 ’2020-01-09′: 6.9500, 
 ’2020-01-10′: 7.0000, 
}

Given this dictionary:

1. Define a variable sorted_keys that will contains the keys of prc_dic in ascending order. Use a list comprehension to do this in a single line The following references might help:

  • list.sort method : https://docs.python.org/3/library/stdtypes.html#list.sort

  • sorted builtin : https://docs.python.org/3/library/functions.html#sorted

2. Replace the prc_dic key for 3000-01-15 with 2020-01-15. Do this in one line and without explicitly writing the value 7.0400.

No.2:

All you need to do is to submit the contents of the yf_example3.py module, which you will create during this code challenge. We will provide you with a solution to this challenge later.

Coding (in PyCharm)

For this code challenge, you will create a new module under the toolkit project folder. This module will be called yf_example3.py. The purpose of this module is to download stock price data for Qantas for a given year and save the information in a CSV file. Follow the steps below to create this module.

Note: When marking this module, we will not consider the docstrings you create. Although the docstrings will not be marked, please create both a module docstring and a function docstring.

The diagram below presents the location of the relevant files and folders:

toolkit/ <– PyCharm project folder | |__ toolkit_config.py <– Configuration module |__ yf_example2.py <– You have already created this module |__ yf_example3.py <– The new module |__ data/ <– Folder where the data will be saved

Follow the steps below to create and run this module.

  • Create a new module, calledyf_example3.py,inside thetoolkit project folder. Open this module in PyCharm.

  • Write a simple module docstring containing the name of the module and a once sentence summarising its purpose. This docstring will not be marked.

  • Create the import statements. This module should import:

    • The os module

    • The toolkit_config module. This module should be imported under the alias cfg

    • The yf_example2 module (see location in the diagram above) without an alias

  • Define the function qan_prc_to_csv with its parameter and docstring (the docstring will not be marked):

    • This function takes a single (mandatory) parameter called year, an integer.

    • Purpose: Download Qantas stock prices for a given year into a CSV file

    • The name of this file will be qan_prc_YYYY.csv, where the YYYY stands for the year in year.

    • This file will be saved under the data folder. Remember that the location of this folder is already in the toolkit_config module.

  • Complete the body of this function so that qan_prc_to_csv making sure that it uses the yf_example2.yf_prc_to_csv to download only the prices from January 1 to December 31 of the year in year. The location of the CSV file should be determined inside the function.

  • Include the if __name__ == "__main__" statement at the end of the module and include a test case (or example). This test case will download the data for year=2020.

  • Run the module and examine the downloaded data

Below is a step by step description of what should happen when you call the function qan_prc_to_csv(year=2020) inside this module:

  • Variables with the start and ending period for the yf_example2.yf_prc_to_csv are created inside the function. In this case, the period is from 2020-01-01 to 2020-12-31.

  • Download the data for this period and tic='QAN.AX'.

  • Create the name of the output file. In this case, qan_prc_2020.csv.

  • Create a path variable making sure that this file will be inside the datafolder.

  • Save the downloaded data.


Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Wridemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order

Related Tags

Academic APA Writing College Course Discussion Management English Finance General Graduate History Information Justify Literature MLA