message = "hello world"
print(message)

message = "Let's go"
print(message)

# title()以首字母大写显示每个单词
name = "zhou yu ting"
print(name.title())

name = "ZHOU YU TING"
print(name.title())

name = "Zhou Yu Ting"
print(name.upper())
print(name.lower())

# f字符串,f是format的简写
first_name = "zhou"
last_name = "Yuting"
full_name = f"My name is {first_name.title()} {last_name}"
print(full_name)
print(f"\t{full_name}")
print(f"\t{first_name}\n\t{last_name}")
# lstrip清除左边空格 rstrip清除右边空格
favorite_language = " python "
print(f"{favorite_language}{message}")
print(f"{favorite_language.lstrip()}{message}")
print(f"{favorite_language.rstrip()}{message}")

#
print(f"1+1={1+1}")
print(f"2-1={2-1}")
print(f"2*3={2*3}")
print(f"3/2={3/2}")
print(f"1+2*3={1+2*3}")
print(f"(1+2)*3={(1+2)*3}")
print(f"0.1+0.1={0.1+0.1}")
print(f"0.1+0.2={0.1+0.2}")
print(f"0.4-0.2={0.4-0.2}")
print(f"0.1*2={0.1*2}")
print(f"0.4/0.2={0.4/0.2}")
# 任意两个数相除,结果总是浮点数
# 只要操作数有浮点数,结果也是浮点数
print(f"4/2={4/2}")
print(f"4/0.1={4/0.1}")

# 书写很大的数,可用下户线将其中的数字分组,使其更清晰易读 1000可以是1_000,也可以是10_00
universe_age = 14_000_000
print(universe_age)

# 同时给多个变量赋值
x, y, z = 0, 1, 2
print(y)

# python没有内置的常量类型,一般使用全大写来指出某个变量视为常量
MAX_CONNECTION = 5000

# Python之禅
# import this

 

posted on 2023-02-06 11:29  Zoie_ting  阅读(14)  评论(0编辑  收藏  举报