Answer to Question #159946 in Python for Meera

Question #159946

'''


(a) Ask the user to enter 5 integer values between 1 and 50. Create a simple bar graph using the character of your choice.

Hint: You may want to try to use a loop within a loop (a nested loop). Don't forget to indent properly! (2A)

For example: If the user were to enter 3, 1, 6, 2, 5, the output might look like:

###

#

######

##

#####

Extension:

(d) [challenge] Make the bar graph horizontal (2T)



1
Expert's answer
2021-02-01T08:01:03-0500
nums = []
for i in range(5):
    # User input
    num = int(input("Enter integer (1-50): "))
    nums.append(num)
print()

# Display bar graph
print("Bar Graph")
for num in nums:
    for j in range(num):
        print("#", end="")
    print()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS