作业
iWillook
这个作者很懒,什么都没留下…
展开
-
定义一个列表存储n个整数,求列表的长度,最大值,最小值和平均值
## main.py# List Handling## Created by Mewlan Musajan on 4/29/21.#def listHandling(g): listLength = 0 all = 0 maximum = max(g) minimum = min(g) for b in g: listLength += 1 all += b average = all / listLength print(str("列表的长度{0},最大值{1}.原创 2021-04-29 19:27:29 · 1074 阅读 · 0 评论 -
Python的线性查找(作业)
线性查找指按一定的顺序检查数组中每一个元素,直到找到所要寻找的特定值为止。定义Search(arr,n,x)函数实现在列表arr中查找x元素,如果存在输出元素在arr中的位置,否则输出-1.其中,n为arr的长度。 定义列表arr = [ 'A', 'B', 'C', 'D', 'E' ];来存储几个字母,提示用户输入一个字母,调用Search函数进行查找。 ## main.py# Linear Search## Created by Mewlan Musajan on 4/2.原创 2021-04-29 19:16:07 · 558 阅读 · 0 评论 -
Python定义一个Calculator类表示计算器(作业)
定义一个Calculator类表示计算器,在该类中定义四个方法add(x, y)、subtract(x, y)、multiply(x, y)、divide(x, y)四个方法分别实现两个数的加法、减法、乘法和除法。创建Claculator对象,提示用户输入两个操作数和运算符(+,-,*,/),调用对应的方法得到计算结果。请设计一个友好的信息交互方式。## main.py# Calculator## Created by Mewlan Musajan on 4/29/21.#.原创 2021-04-29 18:26:42 · 7039 阅读 · 0 评论 -
Python 阿姆斯特朗数 Assignment
## main.py# Armstrong Number Validation## Created by Mewlan Musajan on 4/29/21.#g = int(input("BIR PÜTÜN SAN KIRGÜZÜNG: "))b = 0a = len(str(g))s = gwhile s > 0: p = s % 10 b += p ** a s //= 10if g == b: print(g, "BOLSA ARMSTRONG SA.原创 2021-04-29 17:00:03 · 470 阅读 · 0 评论 -
使用Python的随机数模块 random 实现猜数字游戏
随机生成1~10之间的一个整数,提示用户去猜,用户最多可以猜3次;如果在3次内猜对答案,程序结束,显示如“答对了,您猜了2次!”的信息;如果猜错,显示信息如“太大了”,“太小了”等提示。## main.py# Random Access Memory## Created by Mewlan Musajan on 4/29/21.#import randomg = random.randint(1, 10)b = int(input('1 DIN 10 GHICHE原创 2021-04-29 16:48:48 · 2398 阅读 · 0 评论 -
通过用户输入三角形三边长度,并计算三角形的面积,其中长度为实数
## main.py# Some Python Program## Created by Mewlan Musajan on 4/29/21.#g = int(input('UZUNLUQ 1: '))b = int(input('UZUNLUQ 2: '))a = int(input('UZUNLUQ 3: '))def isLengthValid(): global g global b global a while g+b<a o.原创 2021-04-29 15:55:54 · 803 阅读 · 0 评论