PLEASE PLEASE can someone give me the correct program for this! I sent this prev
ID: 3777898 • Letter: P
Question
PLEASE PLEASE can someone give me the correct program for this! I sent this previously but answer does not work. Trying again. Write a program that reads a sequence of input values and displays a bar chart of the values, using asterisks, like this in Intro to Python. Make sure you write a main:
**********************
**************************************** .
**************************** .
**************************
**************
You may assume that all values are positive. First figure out the maximum value. That value's bar should be drawn with 40 asterisks. Shorter bars should use proportionally fewer asterisks
Explanation / Answer
'''copy the entire answer content and save it as bargraph.py and run it example
output provided in last comment lines'''
numbers = list(map(int,input().split())) #split the raw input list to list of integers
mx=max(numbers) #find the max of list
for i in range(len(numbers)):
ast=int((numbers[i]*100)/mx) #find the percentage of other numbers to max
num_ast=abs((ast*40)/100) #adjust that percentage to 40
for j in range(int(num_ast)):#print the number of astrics
print('*', end="")
print()
'''example output:
55 100 35 9 50 23
**********************
****************************************
**************
***
********************
*********
'''
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.