Wednesday, February 26, 2020

Shame on Google - Can't Even Get Factorial Right..

It just gets worse..

And worser.. WT*? What are they trying to prove? A one liner has been made a freaking paragraph!

Problem : The pretty_address function separates out parts of the address string into new strings: house_number and street_name, and returns: "house number X on street named Y". The format of the input string is: numeric house number, followed by the street name which may contain numbers, but never by themselves, and could be several words long. For example, "123 Philly Ave", "1001 3rd St", or "55 North Ferst Blvd". Fill in the gaps to complete this function.

def pretty_address(address):
  # Declare variables

  # Separate the address string into parts
  words = address.split()

  # Traverse through the address parts
#  for __:
    # Determine if the address part is the
    # house number or part of the street name

  # Does anything else need to be done
  # before returning the result?
 
  # Return the formatted string 
  return "house number {} on street named {}".format(" ".join(<censored>) , words[duh!] )

print(pretty_address("456 Castler Street"))
# Should print: "house number 456 on street named Castler Street"


asdf. Another one that got my temperature up. Problem? A failure to address or play to the student's curiosity. Think about how ridiculous this is - you have two classes of clothing - shirts and pants and they're both inheriting from Clothing - so far so good. Clothing keeps track of the entire population - hence assigning to CNAME.varName rather than self.varName. Good.

But then, when you want information about the entire population - in this case, the total stock of Cotton, you go through a particular class of clothing - how ridiculous is that? Or sick?

For the current_stock = , you can use either polo or sweatpants - which shows up another QA fail - why is one singular and the other plural?

class Clothing:
  stock={ 'name': [],'material' :[], 'amount':[]}
  def __init__(self,name):
    material = ""
    self.name = name
  def add_item(self, name, material, amount):
    Clothing.stock['name'].append(self.name)
    Clothing.stock['material'].append(self.material)
    Clothing.stock['amount'].append(amount)
  def Stock_by_Material(self, material):
    count=0
    n=0
    for item in Clothing.stock['material']:
      if item == material:
        count += Clothing.stock['amount'][n]
        n+=1
    return count

class shirt(Clothing):
  material="Cotton"
class pants(Clothing):
  material="Cotton"
 
polo = shirt("Polo")
sweatpants = pants("Sweatpants")
polo.add_item(polo.name, polo.material, 4)
sweatpants.add_item(sweatpants.name, sweatpants.material, 6)
current_stock = sweatpants.Stock_by_Material("Cotton")
print(current_stock)


That's not enough.. More evidence that either Google's or Coursera's QA dept is asleep (highlighted) :

class Zoo:
    def __init__(self):
        self.current_animals = {}
   
    def add_animal(self, animal):
        self.current_animals[animal.name] = animal.category
   
    def total_of_category(self, category):
        result = 0
        for animal in self.___.values():
            if self.____ == category:
                result += 1
        return result
zoo = Zoo()
 

No comments: