Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
761 B
6
Indexable
def StarRating(str):
    i = round(float(str) * 2) / 2
    if i % 1 == 0:
        print ("full "* int(i) + "empty "* (5 - int(i)))
    else :
        b = i - 0.5
        print("full " * int(i)+"half "+ "empty " * (5 - int(i)))

def StockPicker (arr):
    i = 0
    imax = -1
    c = 0
    roz = -1
    minimum = arr[0]
    maximum = 0

    for num in arr:
        if num < minimum:
            minimum = num
            c = i
        if num > maximum:
            if i >= c:
                maximum = num
                imax = i
        if maximum > minimum:
            if imax > c:
                roz = maximum - minimum
            if c>imax:
                imax = 0
                maximum = 0
        i +=1
    print (roz)