python变量和简单数据类型

#coding=utf-8
#python之禅
import this
python变量和简单数据类型
#打印变量
massage="hello world python"
print(massage)
#打印修改后的变量
massage="hello world python!"
print(massage)
python变量和简单数据类型

#改变字符大小写
name="abc sjijwi"
print(name.title())
print(name.upper())
print(name.lower())
python变量和简单数据类型

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

print(full_name)

python变量和简单数据类型

#应用于问候
massage="hello"+" "+full_name.title()+"!"
python变量和简单数据类型

#制表符的使用
print("hello,my python world")
print("\thello,my python\tworld")
python变量和简单数据类型

#换行符的使用
print("hello,my python world")
print("\nhello,\nmy python\nworld")
python变量和简单数据类型

#虽然单引号或者双引号都可以用来引用变量,但是这里应当用双引号才能正确识别
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)
python变量和简单数据类型

#整数\浮点数运算
print(2+4*3)
print(0.2+0.4*3)
python变量和简单数据类型

#数字指定为字符才不会出错
age=24
print("happy "+str(age)+"rd birthday")
num=10
print("my lucy num is "+str(num))
print(2)
python变量和简单数据类型