Home >Backend Development >Python Tutorial >Python syntax exercise--if judgment

Python syntax exercise--if judgment

黄舟
黄舟Original
2016-12-28 17:27:081299browse

#!/usr/bin/env python  
# -*- coding:utf8 -*-  
  
age = int(input("输入您的年龄"))  
  
if age < 18:  
    print ("您是一名未成年")  
elif age > 18:  
    print ("您是一名成年人")  
else:  
    print ("输入错误,请重新输入")  
-----------------------------------------------  
name_list = ["Jin","Tom","Cat","Jak","Sum"]  
  
if "Jin" in name_list:  
    print ("Jin")  
else:  
    print ("error")

The above is the content of Python grammar exercise-if judgment. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn