随笔分类 -  Python之路

摘要:import randomimport math# python3支持的数值类型int 整型 正负整数,不限大小float 浮点型,正负小数 不限大小complex 复数 a+bj 或者complex(a,b) # Python 数字类型转换有时候,我们需要对数据内置的类型进行转换,数据类型的转换,你只需要将数据类型作为函数名即可。int(x) 将x转换为一个整数。float(x) 将x转换到一个... 阅读全文
posted @ 2019-05-25 00:38 binyang 阅读(576) 评论(0) 推荐(0) 编辑
摘要:#关键字及其作用关键字集合False def if raiseNone del import returnTrue elif in tryand else is whileas except lambda withassert finally nonlocal yieldbreak for not class from or continue global pass 作用:False,True :... 阅读全文
posted @ 2019-05-25 00:25 binyang 阅读(387) 评论(0) 推荐(0) 编辑
摘要:pythony运算符包括# 算术运算符 加,减,乘,除,模(% 取余),幂(**),取整(//)+ 加 - 两个对象相加 a + b 输出结果 31- 减 - 得到负数或是一个数减去另一个数 a - b 输出结果 -11* 乘 - 两个数相乘或是返回一个被重复若干次的字符串 a * b 输出结果 210/ 除 - x 除以 y b / a 输出结果 2.1%... 阅读全文
posted @ 2019-05-25 00:18 binyang 阅读(240) 评论(0) 推荐(0) 编辑
摘要:Python3 中有六个标准的数据类型:Number(数字)String(字符串)Tuple(元组)List(列表)Set(集合)Dictionary(字典)Python3 的六个标准数据类型中:不可变数据(3 个):Number(数字)、String(字符串)、Tuple(元组);可变数据(3 个):List(列表)、Dictionary(字典)、Set(集合# python 数据类型 4大数字... 阅读全文
posted @ 2019-05-25 00:05 binyang 阅读(374) 评论(0) 推荐(0) 编辑
摘要:树的遍历 1 class Node: # This is the Class Node with constructor that contains data variable to type data and left,right pointers. 2 def __init__(self, data): 3 self.data = data 4 ... 阅读全文
posted @ 2019-05-21 01:06 binyang 阅读(173) 评论(0) 推荐(0) 编辑
摘要:classNode:# This is the Class Node with constructor that contains data variable to type data and left,right pointers.def __init__(self, data):self.data = dataself.left... 阅读全文
posted @ 2019-05-21 00:31 binyang 阅读(145) 评论(0) 推荐(0) 编辑
摘要:测试代码表现 1 def depth_of_tree(tree): #This is the recursive function to find the depth of binary tree. 2 if tree is None: 3 return 0 4 else: 5 depth_l_tree = depth_of_tree(tr... 阅读全文
posted @ 2019-05-21 00:20 binyang 阅读(288) 评论(0) 推荐(0) 编辑
摘要:def display(tree):#In Order traversal of the treeif tree isNone: returnif tree.left isnotNone:display(tree.left)print(tree.data)if tree.right isnotNon... 阅读全文
posted @ 2019-05-21 00:14 binyang 阅读(363) 评论(0) 推荐(0) 编辑
摘要:def depth_of_tree(tree): #This is the recursive function to find the depth of binary tree. if tree is None: return 0 else: depth_l_tree = depth_of_... 阅读全文
posted @ 2019-05-20 23:51 binyang 阅读(110) 评论(0) 推荐(0) 编辑