Here is the code for the function that generates histograms using '>' symbols:

def print_histogram(numbers):
    for num in numbers:
        print('>' * num)

This function takes a list of numbers as input. For each number in the list, it prints the '>' symbol repeated the number of times specified by the number.

You can use this function by passing a list of numbers to it. For example:

numbers = [2, 7, 8, 4]
print_histogram(numbers)

Output:

>>
>>>>>>>>
>>>>>>>>>>
>>>>
Python Function to Print Histograms Using '>' Symbols

原文地址: https://www.cveoy.top/t/topic/pfNE 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录