Home > Backend Development > Python Tutorial > Python syntax exercise--string formatting

Python syntax exercise--string formatting

黄舟
Release: 2016-12-28 17:23:41
Original
1486 people have browsed it

#!/usr/bin/env python  
# -*- coding:utf8 -*-  
  
w_sex = "女"  
m_sex = "男"  
w_age = 23  
m_age = 25  
  
sex_input = input("请输入您的性别:").strip()  
age_input = int(input("请输入您的年龄:"))  
  
if sex_input == w_sex and age_input >= w_age:  
    print ("您的信息如下:\n性别:%s\n年龄:%s\n您属于晚婚年龄" %(sex_input,age_input))  
elif sex_input == m_sex and age_input >= m_age:  
    print ("您的信息如下:\n性别:%s\n年龄:%s\n您属于晚婚年龄" %(sex_input,age_input))  
else:  
    print ("输入错误,系统退出")
Copy after login

The above is the Python syntax exercise-string formatting content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template