标签:ring rap 20px lis 关键点 print out color 1.7
关键点:变量、字符串、数字
1.1 变量的命名和使用1.2 字符串1.3 数字1.4 注释
??变量,顾名思义是一个可变的量,每个变量都存储一个值--与变量关联的信息。
1message = "hello world!"
2# message 是一个变量
3print(message)
??在python中使用变量时,需要遵循一些规则和指南。
??字符串就是一系列字符。在python中,用引号扩起的都是字符串,其中引号可以是单引号,也可以是双引号。
1" this is a string "
2‘ this is also a string "
1name = "ada lovelace"
2#以首字母大写
3print(name.title())
4#输出 Ada love lace
5
6#全部大写
7print(name.upper())
8
9#全部小写
10print(name.lower())
1first_name = "ada"
2last_name = "lovelace"
3full_name = frist_name + " " + last_name
4print(full_name)
13**2 = 9
23**3 = 27
10.1+0.1 = 0.2
20.2+0.2 = 0.4
但需要注意的是,结果包含的小数位数可能是不确定的:
10.2+0.1 = 0.30000000000000004
23 * 0.1 = 0.30000000000000004
1age = 23
2#str()将23转化为"23"
3message = "happy " + str(age) + "rd birthday!"
??在python中,注释用#号标识。#后面的内容都会被python解释器忽略。
1#向大家问好
2print("hello python people!")d
标签:ring rap 20px lis 关键点 print out color 1.7
原文地址:https://www.cnblogs.com/ywx123/p/10023791.html