-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExample_7.py
30 lines (26 loc) · 960 Bytes
/
Example_7.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python3
# Implement Histogram In Cli
# Declare function for printing the histogram
def hist(l,Option='Row'):
print('Output:')
if Option == 'Row' or Option=='row': # Row-wise histogram
for i in l:
print("*"*i)
elif Option == 'Col' or Option == 'col': # Column-wise histogram
m=max(l)
for i in range(0,m):
for j in range(0,len(l)):
if i<l[j]:
print('*',end=" ")
else:
print(" ",end=" ")
print('\n')
else:
print("Please Enter A Correct Option:")
print("Type 'Row/row' for row-wise histogram")
print("Type 'Col/col' for column-wise histogram")
# Input a list of integers
a=list(map(int,input("Enter numbers:").strip().split()))
option=input("Enter 'row/Row' for row-wise histogram\nEnter 'col/Col' for column-wise histogram:")
# Call the hist function
hist(a,option)