how comes we don't have to define "x". eg def print_tripple (x) print (3*x) print_tripple("5") | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how comes we don't have to define "x". eg def print_tripple (x) print (3*x) print_tripple("5")

19th Aug 2016, 1:19 PM
Hamid Ibrahim
Hamid Ibrahim - avatar
4 Answers
+ 2
you dont have to define 'x' because 'x' is not a variable. its an argment. x gets called where you have "print_tripple("5") also, you missed a " : " at the end of your function. hope this helps
19th Aug 2016, 2:40 PM
Sandray Fostin
Sandray Fostin - avatar
0
def print_tripple (x): print ("3*x")
20th Aug 2016, 10:06 PM
Hassan gh.lominol
Hassan gh.lominol - avatar
0
answer in script is 3*5 15
20th Aug 2016, 10:07 PM
Hassan gh.lominol
Hassan gh.lominol - avatar
0
Hassan gh.lominol that answer is wrong due to you having it in quotations. It will print 3*5. Not 15 because you made it a string.
24th Jan 2019, 9:44 AM
Sandray Fostin
Sandray Fostin - avatar