Python: finding lowest integer

前端 未结 13 801
北海茫月
北海茫月 2020-12-05 18:16

I have the following code:

l = [\'-1.2\', \'0.0\', \'1\']

x = 100.0
for i in l:
    if i < x:
        x = i
print x

The code should fin

13条回答
  •  悲&欢浪女
    2020-12-05 18:43

    '''Functions'''

    import math
    
    #functions
    def min3(x1,x2,x3):
        if x1<= x2 and x1<= x3:
            return x1
        elif x2<= x1 and x2<= x3:
            return x2
        elif x3<= x2 and x3<= x1:
              return x3
    print(min3(4, 7, 5))
    
    print(min3(4, 5, 5))
    
    print(min3(4, 4, 4))
    
    print(min3(-2, -6, -100))
    
    print(min3("Z", "B", "A"))
    

提交回复
热议问题