练习三

练习1


In [ ]:
name=input("please input your name")
birth=int(input("Please input your birthday date like 1119(11月19号),102(1月2号) "))
if  birth >= 1222:
    print(name, "你是严谨的摩羯座")
elif birth>= 1123:
    print(name,"你是自由的射手座")
elif birth>=1024:
    print(name,"你是神秘的天蝎座")
elif birth>= 923:
    print(name,"你是纠结的天秤座")
elif birth>=823:
    print(name,"你是特别的处女座")
elif birth>=723:
    print(name,"你是热情的狮子座")
elif birth>=622:
    print(name,"你是居家的巨蟹座")
elif birth>=521:
    print(name,"你是活泼的双子座")
elif birth>=420:
    print(name,"你是精明的金牛座")
elif birth>=321:
    print(name,"你是温和的白羊座")
elif birth>=219:
    print(name,"你是爱哭的双鱼座")
elif birth>= 120:
    print(name,"你是感性的水瓶座")
else :
    print(name,"你是严谨的摩羯座")

练习2


In [26]:
m=int(input("请输入一个数"))
n=int(input("请输入另一个非零数"))
question=input("您想要进行什么操作?请输入:连续求和/连续乘积/求余/整除")
if question =="连续求和":
    if m>n:
        total=n
        while m>n:
            n=n+1
            total=total+n
        print(total)
    elif m<n:
        total=m
        while m<n:
            m=m+1
            total=total+m
        print(total)
    else:
        print(m+n)


elif question=="连续乘积":
    if m>n:
        pro=n
        while m>n:
            n=n+1
            pro=pro*n
        print(pro)
    
    elif m<n:
        pro=m
        while m<n:
            m=m+1
            pro=pro*m
        print(pro)
    
    else:
        print(n*m)

elif question=="求余":
    print(m%n)
else:
    print(m/n)


请输入一个数3
请输入另一个非零数1
您想要进行什么操作?请输入:连续求和/连续乘积/求余/整除连续乘积
6

练习3


In [21]:
p=int(input("请输入当前北京当前PM2.5数值"))
if p>=500:
    print("应打开空气净化器,带防雾霾口罩")
elif p>=300:
    print("应打开空气净化器,佩带口罩")
elif p>=100:
    print("应避免户外运动,请佩戴口罩")
else:
    print("天气不错")
    
print("thank you")


请输入当前北京当前PM2.5数值122
应避免户外运动,请佩戴口罩
thank you

练习4


In [ ]:
word=input("请输入一个英文单词,我们将提供将其转化为复数形式的建议")
if "word" .endswith("y"):
    print('把y改成i加-es')
elif "word" .endswith("ch/sh"):
    print("在单词后直接加es")
elif "word" .endswith("o"):
    print("如果是tomato, potato, hero等结尾为o有生命,物体则直接加es")
else:
    print("直接加s")

In [ ]: