Last century, the Victorian Football League (VFL) had 12 teams,
and at the end of the regular (home-and-away) season, a series
of Finals games were played to decide the winner of football
premiership for that year. Up to 1971, the Finals Series involved
Copyright By PowCoder代写 加微信 powcoder
four teams, who played in 4 Finals games:
Game 1: (The First Semi-Final): Team 3 plays Team 4. The loser
drops out, the winner goes into to Game 3.
Game 2: (The Second Semi-Final): Team 1 plays Team 2. The
winner goes into the Game 4. The loser goes into Game 3.
Game 3: (The Preliminary Final): The winner from Game 1 plays
the loser from Game 2. The loser drops out and the winner goes
into Game 4.
Game 4: (The Grand Final): The winner of Game 2 plays the
winner of Game 3. The winner of the Grand Final wins the
Premiership!
The 12 teams were
North Melbourne
South Melbourne
Write a Python program to do the following:
1. Take as the input a Python string made up of any four of
the 12 teams, in the order they finished the regular season.
The input string should separate the teams with commas
and should not have any white space between the teams,
e.g. “Melbourne, Carlton, Geelong, St Kilda”.
2. Test whether the input contains exactly four teams, and all
teams are in the VFL. Print an error message if the input is
not suitable.
3. Print out the winner and loser of each game.
The winner of each finals game should be the team whose name
has the larger ASCII sum. This is equal to the sum of the ASCII
ordinal numbers of each letter in the team’s name. For teams
whose name is made up of two words, do not count the space
character. If two teams have the same ASCII sum, the first team
is declared the winner.
Which teams are playing in the finals this year? defeated St Kilda in the First Semi-Final.
Melbourne defeated Carlton in the Second Semi-Final.
Carlton defeated Geelong in the Preliminary Final.
Melbourne defeated Carlton in the Grand Final.
Melbourne win the Premiership!
You need to handle duplicate teams in the input, as well as teams
not in the VFL _TEAMS:
Which teams are playing in the finals this year? Melbourn
Please check your list of teams.
Which teams are playing in the finals this year? Melbourn
Please check your list of teams.
The VFL teams are given as a list here
VFL_ TE AAS = [‘ Carlton’, ’ Co11ingwood’, ’ Essendon’, tFitzr
Over time, teams from other Australian states were added to the
competition, which now has 18 teams and is called the
Australian Football League (AFL). The finals series has been
expanded to involve 8 teams, but to keep things simple, we will
assume there are still only four teams playing in the Finals series.
The scoring works like this: teams can score Goals (worth 6
points) and Behinds (worth 1 point). Hence a score of 10 Goals
and 12 Behinds is a total score of 72 points. This is written as
10.12 (72). As you probably quessed, the winner is the team with
the higher points score. A drawn game (the scores are level)
must be played again.
Also, each team has a home ground, and finals games will be
played at the home ground of the higher ranked team, except for
the Grand Final, which is always played at the MCG. The AFL
teams and their home grounds (for finals matches) are shown
Home Ground for Finals Games
the Adelaide Oval
Collingwood
Optus Stadium
Gold Coast
Greater Western Sydney Giants Stadium
North Melbourne
Port Adelaide
the Adelaide Oval
West Coast
Optus Stadium
Western Bulldogs
Write a Python program to do the following:
Write a Python program to do the following:
1. Take as the input a Python string made up of any four of
the 18 teams, in the order they finished the regular season
(highest first).
2. Test that the input is suitable: it contains four AFL teams.
3. Print out the location of each game, the winner of each
game, and each team’s score. If a game is drawn (meaning
the scores are level), print out the score of the first game
and also the replayed game. (It will be played at the same
location).
To compute the score for each team, the home team’s Goals and
Behinds should take randomly generated integer values between
12 and 22. The visiting team’s Goals and Behinds should take
randomly generated integer values between 10 and 20. (This is to
allow for the advantage of the home team playing in front of their
supporters).
Also, the home team is always the higher ranked team, even for
the Grand final, where they might not be playing at their ground.
For drawn games, print out the higher ranked team’s score first.
String distance functions take two strings as input and return a
number that measures some distance between the two strings.
The first part of this question requires you to calculate the
distance between two strings, string and string2, according
to certain rules.
Note that String1 and String2 are non-empty and can consist of
alphabetical characters, numerical characters, and non-
alphanumeric characters such as “! ” and “?”. To be more
precise, both strings can consist of the ASCII characters within
the range represented by the numbers 33 to 126. The distance
rules for this program are as follows:
If either string is longer than the other, then for each additional
character the longer string has, add 3 to the distance.
For each character c1 and c2 in the same positions of stringl
and string2 respectively:
1. If c1 and c2 are the same character, then nothing is added
to the distance (i.e., 0).
2. If c1 and c2 are different character:
o If they are of the same type (alphabetical, numerical,
or non-alphanumeric), then add a distance of 1.
o If they are of a different type, then add a distance of 2.
Note that lowercase and uppercase versions of the same letter
are treated as different characters: ‘a’ is a different character to
Here are some examples to illustrate how this works:
This question requires you to develop a program which takes a
string as and prints a number representing/encoding that string as
• For each character in the inputted string, convert that
character to its ASCII representation (e.g., ‘a’->97). For
example, the string ‘hello” would be represented by the list
of ASCII numbers [104, 101, 108, 108, 111].
• For such an ASCII list with 2 numbers, N1, N22, … Ne,
calculate the encoding number with the following formula,
where p, is the 2th prime number starting at 2 (e.g.
PI = 2, pm = 3, p3 = 5):
(PI X RI) + (P2 X R2) + (Pg X R3) + . .. + (PE X NE)
So, if the input string is ‘hello’, then its list of ASCII characters
[104, 101, 108, 108, 111] gets converted to an encoding
number with the following formula:
encoding = (2 x 104) + (3 x 101) + (5 x 108)
+(7 × 108) + (11 x 111) = 3028
Your program will take one inputs string and print out the values as
shown in the following examples:
Enter input string: hello
The special encoding of string is 3028
Enter input string: goodbye
The special encoding of string is 6162
Enter input string: unimelb
The special encoding of string is 6033
Enter input string: antidisestablishmentarianism
The special encoding of string is 147096
Enter input string: xyz
The special encoding of string is 1213
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com