Codecademy Ruby 1 Flashcards

(48 cards)

1
Q

What’s a boolean?

A

A true or false statement

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

It’s also important to remember that Ruby is..

A

case-sensitive

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

never use _______ with booleans,

A

quotation marks (‘ or “) or Ruby will think you’re talking about a string (a word or phrase)

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

What’s the name of this kinda thing? 2**8

A

exponentiation

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

What’s an easier way to do 222

A

2**3

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

What’s the name of the operator that returns the remainder of division?

A

Modulo

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

What’s 25 % 7?

A

4

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

What’s the difference between print and puts?

A

puts adds inserts a blank line after the output

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

Everything in Ruby is an _______ with built in ____

A

object / method

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

Editor>______>console

A

interpreter

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

Display the number of characters in ‘Tom’

A

puts “tom”.length

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

method for reversing values

A

.reverse

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

method for changing case

A

.upcase and .downcase

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

what do you use for a multi-line comment?

A

=begin
comment
yes yes yes
=end

(no space between the = and begin. Maths is ok either way with that though)

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

what’s the convention for variables in Ruby?

A

lower case with _ between words, with no other symbols

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

what character do you use to set variables?

A

=

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

what’s do you call a positive or negative number with no decimal bit?

A

an integer

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

what operator do you use to call a string?

A

.

For example “string”.method

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

method to get inputs

A

gets

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

method to remove the line break added automatically when receiving user input

21
Q

how do you print a variable into a string

22
Q

what do you call when a variable is replaced with a bit of information?

A

string interpolation

23
Q

what’s the method for capitalising the first letter of a string?

24
Q

what do you use to change the value of a variable inside itself?

25
a fancy word for something that has a value that evaluates to either true or false
expression
26
the convention for spacing inside an if statement
two spaces (not tabs)
27
use to add more options to an else/if statement
elsif (NOT elseif)
28
in ruby, what can you use instead of checking whether something is negative using an if statement? (maybe just used for booleans?)
unless for example: unless hungry --code (hungry would have to be set to true for the code to execute)
29
what do you use instead of = as a comparator (otherwise called a rational operator)?
==
30
not equal to
!=
31
greater or equal to
>=
32
less than or equal to
<=
33
What is a boolean operator?
Boolean operators result in boolean values: true or false.
34
What does && do?
The boolean operator and, &&, only results in true when both expression on either side of && are true.
35
or operator
|| | Ruby's or operator evaluates to true when either or both of the values are true... called an inclusive
36
not true
!true
37
what would this equate to? | !(700 / 10 == 70)
false | because ! is a boolean operator
38
(x && (y || w)) && z Expressions ____ parentheses are always evaluated before anything ____ parentheses.
Expressions in parentheses are always evaluated before anything outside parentheses.
39
What are the three boolean operators in Ruby?
&&, || and !
40
what is a float?
a number with a decimal
41
change gets to get an integer input
gets.to_i
42
change gets to get a float input
gets.to_f
43
generate a random floating point number between 0 and 1
rand()
44
generate an integer between 0 and 10
rand(10)
45
generate an integer between 20 and 100
rand(20..100)
46
create a while loop
while | end
47
how to you convert an integer to a string?
.to_s
48
how to you make the code wait for 1 sec?
sleep 1