变量和数据类型 .py

name = "ada lovelace" #单词首字母大写
print(name.title())


name = "Ada Lovelace" #全部大写,全部小写
print(name.upper())
print(name.lower())


first_name = "ada"    #字符串的拼接
last_name = "lovelace"
full_name = first_name  + " " +  last_name
print(full_name)



print("python")        
print("	python")     #制表符
print("Language:
python
C
JavaScrite")#换行符
print("Language:
	python
	C
	JavaScrite")
favourite_language = ' python '          #删除空白
print(favourite_language.lstrip ())
print(favourite_language.rstrip ())
print(favourite_language.strip ())

message = "One of Python's strengths is its community" #引号应用
print(message)


my_name = 'zhangsan'                     #信息的输入
my_age = 26
my_height = 175
my_weight = 74
my_eyes = 'blue'
my_teeth = 'white'
my_hair = 'black'

print("Let's talk about %s."% my_name)
print("He's %d inches tall."%my_height)
print("He's %d pounds heavy."%my_weight)
print("He's %s"%my_age)
print("Actually that's not too heavy.")
print("He's got %s eyes and %s hair."%(my_eyes,my_hair))
print("his teeth are usually %sdepending on the coffee."%my_teeth)
print("if I add %d,%d,and %d Iget %d."%(my_age,my_height,my_weight,my_age+my_height+my_weight))

name = ' Eric'  #字符串拼接

print( 'hello'+ name+ "would you like to learn some Python today")

print("Hello %s  would you like to learn some Python today "%name  )

famous_sayings = 'Albert Einstein once said,"A person who never made a mistake never tried anything new"'
famous_person = 'Albert Einstein'
message = famous_person +  'once said,"A person who never made a mistake never tried anything new"'
print(message)



age = 23              #整数作为字符串
message = ("Happy" + str(age) + "rd Birthday")
print(message)

age = '23'
message = ("Happy" + age+ "rd Birthday")
print(message)


print(2+2)          #数字的基本运算

print(2-2)

print(2**2)

print(2/2)
原文地址:https://www.cnblogs.com/dws-love-jfl-1314/p/5860787.html