2.1

2.3

2.4

2.5

2.6

2.7

 

 2.8

2.9

 2.10

2.11

def test_sum():
    tup=("1","2","3","6","5")
    sum=0
    for i in tup:
        sum=float(i)+sum
    return sum
def test11():
    while True:
        string=raw_input(">>")
        if string=="1":
            sum=test_sum()
            print "sum:",sum
        elif string=="2":
            sum=test_sum()
            avg=sum/5
            print"avg:",avg
        elif string=="x":
            exit()
        else:
            print"Please enter 1 or 2 or x"
test11()    


 2.12-2.13

 

 

 2.15

b:

def test15():
    num1=raw_input("first num:")
    num2=raw_input("second num:")
    num3=raw_input("third num:")
    num1=float(num1)
    num2=float(num2)
    num3=float(num3)
    if num1>num2:
        if num1>num3:
            firstnum=num1
            if num2>num3:
                seconnum=num2
                thirdnum=num3
            else:
                seconnum=num3
                thirdnum=num2                
        else:
            firstnum=num3
            seconnum=num1
            thirdnum=num2
    else:
        if num2>num3:
            firstnum=num2
            if num1>num3:
                seconnum=num1
                thirdnum=num3
            else:
                seconnum=num3
                thirdnum=num1               
        else:
            firstnum=num3
            seconnum=num2
            thirdnum=num1
    print firstnum,seconnum,thirdnum
test15()

 

posted on 2017-04-23 18:02  竹子的梦想在路上  阅读(447)  评论(0编辑  收藏  举报