markdown 公共要点 - 图灵 - 预备工作第4天完成的项目汇编

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 公共要点 - 图灵 - 预备工作第4天完成的项目汇编相关的知识,希望对你有一定的参考价值。

**Numerics and Arithmetic**
What is the difference between integers and floats?
Integers are whole numbers where floats are decimals.  Additionally, they're two different objects; one belonging to the Integer class and the other belonging to the Float class.

What is the ruby command to find 2 to the 2nd power?
2 ** 2

**Booleans**
What do each of the following symbols mean?

* == | equal to | Evaluates whether two values are equal, based on the value to the left of the operand.  If they're, equal the condition becomes true. 1 == 1 => true

* \>= | greater-than-or-equal-to | Evaluates whether one value is greater than or equal to another value. 2 >= 2 => true

* <= | less-than-or-equal-to | Evaluates whether one value is less than or equal to another value.  2 <= 3 => true

* != | not equal to | Evaluates whether on value is not equal to another.  1 != 2 => true

* && | AND | Evaluates and returns a true value if both values on the left AND on the right are true values. Otherwise, it returns a false value.

* || | OR | Evaluates and returns a true value if either of its values on either side has a true value. If both values are false values, then it returns a false value.

What are two Ruby methods that return booleans?
.empty?
.end_with?
.include?
.nil?

**Conditionals**
What is flow control?

Control flow is the order individual statements are evaluated or executed within a program.

What will the following code return? 

apple_count = 4
if apple_count > 5
puts "Lots of apples!"
else
puts 'Not many apples...'
end

Output:  Not many apples...

What is an infinite loop, and how can you get out of one?

An infinite loop is code that runs endlessly, because the loop's condition is never satisfied.  You can exit an infinite loop by pressing: ctrl+c

**Nil**
What is nil?
nil is anspecial value that indicates the absence of value.

**Symbols**
How can symbols be beneficial in Ruby?
Symbols in Ruby are memory-efficient, which is a definite benefit.

Does naming symbols use the same rules for naming variables?
No, the naming convention is not the same.

**Arrays**
What method can you call to find out how many elements are in an array?
You can call the .length method.

What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]?
0

What do 'push' and 'pop' do?
push:  Push adds an item to the end of an array.
pop:   Removes the last item added to an array and returns it.  If the array is empty it returns nil.

**Hashes**
Describe some differences between arrays and hashes.
Arrays access array elements by index.  The indexing for an array is an integer, or the index of the array.  Negative index values start from the end of the array, so the last element of an array is accessible via an index of -1.  

A hash is similar to an array, but its indexing is performed via keys of any object type, and not an integer index.  

What is a case when you might prefer an array? 
Grocery lists.
Arrays are utilized when there's a need to work with a large amount of similar items.

What is a case when you might prefer a hash?
School Grade Book
Hashes are a way to group large amounts of related data.

以上是关于markdown 公共要点 - 图灵 - 预备工作第4天完成的项目汇编的主要内容,如果未能解决你的问题,请参考以下文章

markdown 公共要点 - 图灵 - 预备工作第4天完成的项目汇编

markdown 公共要点 - 图灵 - 预备工作第3天完成的项目汇编

markdown 公共要点 - 图灵 - 预备工作第2天完成的项目汇编

markdown 公共要点 - 图灵 - 预备工作第1天完成的项目汇编

markdown 公共要点 - 图灵 - 完成装备要点的项目汇编

markdown 公共要点 - 图灵 - 完成专业发展的项目汇编