Here's a great sample of what to expect from my Ruby programming course. In this lesson we'll be making a program that finds the area of a triangle. After that we'll build a simple Pythagorean theorem calculator.
print "Doe! What is the base of your trap(tapezoid)?" a = gets.to_f; print "What is the second base of your trap?" b = gets.to_f; print "What is the height of your trap?" h = gets.to_f; fee = a + b fi = fee / 2 foe = fi * h puts "The area of your trap is #{foe}" LOL I thought I would share Thank you, Jake (from StateFarm)!
Hey Jake I did this lesson. Then the gears in my brain started turning and I condensed this lesson down to about 2 lines of code. Granted I've been studying on codecademy, ruby monk, and beginning ruby (the book) as well as these lessons but still. I was excited I was able to do that because it means progress is being made! Anyway here's the code: def hypo_calc(num, num_1) num2 = num ** 2 + num_1 ** 2 puts "Your triangle's hypotenuse is #{Math.sqrt(num2).round}" end hypo_calc(4, 3)
Hello Jake, I was going through your tutorials with ruby. The first 12 went flawless, this 13th got me a strange error I couldn't solve. Maybe you or someone else could? Code: puts "This is a pythagorean theorem calculator ! You can find the hypotenus of a right triangle with it." print "To get started, what is side a?" a = gets.to_f; puts "what is side b of your triangle?" b = gets.to.f; a2 = a**2. b2 = b**2. c2 = (a2*b2) puts "you look great today! By the way, your triangle's hypotenuse is #{Math.sqrt(c2)}" Error(I also get this error using notepad and ruby command): his is a pythagorean theorem calculator ! You can find the hypotenus of a right triangle with it. To get started, what is side a?20 what is side b of your triangle? 30 C:/Users/Nick/RubymineProjects/untitled1/pythagorean.rb:7:in `': undefined method `to' for "30 ":String (NoMethodError) from -e:1:in `load' from -e:1:in `'
I'm sorry I want to ask something, when you said that after gets.to_f there should be a semicolon at the end of it, but I accidentally tried it like this : a = gets.to_f
Hi jacob its great! But how do you connect Triangles area with hypotenuse in one code? like the program have given you the results of triangle code and asking you about if you want to proceed the hypotenuse calculation ? it will be great if you could say me how i do it in one notepad code.
Wild Academy When ever i try and make the number round they dont round i keep geting the same numbers every time how do u fix this? This is what i put puts "You are looking great today! By the way your triangle hypotenuse is #{ Math.sqrt (2).round" did i type something wrong in the line??Thanks
Find someone in the company that will vouch for you. Go to RoR meetups. Ask people about themselves. If someone says you're a cool dude or gal, it increases your chances of being hired 10X. Not doing that, drink a glass of wine before you go in. Not too much now. Just enough to make you feel like a nice warm person. The placebo effect will kick in to cover the rest. Brush your teeth after. Some people have a good sense of smell, especially if the interviewer is a pregnant woman. (Not sure why I needed to specify the gender of a pregnant person.) Ditch the wine completely if that's the case. Just go with the champagne after you get the job. Also, if you're like me and get red rashes around the eyes when drinking wine, just forget about it. Good luck.
When you use puts, the text goes into a new line puts "I am anonymous" puts "Yes, I am" Outputs: I am anonymous Yes, I am ----------------------------------------------- Print does everything in the same line print "I am anonymous" print "Yes, I am" Outputs: I am anonymous Yes, I am ------------------------------------------------------ Hope it makes sense.
I like watching your Ruby tutorial videos and they are really helpful. Can you please post a link to your interview with the programmer which you mentioned in Day12 video? Thank you.
//I tried: puts "The triangle's hypotenuse is #{Math .sqrt(c2).round(2)}" //and I got an error message: 19.rb:11:in `round': wrong number of arguments (1 for 0) (ArgumentError) from 19.rb:11 //...WHY?
The reason you are getting this argument is prior versions of ruby that are before version 1.9 aren't able to interpret it. You need to get the 1.93 version to resolve this issue.
Here's a great sample of what to expect from my Ruby programming course. In this lesson we'll be making a program that finds the area of a triangle. After that we'll build a simple Pythagorean theorem calculator.
print "Doe! What is the base of your trap(tapezoid)?"
a = gets.to_f;
print "What is the second base of your trap?"
b = gets.to_f;
print "What is the height of your trap?"
h = gets.to_f;
fee = a + b
fi = fee / 2
foe = fi * h
puts "The area of your trap is #{foe}"
LOL I thought I would share
Thank you, Jake (from StateFarm)!
Hey Jake I did this lesson. Then the gears in my brain started turning and I condensed this lesson down to about 2 lines of code. Granted I've been studying on codecademy, ruby monk, and beginning ruby (the book) as well as these lessons but still. I was excited I was able to do that because it means progress is being made! Anyway here's the code:
def hypo_calc(num, num_1)
num2 = num ** 2 + num_1 ** 2
puts "Your triangle's hypotenuse is #{Math.sqrt(num2).round}"
end
hypo_calc(4, 3)
+wavvves vvvves great work, keep it up :)
Hello Jake,
I was going through your tutorials with ruby. The first 12 went flawless, this 13th got me a strange error I couldn't solve. Maybe you or someone else could?
Code:
puts "This is a pythagorean theorem calculator ! You can find the hypotenus of a right triangle with it."
print "To get started, what is side a?"
a = gets.to_f;
puts "what is side b of your triangle?"
b = gets.to.f;
a2 = a**2.
b2 = b**2.
c2 = (a2*b2)
puts "you look great today! By the way, your triangle's hypotenuse is #{Math.sqrt(c2)}"
Error(I also get this error using notepad and ruby command):
his is a pythagorean theorem calculator ! You can find the hypotenus of a right triangle with it.
To get started, what is side a?20
what is side b of your triangle?
30
C:/Users/Nick/RubymineProjects/untitled1/pythagorean.rb:7:in `': undefined method `to' for "30
":String (NoMethodError)
from -e:1:in `load'
from -e:1:in `'
Why do you need the semi-colon? does it matter whether it is there or not?
I'm sorry I want to ask something, when you said that after gets.to_f there should be a semicolon at the end of it, but I accidentally tried it like this :
a = gets.to_f
Hi jacob its great!
But how do you connect Triangles area with hypotenuse in one code? like the program have given you the results of triangle code and asking you about if you want to proceed the hypotenuse calculation ? it will be great if you could say me how i do it in one notepad code.
So I take it the point of using 0.5*h*w instead of the much more obvious h*w/2 is because it forces "area" to be float?
hey Jake! thanks alot for this great tutorials its very helpful, please can you please give me a clear difference between "print"and "puts"
hehe, this is pretty neat, I've coded my first program! Thanks, man!
Wild Academy When ever i try and make the number round they dont round i keep geting the same numbers every time how do u fix this?
This is what i put
puts "You are looking great today! By the way your triangle hypotenuse is #{ Math.sqrt (2).round"
did i type something wrong in the line??Thanks
Hello,
Been meaning to ask you, how do you prepare for an interview for a RoR junior developer position?
Thanks
Find someone in the company that will vouch for you. Go to RoR meetups. Ask people about themselves. If someone says you're a cool dude or gal, it increases your chances of being hired 10X.
Not doing that, drink a glass of wine before you go in. Not too much now. Just enough to make you feel like a nice warm person. The placebo effect will kick in to cover the rest. Brush your teeth after. Some people have a good sense of smell, especially if the interviewer is a pregnant woman. (Not sure why I needed to specify the gender of a pregnant person.) Ditch the wine completely if that's the case. Just go with the champagne after you get the job. Also, if you're like me and get red rashes around the eyes when drinking wine, just forget about it. Good luck.
when do you use puts and when prints?
When you use puts, the text goes into a new line
puts "I am anonymous"
puts "Yes, I am"
Outputs: I am anonymous
Yes, I am
-----------------------------------------------
Print does everything in the same line
print "I am anonymous"
print "Yes, I am"
Outputs: I am anonymous Yes, I am
------------------------------------------------------
Hope it makes sense.
Noah Spagnolo It does make sense, thanks for explaining to me :)
I like watching your Ruby tutorial videos and they are really helpful. Can you please post a link to your interview with the programmer which you mentioned in Day12 video?
Thank you.
//I tried:
puts "The triangle's hypotenuse is #{Math .sqrt(c2).round(2)}"
//and I got an error message:
19.rb:11:in `round': wrong number of arguments (1 for 0) (ArgumentError)
from 19.rb:11
//...WHY?
The reason you are getting this argument is prior versions of ruby that are before version 1.9 aren't able to interpret it. You need to get the 1.93 version to resolve this issue.
Why do I need a semi colon at the end of the to_f; ??
you dont
never mind i just rerote the line and it worked idk what it was but i fixed it
:)
"hypotenuse", BTW.
Why do the teacher do mistakes i dont do :P
Because you have the eye of the tiger. Survivor - Eye Of The Tiger
Nice one :P