Ad
  • Custom User Avatar

    Okay, that works well enough now.

  • Custom User Avatar
  • Custom User Avatar
    @test.it("Safe Buildings")
    def test_second_oldest_first():
        test.assert_equals(earthquake_tracker(1.7, 101), 'Safe')
        test.assert_equals(earthquake_tracker(6.11, 889), 'Safe')
        test.assert_equals(earthquake_tracker(11.6, 1311), 'Safe')
        
    @test.it("Evacuated Buildings")
    def test_second_oldest_first():
        test.assert_equals(earthquake_tracker(1.7, 100), 'Evacuate')
        test.assert_equals(earthquake_tracker(7.0301, 542), 'Evacuate')
        test.assert_equals(earthquake_tracker(12.4, 1172), 'Evacuate')
    
  • Custom User Avatar

    Then you should also add at least 1 sample test with a magnitude higher than 9.

  • Custom User Avatar

    OH, I get what you're saying. The constraint was worder poorly.

    Only the whole digits of magnitude (m) impact the evacuation radius. 123.456 -> 123
    

    I have updated the instructions and will publish that as soon as the system lets me.

  • Custom User Avatar

    They didn't (and maybe still don't) expect you to look at the first digit, instead to look at the integer part of the magnitude.

  • Custom User Avatar

    I'm not 100% sure I get what you mean. I updated the random tests to look like this

    @test.it("Random Tests")
    def test_second_oldest_first():
        i = 30
        while i > 0:
            i -= 1
            earthquake_danger = random.choice(['Safe', 'Evacuate'])
            if earthquake_danger == 'Safe':
                mag = random.uniform(0.001, 15.0)
                dis = int(random.uniform(int(mag)*100, int(mag)*200))
                if dis == 0:
                    dis = int(random.uniform(1, 1000))
                test.assert_equals(earthquake_tracker(mag, dis), earthquake_danger)
            else:
                mag = random.uniform(1.0, 15.0)
                dis = int(random.uniform(1, int(mag)*100))
                test.assert_equals(earthquake_tracker(mag, dis), earthquake_danger)
    

    Let me know if I'm still missing it. And thanks for the feedback!

  • Custom User Avatar

    Hey, I can't publish to show you but I think this makes it random!

    @test.it("Random Tests")
    def test_second_oldest_first():
        i = 30
        while i > 0:
            i -= 1
            earthquake_danger = random.choice(['Safe', 'Evacuate'])
            if earthquake_danger == 'Safe':
                mag = random.uniform(0.001, 15.0)
                dis = int(random.uniform(int(mag)*100, int(mag)*200))
                if dis == 0:
                    dis = int(random.uniform(1, 1000))
                test.assert_equals(earthquake_tracker(mag, dis), earthquake_danger)
            else:
                mag = random.uniform(1.0, 15.0)
                dis = int(random.uniform(1, int(mag)*100))
                test.assert_equals(earthquake_tracker(mag, dis), earthquake_danger)
    
  • Custom User Avatar

    Those tests are not random because they expect the exact same results in the same order every time.

  • Custom User Avatar

    Only the first digit of magnitude (m) impacts the evacuation radius

    This is not true in random tests.

  • Custom User Avatar

    Added random tests! Definitly going to read over that documentation as well. Thanks again!

  • Custom User Avatar
  • Custom User Avatar

    I didn't even know you could do random tests. I'll figure out how to impliment some! Thanks for the feedback man :D
    I started learning python about 3 weeks ago so this is all prety new to me.

  • Custom User Avatar

    No Random Tests