Python:if-while-for

#!/usr/bin/python3

#if elif else

print("开始猜数字游戏")
num = int(input("请输入数字"))

stand = 30

if num == stand:
    print("你猜对了")
elif num<stand:
    print("猜小了")
else:
    print("猜大了")




#while

n=1
count =0
while n<=100:
    count+=n
    n+=1

print("1-100的和等于=",count)


#for
#计算1-100的和 

count =0 ;
for i in range(101):
    count=count+i
print("1-100的和等于=",count)



#break continue

 

posted @ 2016-09-26 18:09  小花神  阅读(156)  评论(0编辑  收藏  举报