- 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
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]
0
the code isn't running
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)
0
def min6(*args):
arr=[]
for arg in args:
arr.append(arg)
arr.sort()
return arr[0]
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))