Answered step by step
Verified Expert Solution
Question
1 Approved Answer
{ cells: [ { cell_type: markdown, metadata: {}, source: [ Scraping Fidelity.com , In this exercise, you scrape data from fidelity.com. The goal is
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
Scraping Fidelity.com
", "In this exercise, you scrape data from fidelity.com. The goal is to get the latest sector performance data from the US markets, and to get the total market capitalization for each sector. ", " ", "You need to write one function: get_us_sector_performance() that will return a list of tuples. Each tuple should correspond to a sector and should contain the following data: ", "", "The data should be sorted by decreasing order of market weight. I.e., the sector with the highest weight should be in the first tuple, etc." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
Process
", "Sorting
" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = [('a',23.2,'b'),('c',17.4,'f'),('d',29.2,'z'),('e',1.74,'bb')] ", "x.sort() #Sorts by the first element of the tuple ", "x" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x = [('a',23.2,'b'),('c',17.4,'f'),('d',29.2,'z'),('e',1.74,'bb')] ", "x.sort(key=lambda k: k[1]) #Sorts by the element at position 1 ", "x" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [py36]", "language": "python", "name": "Python [py36]" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started