Starting from:

$29.99

CS1301 Homework 4 - Strings, Indexing, & Lists Solution

How to Think Like a Computer Scientist
CS 1301 YouTube Channel
Comment out or delete all function calls. Only import statements, global variables, and comments are okay to be outside of your functions.
Read the entire document before starting this assignment.
The goal of this homework is for you to enhance your understanding of strings, indexing, and lists. The homework will consist of 5 functions for you to implement. You have been given
HW04.py skeleton file to fill out. However, below you will find more detailed information to complete your assignment. Read it thoroughly before you begin.
Hidden Test Cases: In an effort to encourage debugging and writing robust code, we will be including hidden test cases on Gradescope for some functions. You will not be able to see the input or output to these cases. Below is an example output from a failed hidden test case:

Written by Alexa O'Reilly (aoreilly@gatech.edu) & Brian Chuo (bchuo3@gatech.edu) & Craig Nyazema (cnyazema3@gatech.edu)
Find the Maximum
Function Name: findMax()
Parameters: list of numbers ( list ), start index ( int ), stop index ( int )
Returns: highest number ( int )
Description: Write a function that finds (and returns) to highest number in the list in between the two indices given. The start index and stop index are both inclusive and will always be in range. Assume there will be no repeats in the list.



Fruit Pie
Function Name: fruitPie()
Parameters: fruits ( list ), minimum quantity ( int )
Returns: fruits for pie ( list )
Description: You are tired of eating take-out and decide to get some fruit to make some pies. However, when you get to the store, you see a bunch of different types of fruit in different quantities and need to figure out which fruit has enough supply to make a pie! Write a function that takes in a list of fruit and their quantities and figures out which types of fruit have quantities greater than or equal to the minimum quantity passed in. Return a list of these fruits. If the list is empty, return an empty list. The quantities will never be negative.
Note: The list will be formatted as follows:

You can assume that every fruit will be followed by its quantity.


Replace Word
Function Name: replaceWord()
Parameters: initial sentence ( str ), replacement word ( str )
Returns: corrected sentence ( str )
Description: Write a function that takes in a sentence and a replacement word. Every word within the sentence with a length of 5 or greater should be replaced with the replacement word provided.



Highest Sum
Function Name: highestSum()
Parameters: list of strings ( list )
Returns: index of string with the highest sum ( int )
Description: Write a function that takes in a list of strings and computes the sum of the numbers in each string. If a string contains no numbers, the sum of that string is 0. Return the first index of the string with the highest sum.



Sublist
Function Name: sublist()
Parameters: alist ( list ), blist ( list )
Returns: True or False ( bool )
Description: Write a function that checks to see if a blist is a sublist of alist. blist is a sublist of alist if all of its elements are in alist in the same consecutive order. Return whether blist is a sublist of alist. If two lists are equal, they are sublists of one another. Additionally, if a list is empty, it is always a sublist of the other.



Grading Rubric

Function Points
findMax() 15
fruitPie() 20
replaceWord() 20
highestSum() 20
sublist() 25
Total 100
Provided
The HW04.py skeleton file has been provided to you. This is the file you will edit and implement. All instructions for what the functions should do are in this skeleton and this document.
Submission Process

More products