Git Product home page Git Product logo

cssi-prework-dictionary-lab's Introduction

Basketball Stats

Overview

Dictionaries offer an organized way to store a lot of information because of the way that each value can be accessed by a unique key. Many of the APIs you'll be working with send data in the form of nested arrays and dictionaries. Being comfortable iterating through nested data structures will allow you to access and manipulate data from a variety of sources.

Instructions

In this lab, we've gotten a bunch of data from the Yahoo Sports API. There is a nested dictionary in basketball_info.py that defines a game, with two teams, their players, and the players' stats.

Using the power of Python and the game dictionary in basketball_info.py, write functions in basketball.py to complete the following:

  1. Return the name of the home team and the away team. We've done this one for you to get started.

  2. Return a team's colors, as a string: Black and Red or Green and White

    These next two functions will challenge you to iterate over a dictionary while being mindful of punctuation.

  3. Return the points scored by each player on a team. There should be a ' - ' between each player and their points. A comma and a space should separate each name. The whole string should end with a period.

To do this, you'll want to loop through the player and points and use .format to get the dash and comma. Name - Points, Name2 - Points2,. Then at the end of the iteration, you can manipulate the string to delete the last comma and instead add a period.

>>> print player_points('Chicago Bulls')
Michael Jordan - 28 pts, Scottie Pippen - 22 pts, Dennis Rodman - 18 pts, Tony Kukoc - 20 pts, Ron Artest - 12 pts.
  1. Return all the stats for a player, given a player's team and name. Notice that each stat (except for the last) is separated by a new line \n.
>>> print player_stats('Chicago Bulls', 'Scottie Pippen')
Name: Michael Jordan
Slam_dunks: 4
Number: 23
Points: 28
Shoe: 15
Steals: 5
  1. Given a team and a player's name, return that player's shoe size. Hint: try finding the player first (the same way you did with player_stats) then look for his shoe size.

  2. For a given team, find the player with the largest shoe size and return their number of steals.

cssi-prework-dictionary-lab's People

Contributors

nanselmo avatar annjohn avatar zspann avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.