首页 > 代码库 > 变量和数据类型 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 = ‘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)
变量和数据类型 1.py
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。