- 1

Function

write a python program using with function min6() that takes in six integer or float numbers as arguments and returns the smallest one

10th Aug 2018, 10:23 AM
Hamzat Hamzat
5 odpowiedzi
0
def min6(a,b,c,d,e,f): arr=[] arr.append(a) arr.append(b) arr.append(c) arr.append(d) arr.append(e) arr.append(f) arr.sort() return arr[0]
10th Aug 2018, 10:50 AM
LordHill
LordHill - avatar
0
the code isn't running
10th Aug 2018, 10:56 AM
Hamzat Hamzat
0
that's because it's just a function. you have to call it. Add this to it. x=min6(8,4,5,6,3,9) print(x)
10th Aug 2018, 10:57 AM
LordHill
LordHill - avatar
0
def min6(*args): arr=[] for arg in args: arr.append(arg) arr.sort() return arr[0]
10th Aug 2018, 12:11 PM
dev.Y
dev.Y - avatar
0
import random def min6(a,b,c,d,e,f): nums=[] nums.append(a) nums.append(b) nums.append(c) nums.append(d) nums.append(e) nums.append(f) run=True while run: good=True for i in range(len(nums)-1): if nums[i] > nums[i+1]: x=nums[i+1] y=nums[i] nums[i]=x nums[i+1]=y good=False if good == False: continue else: run=False return nums[0] print(min6(9,2,7,4,1,5))
10th Aug 2018, 1:13 PM
LordHill
LordHill - avatar