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
Find some search engine as many that you can find
Alexandra [31]
1) google
2) bing
3) yahoo
4) safari
5) baidu
6) ask!
7) aol
8) duckduckgo
9) yandex
10 webcrawler
5 0
3 years ago
What are advantages and disadvantages of developing a more robust Internet of Things and continuing to add more smart nodes?
lubasha [3.4K]
Your stored entertainment files are more secure when connected to a home network.
6 0
4 years ago
The banner on the front page of a newsletter that identifies the publication is the:.
podryga [215]

Answer:

Nameplate

Explanation:

The banner on the front of a newsletter that identifies the publication is its nameplate.

7 0
2 years ago
Which of the following does not make a good analysis class? (Points : 6) its name reflects its intent
satela [25.4K]

Answer:it has high coupling

Explanation: Coupling is the property in the field of computer program that is defined as the functions ,data and  codes of the program are dependent on each other and cannot be changed independently if requires. Thus,high amount of coupling is not considered as good factor due to high interdependence. Loose coupling can be still permitted.

Other options are correct because name of the class should reflect the purpose and well defined responsibilities should be present, modeling of certain component and high cohesion means keeping similar functions togather is also required. So, the only bad factor is high coupling

6 0
3 years ago
1. What is the central idea of the section "Service Record." Use two text details to
Vladimir [108]

Answer:

Service record is the record that is used to track the record of service of the employ in an organization.

Explanation:

The idea behind the service record is to maintain the whole detail of record of the person during his employment including, personnel information,  record related to his promotions and posting, salary record etc.

8 0
4 years ago
Other questions:
  • A name given to a spot in memory is called:
    5·1 answer
  • Which is an example of a screenshot?
    7·2 answers
  • Charles would like to move his internet browser window so that he can see his desktop.He should
    5·1 answer
  • _____ can render data useless to unauthorized users who might have violated some of the database security layers.
    7·1 answer
  • To implement a small database, a database designer must know the "1" and the "M" sides of each relationship and whether the rela
    7·1 answer
  • Write a program that ask the user to enter air water or Steele and the distance that a sound wave will travel in the medium the
    9·1 answer
  • Irene wants to connect your smart phone wirelessly to her laptop in order to transfer images. which two images could she reasona
    15·1 answer
  • How many of these imformation have you shared​
    14·1 answer
  • For this activity, you will practice being both proactive and reactive to bugs. Both are necessary to get rid of errors in code.
    5·1 answer
  • What are the importance of computer software​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!