1. 程式人生 > >python-if syntax demo program / single or multiple line comment

python-if syntax demo program / single or multiple line comment

1.guess age

age_of_princal = 56

guess_age = int(   input(">>:") )
'''多行註釋
if guess_age == age_of_princal then

    print("yes")
else
    print("no ")
'''

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 ...")

2.

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("滾")

3.

msg = "我愛北京天安門?"
print(msg) #this code is for ....
"""print(msg)多行註釋
print(msg)
print(msg)"""
print(msg)  
#print(msg)單行註釋

4.

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(death_age - int(age)) +" years ....")