CS_2984_19921_201601
Classwwork 16 - Python
Skip To Content
Dashboard
  • Login
  • Dashboard
  • Calendar
  • Inbox
  • History
  • Help
Close
  • My Dashboard
  • CS_2984_19921_201601
  • Assignments
  • Classwwork 16 - Python
2016 Spring
  • Home
  • Modules
  • Pages
  • Assignments
  • Syllabus
  • Smart Search
  • Facebook Group
  • Class Notebook
  • Portfolium
  • Google Drive
  • Microsoft OneDrive
  • Top Hat
  • VT Library Help
  • Zoom
  • Course Gallery
  • Gradescope
  • Course Evaluations

Classwwork 16 - Python

  • Due Mar 22, 2016 by 11am
  • Points 10
  • Submitting a file upload
  • Available until Apr 19, 2016 at 9:30am
This assignment was locked Apr 19, 2016 at 9:30am.

For the following exercises, and those from the next few days, we have provided you with some starting code in python. Download the .py files and put them in your 'compuational_thinking-f15-1' folder (the one we created on installation). Open the files in spyder, add your name at the top next to the "Author" field and write the code for the exercise in it. Upload the approriate file to each question.

Dictionaries

Problem #1

File: cw-16-q1.py Download cw-16-q1.py

The algorithm in this exercise tries to answer the following question: "What is the price per page of a given book?"

The information necessary to make this calculation is given inside a dictionary that has three keys: "number_of_pages", "price" and a "discount". Put the pieces of this algorithm in the right order, to calculate the appropriate answer.

Problem #2

File: cw-16-q2.py Download cw-16-q2.py

Calculating the average speed during a trip requires knowing the total distance traveled and the amount of time it took to cover it. In this problem the trip data is stored in a dictionary with two keys: "distance" and "time". For scientific purposes the information has been stored in meters and seconds.

The code provided has some of the pieces, which have been scrambled, that you will need to calculate the average speed in miles per hour. Reassemble the lines and complete the code to calculate the average speed.

Problem #3

File: cw-16-q3.py Download cw-16-q3.py

Write a program that answers the following question:<br>Given the current temperature and humidity, what is the current weather like?

Consider the following logic:

  • If the current temperature is below 32 degrees and the humidity is at least 50%, print "snowing".
  • If the current temperature is above 32 degrees and the humidity is at least 50%, print "raining".
  • Otherwise, print "clear".
Fill in the blanks for the dictionary in the code so that you can test your code within the various ranges described above. For the final submission use the following weather: 29, 55 and 13 for temperature, humidity and wind respectively.

Problem #4

File: cw-16-q4.py Download cw-16-q4.py

Use the weather.get_report() block to check whether it is snowing, raining or clear in:

  • Seattle
  • Miami
  • New York
  • Blacksburg
Use the same logic as the problem #3. As the new block also gives us a dictionary you may be able to reuse some of the code you wrote. For your final submission, the code should be checking for the weather in New York only and printing the appropriate status message.

Problem #5

This is a multi-step problem. First we will use spyder's property explorer to analyze the weather.get_forecasted_reports("Blacksburg") block.

  1. Give a short description of what the block returns, using your understanding of lists and dictionaries.
  2. Draw a table representation of the data and describe its abstraction.
Note: Use MS Word or a simliar tool to answer both parts of this question and upload the resulting file. If one of these tools is not available, you may also do this exercise on paper by uploading a picture and turning the sheet in at the end of the class.
1458658800 03/22/2016 11:00am
Please include a description
Additional Comments:
Rating max score to > pts
Please include a rating title

Rubric

Find Rubric
Please include a title
Find a Rubric Links to an external site.
Title
You've already rated students with this rubric. Any major changes could affect their assessment results.
Links to an external site.
 
 
 
 
 
 
 
     
Can't change a rubric once you've started using it.  
Title
Criteria Ratings Pts
This criterion is linked to a Learning Outcome Description of criterion
threshold: 5 pts
Edit criterion description Delete criterion row
5 to >0 pts Full Marks blank
0 to >0 pts No Marks blank_2
This area will be used by the assessor to leave comments related to this criterion.
pts
  / 5 pts
--
Additional Comments
This criterion is linked to a Learning Outcome Description of criterion
threshold: 5 pts
Edit criterion description Delete criterion row
5 to >0 pts Full Marks blank
0 to >0 pts No Marks blank_2
This area will be used by the assessor to leave comments related to this criterion.
pts
  / 5 pts
--
Additional Comments
Total Points: 5 out of 5
Previous
Next

Slides 16 - Abstraction and Data-Structures Homework 16