LU05.L09: Only positives

def main_break():
    while True:
        number = int(input('Give a number:\n'))
        if number > 0:
            print(number * number)
        elif number == 0:
            break
        else:
            print('Unsuitable number')
 
def main_continue():
    number = 1
    while number != 0:
        number = int(input('Give a number:\n'))
        if number > 0:
            print(number * number)
        elif number == 0:
            continue
        else:
            print('Unsuitable number')
 
def main():
    number = int(input('Give a number:\n'))
    while number != 0:
        if number > 0:
            print(number * number)
        elif number < 0:
            print('Unsuitable number')
        number = int(input('Give a number:\n'))
 
if __name__ == '__main__':
    main()

Kevin Maurizi, Marcel Suter

  • modul/m319/learningunits/lu05/loesungen/onlypositives.txt
  • Zuletzt geändert: 2024/03/28 14:07
  • von 127.0.0.1