generated from LEARNAcademy/ruby-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro-roderick.rb
56 lines (52 loc) · 1.69 KB
/
intro-roderick.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Remember that floats are fractional numbers whereas integers are whole numbers. In Ruby, 1 and 1.0 are defined by different data types with slightly different behaviors.
# Complete the following challenges in the IRB console.
my_name = 'roderick'
p my_name
# Open the IRB terminal. Exit the terminal and reopen the terminal.
irb exit
# Add, subtract, multiply, and divide integers.
1 + 1
=> 2
5 - 2
=> 3
3 * 3
=> 9
5 % 3
=> 2
# Add, subtract, multiply, and divide floats.
5.0 + 3
=> 8.0
6.0 - 4
=> 2.0
7.0 * 5
=> 35.0
8.0 / 5
=> 1.6
# Find the remainder of dividing two numbers using the modulo operator (%).
# Divide an integer by 0.
# Divide a float by 0.
# Divide 0 by 0.
# Create a variable and assign an integer.
# Calculate the variable divided by 2.
# Find the remainder of the variable when divided by 3.
# Create another variable and assign it the integer 13.
# Use the relational operators on the two variables.
# Reassign the value of one variable to be 7.
# Reassign the value of one variable to be 26 times its current value.
# Complete the following challenges in a Ruby file.
# Create a variable and return it in a sentence using string interpolation.
# Create a variable that contains a string and test some of the Ruby string methods:
# .upcase
# .reverse
# .include?
# .capitalize
# .delete
# .index
# .swapcase
# Create an array that contains the name of at least five TV shows you enjoy.
# Find the length of the array.
# Return the first item in the array.
# Return the fourth item in the array.
# Permanently reverse the order of the array.
# Create a new empty array for your top favorite TV shows.
# Using the full TV show array, add your top two favorite shows to the empty array.