CS1301 – Important Solved

$ 20.99
Category:

Description

3. This is an individual assignment. Collaboration is encouraged, but your submission must be uniquely yours.
4. For Help:
● How to Think Like a Computer Scientists
● [ http://openbookproject.net/thinkcs/python/english3e / ]
● CS 1301 Python Debugging Guide
● [http://www.cc.gatech.edu/classes/AY2016/cs1301_spring/CS-1301-Deb u gging-Guide/index.html ]

6. Comment out or delete all your function calls. Only import statements, global variables, and comments are okay to be outside the scope of a function.
7. Read the entire document before starting this assignment.

Introduction

Print vs Return

function, thus allowing you to either save it for later, use it in a more complex expression, or print it for human consumption. Important note to remember: print is for the user whereas return is for the program.

Example:
Let’s say we have the following two functions below in a file called file.py:

def printFunc():
print(2)

def returnFunc():
return 2

This is what would happen if we ran the file, and typed the following into the python shell.

>>> a = printFunc()
2
>>> print(a)
None

# notice that although the number 2 is printed to the screen the
# (NoneType)

>>> b = returnFunc()
>>> print(b)
2
# when we call returnFunc() and assign it to a variable, nothing is
# printed to the screen because there are no print statements inside # the function
# however the variable, b, now holds the value 2 (int)

PART 1: FUNCTIONS

Function name: co2emissions()
Parameters: number of trolleys (int), number of buses (int), number of cars (int) Returns: string

Test Cases:
>>> co2emissions(1,0,0)
Great

>>> co2emissions(0,0,3) Bad!!

Function name: supportRally()
Parameters: percent of decided students who support your idea (float), percent of total students who are undecided (float), desired_level(str)
Returns: string or float
Description:

‘Outstanding support’ >= 90.0
‘Significant support’ >= 80.0
‘Moderate support’ >= 70.0

Return the float value of the minimum percentage of students at the rally you need to convince in order to achieve your desired support level rounded to 2 decimal places. If achieving the desired level of support requires a percent surpassing 100.0, return ‘Not possible’.

Test Cases:

## With 93% percent of the decided student body already supporting you, you need to convince 84.89% of the 37% of students that are undecided in order to reach the 90.0% total support level.

>>> supportRally(0.93, 0.37, ‘Outstanding support’)
84.89

## With 70.2% percent of the decided student body already supporting you, it is not possible to reach the 90.0% total support level with only 15.4% of students being undecided.

>>> supportRally(0.702, 0.154, ‘Significant support’) ‘Not Possible’

Function name: isRallySuccessful()
Parameters: level of evidence (int), percent of decided students who support your idea (float), percent of total students who are undecided (float), desired_level(str)
Returns: boolean

Test Cases:
>>> isRallySuccessful(5, 0.88, 0.2, ‘Significant support’)
False

>>> isRallySuccessful(7, 0.91, 0.25, ‘Outstanding support’) True

Function name: spreadingFire()
Parameters: square miles on fire (int), endangerment limit (int)
Returns: string
Description: More fires are starting to pop up in the forests of California. Given the square miles of fire and the endangerment limit (the number of square miles that are on fire that poses risk), write a function to determine which kind of extinguishing method should be employed. For every 100 square miles over the endangerment limit, the danger level increases by 1. For each case, return the danger level and extinguishing method. If the danger level is between 1 and 4, the extinguishing method is “Firebreak and Airdrop.” If the danger level surpasses 4, return “Evacuate and Full Protocol”. If the square miles of fire is less than 100 miles over the endangerment level, return “Proceed with caution”. Note: Danger Level does not go below 0.
For example, if a fire had burned 250 square miles in a forest with a 50 square mile endangerment level, the danger level would be 2, and the function would return “Danger Level: 2; Firebreak and Airdrop”.

Test Cases:
>>> spreadingFire(250, 50)
‘Danger Level: 2; Firebreak and Airdrop’

>>> spreadingFire(775, 35)
‘Danger Level: 7; Evacuate and Full Protocol’

Function name: recycle()
Parameters: number of soda bottles (int), number of grocery bags (int), number of plastic forks (int), number of bottle caps (int)
Returns: string
Description: You and your friends are walking on the beach, and sadly, you see plastic all over the shore. You decide to pick up all of the plastic so you can recycle it! However, before you can recycle it, it needs to be sorted.

You will group all of the items you find by their Type of Plastic. Then you will need to determine the number of items and total weight for each Type of Plastic category. (See Rules for Sorting) After you have finished sorting, the recycling center asks that you bag all of the items. The recycling center provides you with three different bags, each determined by the type of plastic, number of items for each type, and total weight. (See Rules for Bagging) You want to count the final number of items in each bag and print them out in the following format: “Green: (num of items), Yellow: (num of items), Red: (num of items)”

Rules for Sorting:

Rules for Bagging:
Green Bag: Type: PETE, Number of Items: < 5, Total Weight: > 60 grams
Type: PP, Number of Items: > 10, Total Weight: > 60 grams

Yellow Bag: Type: PETE, Number of Items: > 5, Total Weight: > 60 grams
Type: HDPE (All)
Type: PP, Total Weight: < 60 grams

Red Bag: Type: PETE , Total Weight: < 60 grams
Type: PP, Number of Items: < 10, Total Weight: > 60 grams

Test Cases:
>>> recycle(2,1,0,1)
Green:2, Yellow:2, Red:0

>>> recycle(1,0,3,3)
Green:0, Yellow:6, Red:1

Grading Rubric

co2emissions: 15 pts supportRally: 20 pts isRallySuccessful: 15 pts spreadingFire: 25 pts recycle: 25 pts
__________________________________________________
Total 100 pts

Provided

The following file(s) have been provided to you.

1. HW02.py
This is the file you will edit and submit to GradeScope. All instructions for what the functions should do are in the docstrings.

Deliverables

1. HW02.py

@gatech.edu) & Brae (bdavies34@gatech.edu)

Reviews

There are no reviews yet.

Be the first to review “CS1301 – Important Solved”

Your email address will not be published. Required fields are marked *