02_assignment.py - Assignment#2 1 Add modify code ONLY...

  • No School
  • AA 1
  • 6

This preview shows page 1 - 3 out of 6 pages.

''' Assignment #2 1. Add / modify code ONLY between the marked areas (i.e. "Place code below") 2. Run the associated test harness for a basic check on completeness. A successful run of the test cases does not guarantee accuracy or fulfillment of the requirements. Please do not submit your work if test cases fail. 3. To run unit tests simply use the below command after filling in all of the code: python 01_assignment.py 4. Unless explicitly stated, please do not import any additional libraries but feel free to use built-in Python packages 5. Submissions must be a Python file and not a notebook file (i.e *.ipynb) 6. Do not use global variables 7. Make sure your work is committed to your master branch ''' import math import unittest import numpy as np import requests as r def exercise01(): # Create a list called animals containing the following animals: cat, dog, crouching tiger, hidden dragon, manta ray # ------ Place code below here \/ \/ \/ ------ animals = ['cat', 'dog', 'crouching tiger', 'hidden dragon', 'manta ray'] # ------ Place code above here /\ /\ /\ ------ return animals def exercise02(): # Repeat exercise 1 and loop through and print each item in the animal list by iterating through an index number and using range(). Set the variable len_animals to the length of the animal list. # ------ Place code below here \/ \/ \/ ------ animals = ['cat', 'dog', 'crouching tiger', 'hidden dragon', 'manta ray'] for i in range(len(animals)): print(animals[i]) len_animals=len(animals) # ------ Place code above here /\ /\ /\ ------ return animals, len_animals def exercise03(): # Reorganize the countdown list below in descending order and return the value of the 5th element in the sorted countdown list countdown = [9, 8, 7, 5, 4, 2, 1, 6, 10, 3, 0, -5] the_fifth_element = -999 # ------ Place code below here \/ \/ \/ ------n countdown.sort() countdown.reverse() the_fifth_element=countdown[4]
Image of page 1

Subscribe to view the full document.

# ------ Place code above here /\ /\ /\ ------ return countdown, the_fifth_element def exercise04(more_temperatures, iot_sensor_points, a, b, c, d, e): # This exercise function receives a list of temperatures and a dictionary of temperature data where the key is an arbitrary sequential number and the value is the temperature and a,b,c,d and e are each a single temperature reading # To Do: # 1. Add all of the items in more_temperatures to the temperatures list
Image of page 2
Image of page 3
  • Fall '19
  • Menu bar

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes