Python Exercise Example67
# Python2.x Python Exercise Instance 67
[ Python 100 Examples](#)
**Question:** Input an array, swap the largest element with the first element, swap the smallest element with the last element, and output the array.
**Program Analysis:** None.
Program source code:
## Instance
#!/usr/bin/python# -*- coding: UTF-8 -*-def inp(numbers): for i in range(6): numbers.append(int(raw_input('input a number:n')))p = 0 def arr_max(array): max = 0 for i in range(1,len(array) - 1): p = i if array>array : max = p k = max array,array = array,arraydef arr_min(array): min = 0 for i in range(1,len(array) - 1): p = i if array<array : min
YouTip