Question: Im trying to make sure this code works against the tests below, please use Python Only!! (My Code) from typing import List class Room: def

Im trying to make sure this code works against the tests below, please use Python Only!! (My Code) from typing import List class Room: def __init__(self, building: str, ro_num: int): self.building = building self.ro_num = ro_num def __str__(self) -> str: return f"{self.building} {self.ro_num}" def same_building(self, other: "Room") -> bool: if self.building == other.building: return True if self.building != other.building: return False def outdoor_passing(classes: List[Room]) -> int: """This should go through a list of Rooms and then show how many times you went out""" if len(classes) == 0: return 0 else: times_out = [] first_class = classes[0] for classes in range(len(classes)): Room.same_building(first_class, classes[1]) if first_class != classes: times_out.append(first_class) first_class = classes return len(times_out)

*** These are the tests it should be able to work for

Test 1

Im trying to make sure this code works against the tests below,

Test 2

please use Python Only!! (My Code) from typing import List class Room:pt2

def __init__(self, building: str, ro_num: int): self.building = building self.ro_num = ro_num

import unittest from mini_exam import * class Test Room(unittest. TestCase): ""Basic tests of the Room class""n def test_str(self): "" "Check the _.str_-magic method"\|" deschutes 243= Room( "Deschutes", 243) as_str =str( deschutes243) self. assertequal (as_str, "Deschutes 243") def test_same_building(self): "u"Different rooms in the same building"n\| straub150 = Room("Straub", 150) straub254 = Room("Straub", 254) self.assertTrue (straub150.same_building(straub254)) self.assertTrue(straub254.same_building(straub150)) self.assertTrue (straub254. same_building(straub254)) def test_diff_building(self): "unRooms in different buildings"m\| deschutes 243= Room ("Deschutes", 243) straub150 = Room ("Straub", 150) self.assertFalse (straub150. same_building (deschutes243)) self. assertFalse (deschutes243.same_building(straub150)) if name == " main " " unittest.main()

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!