Hello world!

String data type

A string is a sequence of characters

A string literal uses quotes ‘Hello’ or “Hello”

For strings, + means concantenate

We can convert a number in a string using int()

num = 0
tot = 0.
array = list()
while True :
    sval = input('Enter a number: ')
    if sval == 'done' :
        break
    try :
        fval = float(sval)
        array.append(int(fval))
    except :
        print('Invalid Input')
        continue

largest = -1
for lvalue in array :
    if lvalue > largest :
        largest = lvalue
print('Maximum is', largest)

smallest = None
for svalue in array :
    if smallest is None :
        smallest = svalue
    elif svalue < smallest :
        smallest = svalue
print('Minimum is',smallest)

unixbitch has written 1 article

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>