python入门小程序2

1、猜年龄

 age_of_princal=78

 guess_age =int(input(">>:"))

 if guess_age == age_of_princal:

  print("you are right")

2、猜年龄加强版

age_of_princal=78

 guess_age =int(input(">>:"))

 if guess_age == age_of_princal:

  print("you are right")

elif guess_age > age_of_princal:

  print("you should try samller")

else:

  print("you should try bigger")

3,判定成绩等级

score=int(input("score:"))

if score>90:

  print("A")

elif score>80:

  print("B")

elif score>70:

  print("C")

else:

  print("滚")

4、print(“A”+“B”)输出的结果为AB

      print("A","B")输出的结果为A B

5、基本的运算    除法:   5/2=2.5       5//2=2整除    取余数9%2=1

                          指数运算:2**10=1024         指数运算符优先于乘法运算符

                          优先级(2+3)*5

    在Python没有大括号和中括号 只有小括号能够使用优先级,只使用小括号。

    (((2+3)*5)/2)*3从里面往外面一层层计算。

                         比较大小:a=3 b=5

                                          a>b  

                                              false

                                          b>a        

                                         ture

                          不等于是  !=        

                          大于等于  >=

                          小于等于  <=            

                   if a>b>c

                     print("ture")

          

posted @ 2018-03-27 22:34  大尾巴狼渣渣  阅读(247)  评论(0编辑  收藏  举报