Step 14 MATH


#1

Math

Good! Now let's do a little math.

Instructions

In the editor, set the variables:
— sum equal to 13 + 379
— product equal to 923 * 15
— quotient equal to 13209 / 17
what is it that they are looking for?


#2

To set a variable, we assign a value (or expression):

myvar = "This is a string expression."
puts myvar
# This is a string expression

In this lesson, the variable names are provided, as are the expressions. All we need to do is construct the assignment statements:

sum = 13 + 379
product = 
quotient =

That's it for this lesson.


#4

@mtf I have tried many things and it still is not accepting anything. I am so confused


#5

Please post your code so that we can see what you tried.


#7

Just copy and paste.


#8

sum = 13 + 379= 392
product =923*15= 13980
quotient =13209/17= 766.411765
that's what one of my friends said to do


#11

First, even if you can listen to your friends, the important thing is what YOU want to do. It's fine to take advice as long as you use your own abilities, or you won't learn anything.

Besides, this:

sum = 13 + 379= 392
product =923*15= 13980
quotient =13209/17= 766.411765

is wrong.

Why don't you take a look at the example given in the instructions (and given by @mtf above)?

 sum = 13 + 379
product = 
quotient =

#13

Your school level doesn't matter one bit, you can understand anything you want as long as you put effort into it.

Just take your time, read the examples, and deduce how your own code might look like from them. If you feel like you've worked too much, just take a break, the website will still be here tomorrow.


#14
sum = 13 + 379= 392
product =923*15= 13980
quotient =13209/17= 766.411765

Ruby will carry out the evaluation. Remove the second assignment.

sum = 13 + 379
product = 923 * 16
quotient = 13209 / 17

The expressions are assigned, but what is stored is the actual evaluations. Let's print the results:

puts sum      # 392
puts product  # 14768
puts quotient # 777

#15

and it still said "Oops, try again. Did you declare a variable called sum?"


#16

Well, did you?

What's your new code?


#17

sum = 13 + 379
product = 923 * 15
quotient = 13209 / 17

I type this to the script
but the screen shows only 777
It stil goes to next session but is there something wrong about the result here?


#18

I see no issue, every Ruby program on codeacademy will display what the last instruction evaluates to, and the last instruction evaluates to 777 (13209 / 17).


#19

ok thank you I finally got it thank you for helping


#20

Hello there so my code is like this and it doesn't go forward
sum = 12 + 379
product = 923*15
quotient = 13209/17


#21

Feeling pretty lost. The concept itself is easy enough but I feel like the instructions aren't very helpful. It tells you (+) for addition () for multiplication and so on. Does is say how you have to type it in though? Do I need to write sum = "1+1" ? Then how do I make it compute? If you hit enter it just goes to the next space. When I clicked submit it just spit out the same "22" that I had entered.

Thanks!


#22
sum = 1 + 1

will compute 1 + 1 and store the result inside the variable sum. Then if you want to use this result you have to use other methods, keywords and operators depending on your needs. For example if you want to add something to sum you could use:

sum += 3

#26

well for the sme i still didnt get how, but i did all correct and the he said quetent is set to one thing already, and didnt get whats wrong


#28