Thread: ChatGPT
View Single Post
Old 02-09-2023, 01:57 PM   #44
Ghost Econ
College Prospect
 
Join Date: Oct 2020
We no longer need TCY 2

Code:
import random class CollegeFootballGame: def __init__(self, team1, team2): self.team1 = team1 self.team2 = team2 self.score1 = 0 self.score2 = 0 def simulate_play(self): play_type = random.choice(["run", "pass"]) yards = random.randint(1, 20) if play_type == "run": self.score1 += yards else: self.score2 += yards def simulate_game(self): for i in range(10): self.simulate_play() if self.score1 > self.score2: print(f"{self.team1} wins with a score of {self.score1} to {self.score2}") else: print(f"{self.team2} wins with a score of {self.score2} to {self.score1}") game = CollegeFootballGame("Team 1", "Team 2") game.simulate_game()
Ghost Econ is offline   Reply With Quote