In python 3.7.0 Please provide a valid working Python code using 2 functions, de
ID: 3743716 • Letter: I
Question
In python 3.7.0 Please provide a valid working Python code using 2 functions, def main) and def clear For example, in a game stage completion scenario, how do you remove the points ONLY when you go to the next level but still retained the special powerups? Using a sample: Player 1 won 33 points and got 2 special powerups! Value for this is to be retained for the next level of the game What I have now as stated below but it clears both the points and special powerups. I need another function, e.g. def clear() outside of def main() but I am not sure how to go about it. def main(): points.clear() main()Explanation / Answer
class Points: def __init__(self, points, powerups): self.points = points self.powerups = powerups def clear(self): self.points = 0 def main(): points = Points(33, 2) print('Player 1 won %d points and got %d special powerups!' % (points.points, points.powerups)) points.clear() print('Player 1 won %d points and got %d special powerups!' % (points.points, points.powerups)) main()
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.