different symbols and functions Flashcards

1
Q

Define % and what it’s used for

A

% is a module used to find how many times a number can go into another. fro example 4 % 2 = 0 and 5 % 2 = 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define ! and how it’s used

A

The symbol ! is = to “not”
For example num != 0 or num is not equal to 0.
or
if (num % 3) == 0 && !(num % 5 == 0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define ==

A

== is when you want to know if 2 variables are the same.
for example if num = 32
num == 32 then this is true
but
if
num == 22 then this is false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define <=

A

less than or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define >=

A

Greater or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define >

A

Greater then

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define <

A

Less then

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define [] and what its used for

A

It gets the index in an array
For example

num[“hello”, “no”, “yes”]
num[2] would equal to “yes”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define .length

A

.length is used to get the length of a string or and array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define .chr

A

.chr is equal to a character of a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define i

A

i is used to define a number
i = 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what are the Booleans in Ruby

A

in Ruby there are 2 Boolean values, true and false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does an ‘if’ statement work?

A

if statement executes code if the Boolean is equal to ‘true’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Define def and return

A

def defines a method and return exits a method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define elsif statement and what it does

A

elsif is a conditional statement that pairs with a previous if statement, it takes on a Boolean expression if the previous was false, for it to run the Boolean expression now has to be true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define ‘while’ and waht it does

A

while is a loop that you use to give an order as long as its true, if false it executes code after the end loop

17
Q

Define .push() and how it works

A

.push() can add multiple data into an array while &laquo_space;can only add 1 per time

18
Q

Define .pop() and how it works

A

.pop() takes away the last data in the array and is also now equal to it

19
Q

Define .unshift() and how it works

A

.unshift() adds data to the front of the array, it must include a parameter

20
Q

Define .shift() and how it works

A

.shift() takes away first data of an array

21
Q

Define .index() and how it works

A

.index gets the index of an array for Ex: array.index(“Hello”)
array = [“hello”, “no”] puts array.index(“llo”) would give us 2

22
Q

Define .include?() and how it works

A

.include?() is going to give you a boolean checking if the variable exist in an array of data

23
Q

Define array.pop()

A

array.pop() takes away the last data entry of an array

24
Q

Define array.push()

A

array.push() gets a parameter and includes it in the back of an array. you must include a parameter

25
Q

define array.reverse()

A

it gives you the reverse data but it does not save it.

26
Q

define array.reverse!()

A

if you want to change the array and keep it that way, you can use this method to reverse and save the data.

27
Q

How to use a range and what symbols to use

A

a range of an array helps you get the data of an array between a certain index, if used like this [0..3] it will get the dat from 0-3 but if yuo use 3 dots,
[0…3] it gets all the data from 0 to not including 3.

28
Q

define .split() and how it works

A

str.split() is used when you want to take variables away in a string. by doing this you can now turn that string into an array.

29
Q

define array.join()

A

by doing this method you can turn an array into a string.

30
Q

explain .each , .each_char and .each_with_index
&& .each_char.with_index

A
31
Q

explain .times

A