#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ ENGG1811 Lecture Week 6 Input argument example 2 """ # A function to print two numbers in either ascending or # descending order def arrange(num1, num2, order = 'ascending'): # big <- bigger number # small <- smaller number if num1 >= num2: big, small = num1, num2 else: big, small = num2, num1 # Print in ascending or descending # order depending on the input if order == 'ascending': print(order,':',small, big) elif order == 'descending': print(order,':',big, small) else: print('Invalid option') # All the following calling methods can be used # and give the same result arrange(10, 7) arrange(10, 7, 'ascending') arrange(10, 7, order = 'ascending') arrange(10, num2 = 7, order = 'ascending') arrange(num1 = 10, num2 = 7 , order = 'ascending') arrange(num2 = 7 , num1 = 10, order = 'ascending') arrange(order = 'ascending', num2 = 7, num1 = 10) #%% # The following will give an error # arrange(10, num2 = 7, 'ascending') # Error: positional argument follows keyword argument