1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AURORKA [14]
3 years ago
9

Implement a function with signature barGraph(w, h, data) which creates and returns a cs1graphics.Canvas instance that has width

w and height h and which visualizes the given data as a bar graph. The data will be a nonempty list of positive integers. (You do not need to error-check the parameters.) Your visualization must have rectanglar bars with equal width that collectively use 80% of the width of the canvas (leaving 10% padding on left and right) and the bars should be vertically aligned at their bottom edge such that the maximum value in the data results in a bar that uses 80% of the height of the canvas (leaving 10% padding at top and bottom). As an example, the call barGraph (400, 300, [5, 8, 2, 7]) should produce the following image: from cs1graphics import * def barGraph(w, h, data): pass
Computers and Technology
1 answer:
arsen [322]3 years ago
6 0

Answer:

def barGraph(w, h, data):

  # creating Canvas

  paper = Canvas(w, h)

  # defining variables

  largest = max(data) # largest element in data

  length = len(data) # length of data list

  barWidth = 0.8 * w / length # length of each bar of the histogram

  maxBarHeight = 0.8 * h # maximum height of each bar of the histogram

  minBarHeight = maxBarHeight / largest # minimum height of each bar

  # Starting points

  x = 0.1 * w

  y = 0.9 * h

  # looping through the list

  for i in data:

      currBarHeight = minBarHeight * i # current bar height

      x1 = x + barWidth

      y1 = y - currBarHeight

      # creating the rectangle, and adding it to the bar graph

      bar = Polygon( Point(x,y), Point(x,y1), Point(x1,y1), Point(x1,y) )

      bar.setFillColor('grey')

      paper.add(bar)

      x = x1

  # returning the canvas

  return paper

You might be interested in
What command should you use to determine the fqdn of a computer with ip address 172.31.209.5?
KatRina [158]
I use host -a

dig and nslookup could do it, I forget the switches and arguments.
8 0
4 years ago
In the ____ category, the cloud service provider offers the capability to build and deploy consumer-created applications using t
Nikolay [14]

Answer:

Platform as a Service (PaaS)

Explanation:

In cloud computing, PaaS called platform as a service refers to the provision of a computing platform for developers to create their own custom application. Other two categories of cloud computing are IaaS (Infrastructure as a service) and SaaS (Software as a Service). In the PaaS the servers, cloud storage and network  are automatically handled by the platform only the software and application code are to be managed.

7 0
3 years ago
Write a program that reads a target string from the keyboard and then another sentence string from the keyboard.
Rzqust [24]

The solution is in the attachment

5 0
4 years ago
A computer that supports 10/100/1000 Ethernet allows for 10, 100, or 1000 ________ per second.
stich3 [128]

A Computer that supports 10/100/1000 Ethernet allows for 10,100,or 1000 gigabyte per second.

4 0
4 years ago
given that play_list has been defined to be a list, write an expression that evaluates to a new list containing the elements at
Tamiku [17]

Answer:

new_list = play_list[0:4]

Explanation:

5 0
3 years ago
Other questions:
  • I need help RIGHT NOW PLZ!!!!!!!!!!!!! this is due in 5 mins
    13·1 answer
  • How do you jumpstart a car in the middle of nowhere??? Explain using 2 paragraphs.
    14·2 answers
  • Why is it important to open the Map Custom Fields dialog box before importing/exporting a list of contacts? Check all that apply
    6·2 answers
  • Signs that a listener is paying attention include:
    10·2 answers
  • For activities with output like below, your output's whitespace (newlines or spaces) must match exactly. See this note. Jump to
    15·1 answer
  • Edward uses the self-timer drive mode on the camera to set a time delay on the closing of the shutter. What does this mode allow
    9·1 answer
  • Displays unsolicited advertisements in banners or pop-up windows
    5·1 answer
  • All the read/write heads a hard disk are controlled by a(n) ____ which moves the read/write heads across the disk surfaces in un
    13·1 answer
  • Why wouldn't a game using just run-length encodings be challenging?
    9·1 answer
  • Which of the following might a small local bakery hire a multimedia artist to do? (Select all that apply).
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!