ADM-201 dump PMP dumps pdf SSCP exam materials CBAP exam sample questions

【用代数讲计算机科学】布尔值 – 译学馆
未登录,请登录后再发表信息
最新评论 (0)
播放视频

【用代数讲计算机科学】布尔值

CS in Algebra: Booleans

到底有多少数字
How many numbers are there?
字符串或者图片是怎么样的
How about strings or images?
你目前见到的所有数据类型都有无数的变化
All of the types of data you’ve seen so far have infinite variations
因此程序就会变得非常多样化
which allows for a lot of variety in your programs.
但是有时候你只是需要一个简单的是或非 真或假
But sometimes, you just need a simple yes or no, true or false.
的确有这样类型的值
There’s actually a type just for that.
布尔类型就是一个只有一个值表示真或假的数据类型
A Boolean is a type of data that can only have one of two possible values: true or false.
在我们的程序中它们非常适合用来回答一些简单的对错问题
That makes them really well-suited to answer simple true or false questions for our program,
例如3比4 我们能用哪一个值描述3比4
such as 3 is less than 4 which we could speak as is 3 less than 4?
因为3比4小所以返回的值为真
The value that returns is true since 3 is less than 4.
布尔类型也可以用来比较事物
Booleans are useful for comparing things.
我们可以问是否一个数字小于另一个
We can ask if one number is less than another
是否两个字符串相等 等问题
if two strings are equal and so on.
数学函数像 小于 大于或者等于
Mathematical functions like less than, greater than or equal
都是用两个数字 作为它们的域
all take two numbers as their domain
并通过比较这两个数字返回一个布尔值
and produce a Boolean as their range by comparing the two numbers.
有时我们想以更复杂的方式比较值
Sometimes we want to compare values in more complex ways.
例如 是否一个玩家的x坐标大于零小于100
For example, asking if a player’s X coordinate is greater than 0 AND less than 100.
是否一个字符等于up 或者 down
Or if string equals up OR down.
甚至是否一个数字不是42
And even if a number is NOT 42.
这些部分(并 与 非)允许我们去定制和结合布尔值去问更多
These blocks (AND, OR, and NOT) allow us to modify and combine Booleans to answer more
有趣的和有逻辑的问题
interesting and logical questions.
在这一阶段 你需要去写布尔类型的函数来确保游戏中的精灵
In this stage, you’ll need to write Boolean functions to make sure sprites in a game follow
遵循着你为它们设定的规则 例如不从屏幕上消失
the rules that you set out for them, such as not going off the side of a screen.

发表评论

译制信息
视频概述

本节视频引入并讲述了布尔类型以及布尔类型程序编写中所起到的作用

听录译者

收集自网络

翻译译者

【B】Cod

审核员

自动通过审核

视频来源

https://www.youtube.com/watch?v=jIAaneZSSkY

相关推荐