zoukankan      html  css  js  c++  java
  • 变量和数据类型 .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)
  • 相关阅读:
    面向机器学习的特征工程
    卷积可视化,图像理解,deepdream,风格迁移
    损失函数
    开源是如何支撑区块链技术发展的
    揭秘机密计算:弥补最后一个入侵 “漏洞”
    什么是超大规模数据中心?
    比特币是避险资产还是储备资产?
    区块链技术生态持续优化,五大趋势不容忽视
    物联网低功耗广域网(LPWAN)的比较
    碎片化是物联网快速发展的阻碍,也是机会
  • 原文地址:https://www.cnblogs.com/dws-love-jfl-1314/p/5860787.html
Copyright © 2011-2022 走看看