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

R is not a simple programming language, and it does better on reading excel files than python

R is not a simple programming language, and it does better on reading excel files than python . tried to read excel files to python and R. i...