Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 什么是;“真正的”;用伪码表示?_Python_Pseudocode - Fatal编程技术网

Python 什么是;“真正的”;用伪码表示?

Python 什么是;“真正的”;用伪码表示?,python,pseudocode,Python,Pseudocode,我试图翻译这个伪代码,但不能准确地翻译。特别是,我似乎不明白这里的real是什么意思。这是伪代码: Function Real average(Real values[], Integer size) Declare Real total = 0.0 Declare Integer counter = 0 While counter < size Set total = total + values[counter] Set cou

我试图翻译这个伪代码,但不能准确地翻译。特别是,我似乎不明白这里的
real
是什么意思。这是伪代码:

Function Real average(Real values[], Integer size)
    Declare Real total = 0.0
    Declare Integer counter = 0

    While counter < size
        Set total = total + values[counter]
        Set counter = counter + 1
    End While

    Return total / size
End Function

Declare Real scores[6] = 90, 80, 70, 100, 60, 80
Display average(scores, 6)
函数实平均值(实值[],整数大小)
声明实际总计=0.0
声明整数计数器=0
而计数器<大小
设置总计=总计+数值[计数器]
设置计数器=计数器+1
结束时
返回总数/大小
端函数
申报真实分数[6]=90,80,70,100,60,80
显示平均值(分数,6)
这就是我想到的:

def average(values[], int(size))
    total = 0.0
    counter = 0

    while counter < size:
        total = total + values[counter]
        counter = counter + 1

    return total / size

scores[6] = 90, 80, 70, 100, 60, 80
print(average(scores, 6))
def平均值(值[],int(大小))
总计=0.0
计数器=0
而计数器<大小:
总计=总计+数值[计数器]
计数器=计数器+1
返回总数/大小
分数[6]=90,80,70,100,60,80
打印(平均分(6分))

一些语言使用术语“real”代替“float”等。因此,在Python中,使用这段代码可以省去它。 …但是你的代码有一些错误。例如,你只是想

scores=[90,80, 70, 100, 60, 80]
然后给出平均“分数”和6分

像这样

def average(values ,size):
    total = 0.0
    counter = 0

    while counter < size:
        total = total + values[counter]
        counter = counter + 1

   return total / size

scores = [90, 80, 70, 100, 60, 80]
print(average(scores, 6))
def平均值(值、大小):
总计=0.0
计数器=0
而计数器<大小:
总计=总计+数值[计数器]
计数器=计数器+1
返回总数/大小
分数=[90,80,70,100,60,80]
打印(平均分(6分))

虽然显然没有必要这样做,但我认为您只是在学习Python…

A?或者是一台电脑,可能是一台电脑?(对于那些通常是等价的计算机)我也这么认为,但我想我的语法仍然不正确,我建议你,因为你会犯一些非常基本的错误。请记住:Python是一种动态类型语言,您不需要声明具有特定类型或算术的变量。您不需要为此使用“算法”,它只是
sum(values)/len(values)
使用
Real
可以追溯到什么时候是学习编程语言的首选。