he fairies in Fairyland are getting ready to compete in the Fly High game where the fairy that flies the highest is declared a winner. The number of fairies participating in this competition is not known ahead of time. Before flying high, each fairy goes through a pixie dust machine and gets sprinkled with the pixie dust. The pixie dust allows them to fly and perform their special talent high up in the sky. Pixie dust can be of any one of the 4 colours (red, blue, yellow, and green) and each colour has a dust strength in the following ranges (dust strength determines roughly how high a fairy can fly): Colour Strength Red 40 - 49

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

The fairies in Fairyland are getting ready to compete in the Fly High game where the fairy that flies the highest is
declared a winner. The number of fairies participating in this competition is not known ahead of time. Before flying
high, each fairy goes through a pixie dust machine and gets sprinkled with the pixie dust. The pixie dust allows them
to fly and perform their special talent high up in the sky. Pixie dust can be of any one of the 4 colours (red, blue,
yellow, and green) and each colour has a dust strength in the following ranges (dust strength determines roughly
how high a fairy can fly):
Colour Strength
Red 40 - 49
Blue 30 - 39
Green 20 - 29
Yellow 10 - 19
Write a Python program, in a file called fairyland.py, to include the following functions:
• function main that repeatedly obtains a fairy’s name (from the user) and, using other functions, determines
the colour of pixie dust that the fairy has been dusted with, the height of the fairy’s flight (based on that
colour), and keeps track of the highest flight so far and the name of the fairy that achieved it, until all the
participating fairies are processed. It then prints the name and the height reached for the fairy that won the
competition. Intermediate printing is done to show individual fairy dust colours and heights. See sample
input/output below.
• function pixieDusting which randomly determines and returns, as a string, the colour of the pixie dust
selected for a fairy.
• function computeHeight that takes a pixie dust colour and computes and returns the height that the fairy
can fly (in metres). The height is randomly generated within the strength range for the fairy’s pixie dust
colour. For example, if a fairy has been dusted with Green, they will achieve a height between, and including,
20 to 29 metres, randomly determined.
Sample input/output (input in bold blue):
Enter a fairy's name, 'end' when done: Astrid
Astrid was dusted with Green pixie dust and flew 22 metres high.
Enter a fairy's name, 'end' when done: Twinkles
Twinkles was dusted with Green pixie dust and flew 24 metres high.
Enter a fairy's name, 'end' when done: Tinkerbell
Tinkerbell was dusted with Blue pixie dust and flew 35 metres high.
Enter a fairy's name, 'end' when done: Belinda
Belinda was dusted with Green pixie dust and flew 21 metres high.
Enter a fairy's name, 'end' when done: end
The highest flight was 35 by Tinkerbell
Note: To generate the height of fairy flight, you can use the randint function from the random module.
The function syntax you will need is random.randint(start_value, end_value) where a random
value will be selected from a range that begins at the start_value, goes up to, and including, the
end_value. For example, x = random.randint(2,7) will generate a value for x between 2 and 7,
inclusive. This can also be used for the colour.
 
 
 
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education