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 ..") else: print("no,it`s wrong ") ''' ''' 缩进:缩进要求是必须要缩的,不可缺少的 ps:全球所有的语言都不需要强制缩进,就python必须缩进 因为其他的语言一般是使用{}来做为标识,但是python么有 只能通过缩进才识别 警告:“ ” 和" "一个缩进和4个空格看起来一样,但是不能如此, 缩进级别必须保持一直,要不你就全部tab,要不全部4个空格, 当然如果全部都是一个空格也是可以。官方规定是4个空格。不建议用tag 因为在不同的系统上面tab的功能可能彼此不识别, 但是4个空格比较辛苦,如果可以使用一下tab打出4个空格即可完美解决 因此可在notepad中设置首选项语言中将制表符更改为空格 显示:在视图中显示符号打开制表符的显示可以看出tab为” “,而4个空格为“ ” ''' #三重判断 if guess_age == age_of_princal: print("yes you got it ..") elif guess_age>age_of_princal: print("should try samller..") else: print("should try biger..") score = int(input("score:")) if score > 90: print("A") elif score > 80: print("B") elif score > 70: print("C") elif score > 60: print("D") else: print("go out") ''' elif 为else if的简写 elif可以实现多重循环,用以多种情况的判断 if循环的结尾必须是else、而不能是elif, '''