Computer Science, asked by ssimar5740, 10 months ago

Write a function, game, that takes two Team objects as parameters and returns the name of the winning team. Function specifications: • The function name: game • The function takes two parameters, both of the type Team. • The function returns the name of the winning team, as a string • To determine the winning team, add up the points associated with each team’s first 4 players. The team with more points is the winner. • If one or both of the teams do not have 4 or more players, your function should return "forfeit" • If the teams have the same total points, your function should return "draw" • The output of "forfeit" takes higher priority than "draw" in the sense that if a team doesn’t have enough players, a game cannot be played, so there could be no draw (for example, if both teams have no players, this would constitute a "forfeit", not a draw).

Answers

Answered by Anonymous
0

Answer:

We have already seen how we can use a dictionary to group related data together, and how we can use functions to create shortcuts for commonly used groups of statements. A function performs an action using some set of input parameters. Not all functions are applicable to all kinds of data. Classes are a way of grouping together related data and functions which act upon that data.

A class is a kind of data type, just like a string, integer or list. When we create an object of that data type, we call it an instance of a class.

As we have already mentioned, in some other languages some entities are objects and some are not. In Python, everything is an object – everything is an instance of some class. In earlier versions of Python a distinction was made between built-in types and user-defined classes, but these are now completely indistinguishable. Classes and types are themselves objects, and they are of type type. You can find out the type of any object using the type function:

Similar questions