python1

if else:

guess_age = int(input("please input a age:"))

age = 59 #变量名不能以空格开头

#if else 直接用:冒号来区分,相对来说比较简单
if age == guess_age:

print("you got the right age")
else:

print("sorry,you are wrong")

特殊:l连比运算符----------------------------------
#if elfi: else:
if age == guess_age:

print("you are right")
elif age > guess_age:
print("you need a big one")
else:
print("you need a small one")
a = 100
b = 1000

c = int(input("input a number:"))

if a <= c <= b :

print(" it's true")
else:
print ("flase")

input---------------------------------------------------------------

name = input ("your name:")

age = input ("your age:")
#input 所接收到的,所有输入的,都会被识别为字符串,即使输入的是数字

old = 100
#这里用了两种拼接方式,一种是用逗号,另一种是用加号(同一类型的相关拼接好,字符串和字符串之间,或是数字和数字之间。)
print(name,"you can still live",old + int(age),"years")#逗号空格
print(name,"you cat still to live " + str(old + int(age))+ " years")#加号没空格
posted @ 2018-03-13 09:30  牛粪也香  阅读(157)  评论(0编辑  收藏  举报