Email your answers to: alex.grant@generalassemb.ly
a = 2
b = 3
a = b
At the end of this program, what are the values of a and b? Try to explain, in plain English, how you got your answer for each one.
c = 5
d = 2
c = c + d
At the end of this program, what is the value of c?
Try to explain, in plain English, what the last line of this program (c = c + d
) means.
e = 4
f = 6
g = e + f
e = 1
At the end of this program, what are the values of e, f, and g? Try to explain, in plain English, how you got your answer for each one.
x = 4
y = 3
x = y
y = 10
At the end of this program, what are the values of x and y? Try to explain, in plain English, how you got your answer for each one.
Imagine that you take the code from Question 4, save it to a file called test.rb
, and run ruby test.rb
in your Terminal.
What would be the output? Explain your answer.
weather = "sunny"
weather == "sunny"
What is the difference between these two statements? Explain your answer.
x = 4
if x == 3
puts "sushi is tasty"
end
if x > 0
puts "sushi is delicious"
end
Imagine that you take the code from this question, save it to a file called food.rb
, and run ruby food.rb
in your Terminal.
What would be the output? Explain your answer.
x = 3
if x == 3
puts "sushi is tasty"
elsif x > 0
puts "sushi is delicious"
end
Imagine that you take the code from this question, save it to a file called sushi.rb
, and run ruby sushi.rb
in your Terminal.
What would be the output? Explain your answer.
x = 2
if x > 0
puts "Chuck Norris can do a wheelie on a unicycle"
x = x + 1
end
puts x
Imagine that you take the code from this question, save it to a file called huzzah.rb
, and run ruby huzzah.rb
in your Terminal.
What would be the output? Explain your answer.
kitty = "lolcat"
if kitty == "lolcat"
puts "i can has cheezburger?"
else
puts "im in ur code fixin ur bugz"
end
Imagine that you take the code from this question, save it to a file called kitty.rb
, and run ruby kitty.rb
in your Terminal.
What would be the output? Explain your answer.
fruit = "tomato"
if fruit == "banana"
puts "yum"
end
Imagine that you take the code from this question, save it to a file called kitty.rb
, and run ruby kitty.rb
in your Terminal.
What would be the output? Explain your answer.
What is the value of fruit
at the end of the code in Question 11? Try to explain, in plain English, how you got your answer.
wizard = "harry potter"
if wizard
puts "alohomora"
end
Imagine that you take the code from this question, save it to a file called spell.rb
, and run ruby spell.rb
in your Terminal.
What would be the output? Explain your answer.
x = 9/10
puts x
puts x.to_i
puts x.to_f
Imagine that you take the code from this question, save it to a file called numbers.rb
, and run ruby numbers.rb
in your Terminal.
What would be the output? Explain your answer.
What command outputs my current directory?
What command outputs a listing of all files and directories in the current directory?
How can I change to my home directory?
How can I rename the file named question.txt
to answer.txt
?
How can I delete a directory named wrong
within my current directory, including all its contents and subdirectories?
How can I allow it so that anyone can read, write and execute the file called virus.sh
?