Python in-out 'introduce yourself'

The first:

user = input("请输入你的名字")
age = int(input("请输入你的年龄"))
height = float(input("请输入你的身高"))
print("名字:%s年龄:%d身高:%.2f"%(user,age,height))

%s String placeholder
%d Integer placeholder
%f Floating point placeholder
(%nf automatically reserves n decimal places)


The second type:

print("hello")
print("姓名:张三")
print("年龄:18")
print("身高:1.89")
print("体重:74")
# print("输出内容") 打印
age = 18
tall = 1.89
print(type(age))
print(type(tall))

type(variable name) returns the type of the variable
int integer
float floating point
True True
False False


The third type:

print("姓名 张三",end="\n")
print("年龄 18岁")
print("身高 189cm")
print("体重 72kg")
print("爱好 打游戏 手工 篮球 看喜剧 听歌")


end="\n" comes with a newline
\n means a newline
When the end is not written, the bottom layer of the print, the end parameter is equal to \n is a newline

Guess you like

Origin blog.csdn.net/Sjm05/article/details/127445961