摘要: 代码: list=["hello","world"] for i in list: print(i) things=["苹果","香蕉","橙子","梨子","猕猴桃","柚子","猴魁","铁观音","毛笔","宣纸"] for j in range(10): print(j,":",things 阅读全文
posted @ 2021-10-20 12:44 scholar-for-ever 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 代码: object=["石榴",1,"香蕉","橙子","梨子","石榴"] object1=object print(object) print(set(object1)) object[0]="苹果" del object[1] print(object) object.append(15) 阅读全文
posted @ 2021-10-20 11:53 scholar-for-ever 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 代码: #!/usr/bin/env python #_*_ coding:utf-8 _*_ import random import time import os print("你好,现在你有10秒的时间记忆下列物品及其编号") things=["苹果","香蕉","橙子","梨子","猕猴桃" 阅读全文
posted @ 2021-10-20 09:22 scholar-for-ever 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 代码: age=int(input("Your age is:")) HRrest=float(input("Your HRrest is:")) gender=str(input ("Your gender is:")) if gender=="male": n=220 else: n=210 l 阅读全文
posted @ 2021-10-20 09:12 scholar-for-ever 阅读(1705) 评论(0) 推荐(0) 编辑
摘要: 代码: lista=[20,40,30,50,10] listb=["bb","ee","aa","dd","cc"] #lista.sort() listc=sorted(lista) listd=sorted(lista,reverse=True) liste=sorted(listb) lis 阅读全文
posted @ 2021-10-20 08:44 scholar-for-ever 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 代码: def get_unique_list(n): result=[] for item in lista: if item not in result: result.append(item) return result lista=[10,20,30,10,20] print(f"Sourc 阅读全文
posted @ 2021-10-19 21:41 scholar-for-ever 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 代码: def remove_elements_from_list(i,j): for itam in j: i.remove(itam) return i lista=[3,5,7,9,11,13] listb=[7,11] print(f"from {lista} remove {listb}, 阅读全文
posted @ 2021-10-18 21:46 scholar-for-ever 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 代码: def get_even_numbers(i,j): result=[] for item in range(i,j): if item % 2==0: result.append(item) return result begin=4 end=15 data=[item for item 阅读全文
posted @ 2021-10-18 21:25 scholar-for-ever 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 代码: def sum_list(n): result=0 for i in n: result+=i return result list1=[1,2,3,4] list2=[17,5,3,5] print(f"The sum of {list1} is:" ,sum_list(list1)) p 阅读全文
posted @ 2021-10-18 20:42 scholar-for-ever 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 代码1: 1 def sum_of_square(n): 2 result=0 3 while n>0: 4 result+=n**2 5 n-=1 6 return result 7 8 print("Sum of square (3) is: " ,sum_of_square(3)) 9 pri 阅读全文
posted @ 2021-10-18 08:07 scholar-for-ever 阅读(34) 评论(0) 推荐(0) 编辑