demo0-python的一些

#ecoding=utf-8
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)

==================================================================================


==================================================================================

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值