在进行 python 学习的时候,我们首先得知道 what is python? why is python? how to study python?
…巴拉巴拉一大堆。
学习一门编程语言,首先要学习它的语法,学习语法的首要学习它的数据类型。
python的基本数据类型有以下几类:
(1)数字(int)类型:int、float、complex
(2)布尔(bloo)类型
(3)字符串(str)类型
(4)列表(list)
(5)元组(tuple)
(6)字典(dict)
(7)集合(set)
将数据格式化输出
name = input("please input your name: ")
age = int(input("please input your age: "))
sex = bool(int(input("please input your sex: ")))
job = input("please input your job: ")
salary = input("please input your salary: ")
if sex == True:
sex = 'male'
else:
sex = 'fmale'
if salary.isdigit():
salary = int(salary)
else:
exit("salary must be int.")
print(name, age, sex, job, salary)
# 格式化输出字符串
personal_info = '''
-------------Personal information of %s---------
.........NAME: %s
.........AGE: %d
.........SEX: %s
.........JOB: %s
.........SALARY: %f
.........WORK STILL: %d YEARS
--------------This is the end-------------
''' % (name, name, age, sex, job, salary, (65-age))
print(personal_info)