+ 1
HELP def print_double(x): print(2*x) print_double(3) result??
12 Antworten
+ 7
What is the result of this code?
def print_double(x):
print(2 * x)
print_double(3)
ans: 6
+ 1
ouu 6. thanks
+ 1
6
+ 1
def print_double(x):
print(2*x)
print_double(3)
0
Not to difficult. Just exchange everywhere inside the function the x by 3. then you just have to calculate.
0
What is the result of this code?
def print_double(x):
print(2 * x)
print_double(3)
Ans: 6
0
the ans is 7
0
yeah its 6
0
ans :6
- 1
You have just defined print_double as 2*x. But in order for it to work you need to put a variable in, you cant double the letter "X". So in the parentheses next to the def function you put in a letter x, that's telling python that the variable is x so when you put (2*x) you're essentially telling python to print 2*a number that you put in. So now everytime you put print_double(#enter number) the variable in the parentheses is going to follow the rule that you just defined, which would be printing it*2.
So if you were to just put:
def print_double(x):
print(x)
Anything you put in the parentheses for print_double() is going to follow the rule you just put down, so in this case all its doing is just printing it. So if I put print_double('hello world") it would just print hello world because that's the rule that I set it as.
- 3
indentation
- 4
Hey guys it's proRam@LOGO Industries
what about starting a python developrs group
Drop in ur whatsapp nos. of fb ids