Skip to content

Commit 0f1d695

Browse files
committed
Post final QA fixes
1 parent 863607f commit 0f1d695

14 files changed

+70
-84
lines changed

python-isinstance/ball_instance_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
football = AmericanFootBall("brown")
55
ball = Ball("green", "sphere")
66

7-
isinstance(eight_ball, PoolBall)
8-
isinstance(eight_ball, Ball)
9-
isinstance(eight_ball, AmericanFootBall)
7+
print(f"{isinstance(eight_ball, PoolBall) = }")
8+
print(f"{isinstance(eight_ball, Ball) = }")
9+
print(f"{isinstance(eight_ball, AmericanFootBall) = }")
1010

11-
isinstance(eight_ball, object)
12-
isinstance(football, object)
13-
isinstance(ball, object)
14-
isinstance(object, object)
11+
print(f"{isinstance(eight_ball, object) = }")
12+
print(f"{isinstance(football, object) = }")
13+
print(f"{isinstance(ball, object) = }")
14+
print(f"{isinstance(object, object) = }")

python-isinstance/basic_types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
shape = "Sphere"
22
number = 8
33

4-
isinstance(shape, str)
5-
isinstance(number, int)
6-
isinstance(number, float)
4+
print(f"{isinstance(shape, str) = }")
5+
print(f"{isinstance(number, int) = }")
6+
print(f"{isinstance(number, float) = }")

python-isinstance/bool_int_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
isinstance(True, int)
2-
3-
isinstance(True, bool)
4-
5-
isinstance(False, int)
6-
7-
isinstance(False, bool)
1+
print(f"{isinstance(True, int) = }")
2+
print(f"{isinstance(True, bool) = }")
3+
print(f"{isinstance(False, int) = }")
4+
print(f"{isinstance(False, bool) = }")
85

96
test_data = [10, True, False]
107

8+
print()
119
for element in test_data:
1210
print("int") if isinstance(element, int) else print("bool")
1311

12+
print()
1413
for element in test_data:
1514
print("bool") if isinstance(element, bool) else print("int")
1615

16+
print()
1717
for element in test_data:
1818
print("bool") if type(element) is bool else print("int") # noqa

python-isinstance/calculate_area_v1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ def calculate_area(length, breadth):
22
return length * breadth
33

44

5-
calculate_area(5, 3)
6-
calculate_area(5, "3")
7-
calculate_area("5", "3")
5+
print(f"{calculate_area(5, 3) = }")
6+
print(f"{calculate_area(5, "3") = }")
7+
print(f"{calculate_area("5", "3") = }")

python-isinstance/calculate_area_v2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ def calculate_area(length, breadth):
44
raise TypeError("Both arguments must be integers")
55

66

7-
calculate_area(5, 3)
8-
calculate_area(5, "3")
9-
calculate_area("5", "3")
7+
print(f"{calculate_area(5, 3) = }")
8+
print(f"{calculate_area(5, "3") = }")
9+
print(f"{calculate_area("5", "3") = }")

python-isinstance/consolidation1_solution.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33
ball = Ball("green", "sphere")
44
football = AmericanFootBall("brown")
55

6-
isinstance(football, AmericanFootBall)
7-
8-
isinstance(football, PoolBall)
9-
10-
isinstance(ball, Ball)
11-
12-
isinstance(ball, AmericanFootBall)
13-
14-
isinstance(football, Ball)
15-
16-
isinstance(ball, PoolBall)
17-
18-
isinstance(1, bool)
19-
20-
isinstance(0, bool)
6+
print(f"{isinstance(football, AmericanFootBall) = }")
7+
print(f"{isinstance(football, PoolBall) = }")
8+
print(f"{isinstance(ball, Ball) = }")
9+
print(f"{isinstance(ball, AmericanFootBall) = }")
10+
print(f"{isinstance(football, Ball) = }")
11+
print(f"{isinstance(ball, PoolBall) = }")
12+
print(f"{isinstance(1, bool) = }")
13+
print(f"{isinstance(0, bool) = }")

python-isinstance/consolidation2_solution.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
eight_ball = PoolBall("black", 8)
77
football = AmericanFootBall("brown")
88

9-
# a)
10-
11-
isinstance(eight_ball, ABC)
12-
isinstance(football, ABC)
13-
14-
# b)
15-
16-
isinstance(isinstance, Callable)
17-
isinstance(PoolBall, Callable)
18-
19-
# c)
20-
21-
isinstance(eight_ball.get_state, Callable)
22-
23-
isinstance(PoolBall, Callable)
9+
# 1.
10+
print(f"{isinstance(eight_ball, ABC) = }")
11+
print(f"{isinstance(football, ABC) = }")
12+
13+
# 2.
14+
print()
15+
print(f"{isinstance(isinstance, Callable) = }")
16+
print(f"{isinstance(PoolBall, Callable) = }")
17+
18+
# 3.
19+
print()
20+
print(f"{isinstance(eight_ball.get_state, Callable) = }")
21+
print(f"{isinstance(PoolBall, Callable) = }")

python-isinstance/isinstance_vs_type.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
eight_ball = PoolBall("black", 8)
44

5-
type(eight_ball)
6-
7-
type(eight_ball) is PoolBall
8-
9-
isinstance(eight_ball, Ball)
10-
11-
type(eight_ball) is Ball
5+
print(f"{type(eight_ball) = }")
6+
print(f"{type(eight_ball) is PoolBall = }")
7+
print(f"{isinstance(eight_ball, Ball) = }")
8+
print(f"{type(eight_ball) is Ball = }")
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from balls_v2 import AmericanFootBall, Ball, PoolBall
22

33
eight_ball = PoolBall("black", 8)
4-
54
football = AmericanFootBall("brown")
65

7-
isinstance(eight_ball, Ball)
8-
9-
isinstance(football, Ball)
6+
print(f"{isinstance(eight_ball, Ball) = }")
7+
print(f"{isinstance(football, Ball) = }")

python-isinstance/iter_test.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
PlayersVersionTwo,
66
)
77

8-
iter(PlayersVersionOne(["Fast Ed", "Slow Jo", "Still Su"]))
9-
10-
iter(PlayersVersionTwo(["Fast Ed", "Slow Jo", "Still Su"]))
11-
12-
iter(PlayersVersionThree(["Fast Ed", "Slow Jo", "Still Su"]))
13-
14-
iter(PlayersVersionFour(["Fast Ed", "Slow Jo", "Still Su"]))
8+
print(f"{iter(PlayersVersionOne(["Fast Ed", "Slow Jo", "Still Su"])) = }")
9+
print(f"{iter(PlayersVersionTwo(["Fast Ed", "Slow Jo", "Still Su"])) = }")
10+
print(f"{iter(PlayersVersionThree(["Fast Ed", "Slow Jo", "Still Su"])) = }")
11+
print(f"{iter(PlayersVersionFour(["Fast Ed", "Slow Jo", "Still Su"])) = }")

0 commit comments

Comments
 (0)