import time
print("======================================")
name=input("请输入你的姓名:")
age=input("请输入你的年龄:")
tel=input("请输入你的电话:")
print("======正在生成信息,请稍等========")
time.sleep(2)
print("姓名:%s"%name)
print("年龄:%s"%age)
print("电话:%s"%tel)
print("===================================")
==================================================================================
age = 10
if age>=18:
print("你是成年人,可以浏览XXX网站")
else:
print("你还小,等你长大了再说吧")
age = 10
if age>=18:
print("你是成年人,可以浏览XXX网站")
else:
print("你还小,等你长大了再说吧")
================================================================================================
lang=input("请输入刀子的长度:")
lang=int(lang)
if lang>10:
print("不可上火车")
else:
print("可以上火车")
==================================================================================
score=input("请输入成绩:")
score=float(score)
if score>=90 and score<=100:
print('本次考试,等级为A')
elif score>=80 and score<90:
print('本次考试,等级为B')
elif score>=70 and score<80:
print('本次考试,等级为C')
elif score>=60 and score<70:
print('本次考试,等级为D')
elif score>=0 and score<60:
print('本次考试,等级为E')
==================================================================================
#if嵌套
chepiao=input("请输入车票:")
chepiao=int(chepiao)
length=input("请输入刀子长度:")
length=float(length)
if chepiao==1:
print("有车票可以进站")
print("")
if length<10:
print("通过安检。。。")
print("终于上火车了。。。")
else:
print("没有通过安检。。。")
print("刀子过长。。。")
else:
print("没有车票,不能进站")
==================================================================================
#encoding=utf-8
#猜拳游戏
import random
player=input("请输入:剪刀(0) 石头(1) 布(2)")
player=int(player)
computer=random.randint(0,2)
if player>computer:
print("哈哈,我赢了")
elif player==computer:
print("平局,我们在来一次")
else:
print("输了,不要走,决战到天亮")
==================================================================================
i = 0
sum = 0
while i<=100:
sum+=i
i+=1
print("从0到100的和是:%d"%sum)
==================================================================================
i = 0
sum = 0
while i<=100:
if i%2==0:
sum+=i
i+=1
print("从0到100的偶数和是:%d"%sum)
==================================================================================
"""
*
* *
* * *
* * * *
* * * * *
"""
i = 1
while i<6:
j = 1
while j<=i:
print("* ",end="")
j+=1
print("\n")
i+=1
==================================================================================
#九九乘法表
i =1
while i<=9:
j = 1
while j<=i:
print("%d*%d=%2d "%(j,i,i*j),end="")#2d的意思是占两位,不够两位空格代替
j+=1
print("\n")
i+=1
==================================================================================
#for循环
name="zhangsan"
for temp in name:
print(temp)
==================================================================================
==================================================================================