Why there is no output?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why there is no output??

def multiply(x, y): return x * y a = 4 b = 7 operation = multiply print(operation(a, b)) #it retuns value but when we remove print means def multiply(x, y): return x * y a = 4 b = 7 operation = multiply operation(a, b) #then it shows no output

5th Jun 2018, 12:15 PM
Meet Rajpopat
Meet Rajpopat - avatar
8 Answers
+ 1
Yes, but you rather print variables or the output of functions. a = multiply(x,y) print(a) yields the same as print(multiply(x,y)) In the second case, the output value is just stored temporarely
5th Jun 2018, 12:36 PM
Matthias
Matthias - avatar
0
Well, the calculations happen as usual. But to show output, you need to print it of course.
5th Jun 2018, 12:21 PM
Matthias
Matthias - avatar
0
#i am confused def f(): print("@") f() #then it is returns '@' Matthias
5th Jun 2018, 12:24 PM
Meet Rajpopat
Meet Rajpopat - avatar
0
Because you tell to print the string "@". What is your intendet behavior? Maybe you are confusing return and print?
5th Jun 2018, 12:26 PM
Matthias
Matthias - avatar
0
Matthias you mean to say that we have to use print to print any function i understood thank you
5th Jun 2018, 12:28 PM
Meet Rajpopat
Meet Rajpopat - avatar
0
Yes, Python won't print anything unless you tell it to. This allows you to do a = multiply(x, y)
5th Jun 2018, 12:30 PM
Vlad Serbu
Vlad Serbu - avatar
0
Vlad Serbu print(a)??
5th Jun 2018, 12:32 PM
Meet Rajpopat
Meet Rajpopat - avatar
0
Matthias thanks
5th Jun 2018, 12:37 PM
Meet Rajpopat
Meet Rajpopat - avatar