python里冒号什么意思_在Python中冒号等于(:=)是什么意思?

编程知识 更新时间:2023-04-06 00:53:21

您发现的是伪代码Pseudocode is an informal high-level description of the operating

principle of a computer program or other algorithm.

:=运算符实际上是赋值运算符。在python中,这只是=运算符。

要将这个伪代码转换成Python,您需要知道被引用的数据结构,以及更多的算法实现。

关于psuedocode的一些注记

:=是python中的赋值运算符或=

=是python中的相等运算符或==

请注意,有某些类型的伪代码,您的里程数可能会有所不同:

帕斯卡式伪码procedure fizzbuzz

For i := 1 to 100 do

set print_number to true;

If i is divisible by 3 then

print "Fizz";

set print_number to false;

If i is divisible by 5 then

print "Buzz";

set print_number to false;

If print_number, print i;

print a newline;

end

C型伪码void function fizzbuzz

For (i = 1; i <= 100; i++) {

set print_number to true;

If i is divisible by 3

print "Fizz";

set print_number to false;

If i is divisible by 5

print "Buzz";

set print_number to false;

If print_number, print i;

print a newline;

}

注意大括号用法和赋值运算符的不同。

更多推荐

python里冒号什么意思_在Python中冒号等于(:=)是什么意思?

本文发布于:2023-04-06 00:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/cb97aafa8d077fdf7976d563f070de38.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:冒号   什么意思   python   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 47936文章数
  • 14阅读数
  • 0评论数