Why didn’t my product display on the screen?

Question

I’ve defined the product as asked and assigned it a value, but it isn’t displayed to the terminal. Why is this?

Answer

Computers must be told what to do at every step of the way. If you don’t tell it to print something to the screen it has no way of knowing you wanted product displayed to you. If you want, you could add print product to the next line to see the result of your multiplication.

Also! If at any time you do see something that you didn’t explicitly print, it may be because of tests being run by Codecademy that would not normally appear outside of our environment here.

15 Likes

I tried adding print commands before but it only displays ‘product’ (or the name of the other variable) in the terminal, also after refreshing, why is this?

4 Likes

Have you tried writing without using quotations? just put print(x) instead of print(“x”).

I believe that when you put quotes, it uses the content as a string or integer, rather than an item in your code, in this case, the output of the variable.

I could be wrong, but I think that’s it!

18 Likes

I Have tried with and without quotations but maybe I should have added the parenthesis to name the variable product?
Thanks for helping me out @ekulbyrnes
And now I concluded that I only needed to remove the parenthesises and quotations

2 Likes

I had the same question and figured it out. To display the answer to the arithmetic problem 12 x 8 I used this code to get the answer to display. Since it knows that the math is multiplication you don’t need to have the word product anywhere in the code anymore.

Code: print (12 * 8)
Displayed Result: 96

17 Likes

Thank you I tried and it worked

2 Likes

thnx buddy…it really works

2 Likes

I am probably understanding you wrong,but this is not working for me.I print on one line multiply=12*8 and on the second print product.I’ve tried with parentheses but it still hasn’t worked.Could I get some help?

1 Like

I took an easier approach. Thanks to @contentmazzone I was able to tell Python that I wanted to see the answer (before it wasn’t showing and I didn’t understand why, the lesson also didn’t explain why either).

My Code looked like this before:

product = 18 * 3
remainder = 1398 % 11

The lesson didn’t specify that I had to use % instead of / and I automatically assumed, at least with division, it’d be / and not %. So I ended up reading this thread for help.

So now the difference in code would be as follows:

product = 18 * 3
print product
remainder = 1398 % 11
print remainder

And when I run the command the answer to both the questions are:

234
1

:slight_smile:

(oops, I rest my case, it does tell you to use % haha)

24 Likes