Python学习第一天

学习了 python 的 if else ,while 和 逻辑运算符
在python 中靠冒号和缩进来替代java中的{}
以if else 为例
java:
if(1 == 1) {
  print("if")
} else {
  print("else")
}
python:
if 1 == 1:
    print("if")
else:
    print("else")
while 和if类似;python逻辑运算  and  or
今天的第一个小例子

import random
sec = random.randint(1,100)
print("我们来猜猜你的颜值(1-100)")
temp = input("你觉得你的颜值能打几分呢:")
guess = int (temp)
while guess != sec:
    if guess > sec:
        print("天哪 给这个人送个镜子吧")
    else:
        print("勇敢点")
    temp = input("再猜猜看:")
    guess = int (temp)
print("bingo -----")

猜你喜欢

转载自458827270.iteye.com/blog/2260014