This action will force synchronization from pish7/stdpython, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
from math import *print("Hello Python world!")message = "One of Python's strengths is its diverse community."print(message)# 下面将两条语句写在一行,语句之间用分号隔开# message = "Hello Python world!"; print(message)print("a", "b", "c", sep="+", end="") # 自定义分隔符和结尾(结尾不换行)print("a", "b", "c", sep="+", end="")# a+b+ca+b+c# 使用 Python 变量前必须给它赋值,因为 Python 变量没有默认值。# 变量不需要声明数据类型s1: int = 255s2: int = 0xFFs3: int = 0b11111111s4: int = 0o377# 同时给多个变量赋值x, y, z = 1, 2, 3# 复合赋值运算符foo = 10foo += 3foo -= 4# 整数的几种进制# 整数始终是有符号的,实际上没有最大值print(255, 0xFF, 0b11111111, 0o377) # 255 255 255 255# 浮点数print(3.3, 3e2)f1 = float("inf") # 正无穷f2 = float("-inf") # 负无穷f3 = float(nan) # 非数,由于导入了 math 模块,所以可以使用 nan 而不是 "nan",inf 同理print(f1, f2, f3)# 数值之中只可以添加下划线print(1_000_000)# 乘方print(3**2) # 9# 浮点数print(0.2 + 0.1) # 0.30000000000000004# 将任意两个数相除,结果总是浮点数,即便这两个数都是整数且能整除# 在其他任何运算中,如果一个操作数是整数,另一个操作数是浮点数,结果也总是浮点数print(4 / 2) # 2.0# 位运算print(9 & 8)print(9 | 8)print(9 ^ 8)print(~9)print(9 << 2)print(9 >> 2)# 注意,del 只删除名称,而不删除值!可理解为解除名称与值的绑定。# 如果有多个名称被绑定到同一个值,并且如果只删除其中一个名称,则其他名称及其值不受影响。# 换句话说,del 不会强制垃圾回收器删除对象。x = [1, 2, 3]del x # 删除的是 x,[1,2,3] 是不会被删除的,但会在垃圾回收时被清除x = [1, 2, 3]del x[1]# 若本文件用作运行程序,则执行以下代码,若是当作模块导入,则不执行if __name__ == "__main__":pass# x = input("请输入一个小数,以及取整方式(0=向下取整,1=向上取整):")# y = x.split()# try:# if int(y[1]) == 0:# func = math.floor # 函数可使用值赋给某个变量# if int(y[1]) == 1:# func = math.ceil# print(func(float(y[0]))) # float() 用于转换小数,int() 只能转换整数# except:# print("输入有误")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。