HW09

.py

School

Georgia Institute Of Technology *

*We aren’t endorsed by this school

Course

1301

Subject

Computer Science

Date

Dec 6, 2023

Type

py

Pages

2

Uploaded by PresidentMoon12744

Report
""" Georgia Institute of Technology - CS1301 Homework 9 - Recursion """ ######################################### """ Function Name: numCoffees() Parameters: num (int) Returns: None (NoneType) """ def numCoffees(num): if num ==0: print("No more coffee!") else: print(f"Coffees left: {num}") numCoffees(num-1) ######################################### """ Function Name: coffeeShopDescrambler() Parameters: scrambledName (str) Returns: shopName (str) """ def coffeeShopDescrambler(scrambledName): if scrambledName == "": return "" else: shopName=coffeeShopDescrambler(scrambledName[:-1]) if scrambledName[-1].isalpha() or scrambledName[-1]==" ": shopName+=scrambledName[-1].lower() return shopName ######################################### """ Function Name: atlCoffee() Parameters: listOfshops (list) Returns: shopsToVisit (dict) """ def atlCoffee(listOfshops): if listOfshops == []: return {} else: shopsToVisit=atlCoffee(listOfshops[1:]) if listOfshops[0][2]>5: name=listOfshops[0][0] area=listOfshops[0][1] if area in shopsToVisit:
shopsToVisit[area].append(name) else: shopsToVisit[area]=[name] shopsToVisit[area].sort() return shopsToVisit ######################################### """ Function Name: balancedOrder() Parameters: order (str) Returns: isBalanced (bool) """ def balancedOrder(order): if len(order)<=1: return True else: if order[0].isupper() == order[-1].isupper(): return balancedOrder(order[1:-1]) else: return False ######################################### """ Function Name: cafeJosh() Parameters: menuItems (list) Returns: finalItem (str) """ def cafeJosh(menuItems): if menuItems==[]: return "" else: finalItems= cafeJosh(menuItems[:-1]) if type(menuItems[-1]) is list: selfstr=cafeJosh(menuItems[-1]) finalItems+=selfstr else: finalItems+=menuItems[-1] return finalItems #########################################
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help