Hook
More breakout videos from this creator.
How to switch to your ops in Python? In order to switch to your ops, we're gonna use a stack. A stack means last in first out. Last in first out. That means last round in the clip's gonna be the first one out. I'm gonna let you know how we actually put our rounds in our mag. Our stack is our magazine. And the next thing we have to do is create a function called push. This is how we actually put our rounds in our mag. And the next thing we have to do is create a function called pop. If self is empty, print Mag is empty, return None. Else, self.stack.pop(). And the next thing we have to do is create a function called is_empty. Return length of self.stack. And the next thing we have to do is create a function called size. Return print Mag size, length of self.stack. And the next thing we have to do is create a function called display. If self is empty, print Empty Mag. Else, print Mag, self.stack. clip = Stack() clip.push(1) clip.push(2) clip.pop() clip.display() Mag: [1] clip.display() Empty Mag clip = Stack() for i in range(1,18): clip.push(i) clip.size() clip.display() print("Spray that Mug!!!!!!!!") for i in range(3): clip.pop() clip.size() clip.display() Mag Size: 17 Mag: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] Spray that Mug!!!!!!!! Mag Size: 14 Mag: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] But if you wanna switch cheese, they'll hope block down. Spray that mug. Just change the three to a 17. Spray their whole block down.