ezoic

Tuesday, February 21, 2017

One solution to a question

Define a procedure histogram() that takes a list of integers and prints a histogram to the screen. For example, histogram([4, 9, 7]) should print the following:


****
*********
*******

class Solution:
    def hist1(self,vector):
         a1=[0]*len(vector)
         for i in range(len(vector)):
             a1[i]='*'*vector[i]
         for j in range(len(a1)):
             print(a1[j])



kk=Solution()
if __name__=="__main__":

    kk.hist1([2,5,8])


results:




No comments:

Post a Comment

looking for a man

 I am a mid aged woman.  I was born in 1980. I do not have any kid. no complicated  dating before . I am looking for a man here for marriage...