Exercise 22 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

puts

A

put string

Prints a string onto the screen. Includes newline character at the end.

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

print

A

Prints a string onto the screen.

Doesn’t include newline character at the end.

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

””

A

double quotes.

Tell Ruby to interpret what’s within the characters as Ruby code.

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

#

A

octothorpe or pound symbol. Turns lines of code into comments.

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

{}

A

format activator. Tells Ruby to interpolate its contents as code

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

variable

A

A name that holds a piece of information.

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

+

A

plus operator. Used for addition. Can add numbers or combine strings.

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

-

A

minus operator. Used for subtraction.

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

/

A

slash operator. Used for division.

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

*

A

asterik operator.

Used for multiplication. Can multiply numbers or strings. Two asteriks together will find a number’s exponent.

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

%

A

percent.

Can be used as a modulus operator. It finds the remainder after division.

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

*>

A

less than.

Comparison operator. Checks to see if an item is less than another.

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

>

A

greater than. Comparison operator. Checks to see if an item is greater than another.

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

<=

A

less than or equal to. Comparison operator. Checks if an item is less than another. Also checksif the item is equal to the other.

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

=>

A

greater than or equal to. Comparison operator. Checks if an item is greater than another.Also checks if the item is equal to the other.

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

=

A

assignment operator.

Assigns values to a variable.

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

.

A

decimal.

Turns numbers into floats. Also used to call methods on variables.

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

A

single quotes.

Create strings. Won’t do string interpolation.

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

true

A

boolean value.

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

false

A

boolean value.

21
Q

%q{}

A

Creates a string.

Doesn’t interpolate variable names or other Ruby code.

22
Q

’’’

A

triple single quotes.

Used for multi-line strings. Doesn’t interpolate variable names or other Ruby code.

23
Q

gets

A

get string.

Records string input from the user.

24
Q

.chomp

A

A method.

Removes newline character at the end of a string.

25
Q

open(filename)

A

A method.

Takes filename as parameter and returns file object.

26
Q

\n

A

newline.

Whitespace character, aka an Escape Sequence. Separates paragraphs from each other.

27
Q

\t

A

tab. Whitespace character, aka an Escape Sequence. Indents.

28
Q

\

A

backward slash.

Escape sequence. Tells Ruby to print a single backslash inside a string.

29
Q

()

A

Parentheses.

Can be used to enter parameters.

30
Q

.to_i

A

A method.

Converts string to an integer.

31
Q

.to_f

A

A method.

Converts fixnum to a float.

32
Q

ARGV

A

Argument variable.

Tells Ruby to take variables, unpack them, and assign values given by the user to the variable names assigned to ARGV.

33
Q

$stdin

A

standard input.

Used instead of gets when we enter arguments into the command line.

34
Q

”””

A

triple double quotes.

Used for multi-line strings. Interpolates code.

35
Q

read

A

A method.

Used on file objects. Returns a file’s contents.

36
Q

.close

A

A method.

Used on file objects. Closes file.

37
Q

ARGV.first

A

Used when entering only one argument into the command line.

38
Q

.truncate()

A

A method.

When used on file objects, it truncates existing contents to zero length.

39
Q

.length

A

A string method that returns the length of the string.

40
Q

.exist?

A

Returns true if a file exists. Returns false if it doesn’t.

41
Q

w

A

“Write-Only” mode.

Passed as an extra parameter to open(filename). Automatically truncates existing file to zero length, or creates a new file for writing.

42
Q

.write

A

File object method.

Writes a given string into a file.

43
Q

def

A

Keyword used to denote a method’s definition.

44
Q

end

A

Keyword that denotes the end of a method’s definition.

45
Q

*args

A

Creates a list of arguments, used for multiple arguments.

46
Q

.seek

A

Looks for a specific place in the file’s contents.

47
Q

+=

A

Positive increment.

Adds to existing variable value. (variable += 1 is the same as variable = variable + 1 )

48
Q

return

A

Gets data or variables back from the method.

We can use puts before calling a method, and it will actually print out the return value in our script.