Python if语句知识点用法总结时间:2022-11-09 08:30:28计算机之所以能做很多自动化的任务,因为它可以自己做条件判断。 比如,输入用户年龄,根据年龄打印不同的内容,在Python程序中,可以用if语句实现: ? 1 2 3 4 5 age = 20 if age >= 18: print 'your age is', age print 'adult' print 'END' ? 1 2 3 4 5 6 7 >>> age = 20 >>> if age >= 18: ... print 'your age is', age ... print 'adult' ... your age is 20 adult ? 1 2 3 score = 75 if score >= 60: print 'passed'