首页 > 代码库 > 变量和数据类型 1.py

变量和数据类型 1.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_nameprint(full_name)print("python")        print("\tpython")     #制表符print("Language:\npython\nC\nJavaScrite")#换行符print("Language:\n\tpython\n\tC\n\tJavaScrite")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 = 26my_height = 175my_weight = 74my_eyes = bluemy_teeth = whitemy_hair = blackprint("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 Einsteinmessage = 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 = 23message = ("Happy" + age+ "rd Birthday")print(message)print(2+2)          #数字的基本运算print(2-2)print(2**2)print(2/2)

 

变量和数据类型 1.py