day2

#python中的常量,约定成俗一般都是大写,不可更改
#用while输出 1 2 3 4 5 6 8 9 10
# count=0
# while count<=9:
# count=count+1
# if count==7:
# continue
# print(count)
# pass的意思是,什么都不进行,跳过。继续往下进行,而不是结束本次循环。
#题目:输出1-100的奇数
# count=1
# while count<=100:
# if count%2!=0:
# print(count)
# count=count+1
#输出 1-100的偶数
# count=1
# while count<=100:
# if count%2==0:
# print(count)
# count=count+1
#求 1-2+3-4+5-。。。+99的和
# count=1
# sum=0
# while count<=100:
# if count%2!=0:
# sum=sum+count
# else:
# sum=sum-count
# count=count+1
# print(sum)
#格式化输出的讲解 %
# name=input("请输入姓名 ")
# age=input("请输入年龄 ")
# height=input("请输入身高 ")
# msg="我叫 %s,年龄%s,身高是 %s"%(name,age,height) #按顺序替代 %s相当于占位符
# print(msg)
#输出名片
# name=input("请输入姓名 ")
# age=input("请输入年龄 ")
# height=input("请输入身高 ")
# msg='''------- %s的名片-------
# 姓名: %s
# 年龄: %d
# 身高: %d
# --------------------------
# '''%(name,name,int(age),int(height))
# print(msg)
#while else讲解 固定搭配。当while循环没有被打断 走else 但被break打断,就不走else。一般不会用它。只有在特地需求中才会用它。

posted @ 2019-07-08 22:02  八戒猴子  阅读(109)  评论(0)    收藏  举报