python变量和简单数据类型

#coding=utf-8
#python之禅
import this

#打印变量
massage="hello world python"
print(massage)
#打印修改后的变量
massage="hello world python!"
print(massage)


#改变字符大小写
name="abc sjijwi"
print(name.title())
print(name.upper())
print(name.lower())


#字符拼接
first_name=("dai")
last_name=("mengyao")
full_name=first_name+" "+last_name

print(full_name)


#应用于问候
massage="hello"+" "+full_name.title()+"!"


#制表符的使用
print("hello,my python world")
print("\thello,my python\tworld")


#换行符的使用
print("hello,my python world")
print("\nhello,\nmy python\nworld")


#虽然单引号或者双引号都可以用来引用变量,但是这里应当用双引号才能正确识别
message = "One of Python's strengths is its diverse community."
print(message)
#虽然单引号或者双引号都可以用来引用变量,但是这里应当用单引号才能正确识别
message='Albert Einstein once said, "A person who never made a mistake never tried anything new."'
print(message)


#整数\浮点数运算
print(2+4*3)
print(0.2+0.4*3)


#数字指定为字符才不会出错
age=24
print("happy "+str(age)+"rd birthday")
num=10
print("my lucy num is "+str(num))
print(2)










猜你喜欢

转载自blog.csdn.net/qq_24135817/article/details/79511985