上一页 1 ··· 49 50 51 52 53 54 55 56 57 ··· 80 下一页
摘要: 数据容器 1. list 列表[] ''' 字符串 split后成为列表 对列表list做倒叙的[::-1] ''' #定义方法获取 列表 指定下标的 list_name=[0,1,2,3,4,5] list_name2=[-4,-3,-2,-1] list_name3="abcd,efg" def 阅读全文
posted @ 2023-04-10 21:39 胖豆芽 阅读(29) 评论(0) 推荐(0)
摘要: ''' 元组学生 ("fqs",11,["football","music"]) 1.查询年龄所在的下标 2.查询学生姓名 3.删除学生爱好中的football 4.增加爱好 coding ''' #定义方法 def get_student(): tuple_student=("fqs",11,[" 阅读全文
posted @ 2023-04-07 23:02 胖豆芽 阅读(76) 评论(0) 推荐(0)
摘要: ''' 元组 ''' #定义方法 def get_num(): # 1.定义一个元祖 tuple_one=("fqs",18,"f",18,18,18,18) print(f"tuple_one元祖:{tuple_one}") # 2.单个元祖内元素要注意 ("fqs") 类型是str 字符串;(" 阅读全文
posted @ 2023-04-07 22:51 胖豆芽 阅读(58) 评论(0) 推荐(0)
摘要: ''' 求列表中的偶数,并放到新的列表中 ''' #定义方法 def get_ou(): list_num=[1,2,3,4,5] list_ou=[] index=0 while index<len(list_num): if list_num[index] % 2 == 0: print(f"偶 阅读全文
posted @ 2023-04-07 22:06 胖豆芽 阅读(248) 评论(0) 推荐(0)
摘要: ''' while循环打印整个数组 ''' name_list=["fqs","doudou","oldwang"] #下标从0开始 index=0 #求数组的长度 len_list=len(name_list) while index<len_list: print(f"第{index+1}个元素 阅读全文
posted @ 2023-04-07 21:14 胖豆芽 阅读(95) 评论(0) 推荐(0)
摘要: 增1.列表.append(元素) 向列表追加元素2.列表.extend(元素) 将数据容器的内容一次取出,追加到元素的尾部3.列表.insert(下标,元素) 在指定下标处,插入指定的元素删4.del列表[下标] 删除列表指定下标元素5.列表.pop(下标) 删除列表指定下标元素6.列表.remov 阅读全文
posted @ 2023-04-06 22:43 胖豆芽 阅读(28) 评论(0) 推荐(0)
摘要: ''' ATM 当前的剩余金额是个不断变化的过程 需要在存款 取款函数中声明为全局变量自己写的 ''' money_now=5000 name="fqs" def look_money_now(): print(f"{name}您的余额是{money_now}") def money_up(): m 阅读全文
posted @ 2023-04-05 15:23 胖豆芽 阅读(49) 评论(0) 推荐(0)
摘要: ''' 函数嵌套 更改全局变量使用 声称全局变量 global ''' number = 100 def b (): print(f"方法b中number:{number}") def a (): #注意 只有调用函数数 global 才能生效 global number number = 200 阅读全文
posted @ 2023-04-05 14:38 胖豆芽 阅读(65) 评论(0) 推荐(0)
摘要: ''' 函数返回值 ''' def add(a,b): #结果result=a+b result=a+b #返回 结果值 return result r=add(1,2) print(r) 阅读全文
posted @ 2023-04-04 22:43 胖豆芽 阅读(26) 评论(0) 推荐(0)
摘要: ''' 函数传参 ''' def is_ok(persion,du): if du>37.5 : print(f"{persion},你需要隔离") else: print(f"{persion},温度正常,请进") is_ok("fqs",39) is_ok("doudou",37) 阅读全文
posted @ 2023-04-04 22:33 胖豆芽 阅读(19) 评论(0) 推荐(0)
上一页 1 ··· 49 50 51 52 53 54 55 56 57 ··· 80 下一页