用户输入输出与多分支if语句及缩进

death_age = 80

name = input(“your name”)
age = input(“your age:”) #input
注:接受的所有数据都是字符串,即便你输入的是数字,但依然会被当成字符串来处理
print(type (age))

#int integer = 整数 把字符串转成int,用int(被转的数据)
#str string =字符串 把数据转成字符串用str(被转的数据)
print(“Your name:”,name)
#print("You can still live for ",death_age - int(age),“years …”)
print("You can still live for " + str(deach_age - int(age)) +“years …”)

death_age=80 
name = input("Your name:")
age = input("your age:")
print(type(age))
print("Your name:",name)
print("You can still live for",death_age-int(age),"years ....")
print("You can still live for"+str(death_age-int(age))+"years ....")

if语句实现猜年龄

age_of_princal = 56

guess_age = int(    input(">>:"))

if guess_age == age_of_princal:
    print("yes,you got it..")
else:
    print("No,it's wrong")    

表达式if …else语句
缩进 IndentationError:expected an indented block
IndentationError:unindent does not match
any outer indentation level syntaxError:invalid
syntax 语法错误

age_of_princal = 56
guess_age = int (    input(">>:") )
 
if guess_age == age_of_princal:
    print("Yes,you got it..")
    print("Yes,you got it..")
    print("Yes,you got it..")
    print("Yes,you got it..")

else:
    print("No,it's wrong.") 

多分支if语句

1.if判断语句

age_of_princal = 56

guess_age = int(    input(">>:"))

if guess_age == age_of_princal:
    print("Yes,you got it..")
elif  guess_age > age_of_princal:
    print("shoud try samller..")
else:
    print("try bigger ... ")  

if猜成绩语句

score = int(input("score:"))

if score > 90:
    print("A")
elif    score > 80:
    print("B")
elif    score > 70:
    print("C")
elif    score > 50:
    print("D")
else:
    print("滚")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值