Question: 2) We've been talking a bit recently about what makes good code and what makes a code smell or not 'clean code'. a) 20pts) The

 2) We've been talking a bit recently about what makes goodcode and what makes a "code smell or not 'clean code'. a)

2) We've been talking a bit recently about what makes good code and what makes a "code smell or not 'clean code'. a) 20pts) The code below is smelly all right. Tell me everything that is wrong with it, especially in light of what we have talked about in class. def. nl first half (self) questionl - input("Does your team's state begin with a letter from A-M? (y): *) while not (question. lower().startswith('y') or question1. lower().startswith('n')): print("Please answer 'yes' or 'no'.") questionl - input ("Does your team's state begin with a letter from A-M? (y): ") if question1. lower().startswith('y'): self.nl_teams = self.nl_teams[:8] #remove the last half print (self.nl teams) question2 - input("Does your team's logo have a lot of red? (y): ") while not (question2. lower().startswith('y') or question2. lower().startswith('n')): print("Please answer 'yes' or 'no'.") question2 - input ("Does your team's logo have a lot of red? (y): ") if question2. lower().startswith('y'): self.nl_teams - self.nl_teams[:4] * remove the last half of the remaining print(self.nl_teams) question3 - input("Does your team's state start with the letter 'A'? (y): ") while not (question3.lower().startswith('y') or question3.lower().startswith('n')): print("Please answer 'yes' or 'no'.) question3 - input ("Does your team's state start with the letter 'A'? (y): ") if question3.lower().startswith('y'): self.nl_teams = self.nl_teams[:2] #remove the last half of the remaining teams print (self.nl_teams) question4 = input("Is your team the Braves? (y): ") while not (question. lower().startswith("y') or question.lower().startswith('n')): print("Please answer 'yes' or 'no'.") question4 - input("Is your team the Braves? (y): ") if question4. lower().startswith('y'): self.nl_teams = self.nl_teams[-1:] #keep the braves print("your team is the braves") print(self.nl_teams) else: self.nl_teams = self.nl_teams[:1] #keep the diamondbacks print("your team is the Diamondbacks!") print(self.nl_teams) else: #if it doesn't begin with 'A' self.nl_teams = self.nl_teams (-2:] print(self.nl_teams) print(self.nl teams) questions - input("is your team the Cubs? (y): ") while not (questions. lower().startswith('y') or question5. lower().startswith('n')): print("Please answer 'yes' or 'no'.") questions - input("is your team the Cubs? (y): -) if questions. lower().startswith('y'): self.nl teams = self.nl teams[:1] print("your team is the cubs") print(self.nl_teams) else: self.nl_teams = self.nl_teams [-1:] print("your team is the Reds") print(self.nl_teams) else: self.nl_teams = self.nl_teams[ -4:] print(self.nl_teams) question6 = input ("Does your team's state start with the latter 'M'? (y): "); while not (question. Lower().startswith('y') or question6. lower().startswith('n')): B) (20pts) refactor this code (ok gk it is so terrible it might be a rewrite) to do the same thing, but follow the rules of thumb for clean code a bit better. 2) We've been talking a bit recently about what makes good code and what makes a "code smell or not 'clean code'. a) 20pts) The code below is smelly all right. Tell me everything that is wrong with it, especially in light of what we have talked about in class. def. nl first half (self) questionl - input("Does your team's state begin with a letter from A-M? (y): *) while not (question. lower().startswith('y') or question1. lower().startswith('n')): print("Please answer 'yes' or 'no'.") questionl - input ("Does your team's state begin with a letter from A-M? (y): ") if question1. lower().startswith('y'): self.nl_teams = self.nl_teams[:8] #remove the last half print (self.nl teams) question2 - input("Does your team's logo have a lot of red? (y): ") while not (question2. lower().startswith('y') or question2. lower().startswith('n')): print("Please answer 'yes' or 'no'.") question2 - input ("Does your team's logo have a lot of red? (y): ") if question2. lower().startswith('y'): self.nl_teams - self.nl_teams[:4] * remove the last half of the remaining print(self.nl_teams) question3 - input("Does your team's state start with the letter 'A'? (y): ") while not (question3.lower().startswith('y') or question3.lower().startswith('n')): print("Please answer 'yes' or 'no'.) question3 - input ("Does your team's state start with the letter 'A'? (y): ") if question3.lower().startswith('y'): self.nl_teams = self.nl_teams[:2] #remove the last half of the remaining teams print (self.nl_teams) question4 = input("Is your team the Braves? (y): ") while not (question. lower().startswith("y') or question.lower().startswith('n')): print("Please answer 'yes' or 'no'.") question4 - input("Is your team the Braves? (y): ") if question4. lower().startswith('y'): self.nl_teams = self.nl_teams[-1:] #keep the braves print("your team is the braves") print(self.nl_teams) else: self.nl_teams = self.nl_teams[:1] #keep the diamondbacks print("your team is the Diamondbacks!") print(self.nl_teams) else: #if it doesn't begin with 'A' self.nl_teams = self.nl_teams (-2:] print(self.nl_teams) print(self.nl teams) questions - input("is your team the Cubs? (y): ") while not (questions. lower().startswith('y') or question5. lower().startswith('n')): print("Please answer 'yes' or 'no'.") questions - input("is your team the Cubs? (y): -) if questions. lower().startswith('y'): self.nl teams = self.nl teams[:1] print("your team is the cubs") print(self.nl_teams) else: self.nl_teams = self.nl_teams [-1:] print("your team is the Reds") print(self.nl_teams) else: self.nl_teams = self.nl_teams[ -4:] print(self.nl_teams) question6 = input ("Does your team's state start with the latter 'M'? (y): "); while not (question. Lower().startswith('y') or question6. lower().startswith('n')): B) (20pts) refactor this code (ok gk it is so terrible it might be a rewrite) to do the same thing, but follow the rules of thumb for clean code a bit better

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!