Function that will receive 2 numbers as input and it should return the multiplication of these 2 numbers
Im playing Checkio website to learn more about python but I dont seem to be able to solve the very first problem.This is it:
Write a function that will receive 2 numbers as input and it should return the multiplication of these 2 numbers.
Input: Two arguments. Both are int
Output: Int.
Now, they give me this code:
def mult_two(a, b):
# your code here
return mult_two
if __name__ == '__main__':
print("Example:")
print(mult_two(3, 2))
# These "asserts" are used for self-checking and not for an auto-testing
assert mult_two(3, 2) == 6
assert mult_two(1, 0) == 0
print("Coding complete? Click 'Check' to earn cool rewards!")
in the #Your code here part, i need to add the answer, but I have no clue. Please help.
python input int multiplying
add a comment |
Im playing Checkio website to learn more about python but I dont seem to be able to solve the very first problem.This is it:
Write a function that will receive 2 numbers as input and it should return the multiplication of these 2 numbers.
Input: Two arguments. Both are int
Output: Int.
Now, they give me this code:
def mult_two(a, b):
# your code here
return mult_two
if __name__ == '__main__':
print("Example:")
print(mult_two(3, 2))
# These "asserts" are used for self-checking and not for an auto-testing
assert mult_two(3, 2) == 6
assert mult_two(1, 0) == 0
print("Coding complete? Click 'Check' to earn cool rewards!")
in the #Your code here part, i need to add the answer, but I have no clue. Please help.
python input int multiplying
As a starting point, think about how you would write a program that multiplies two numbers, without a function. Then take that code and put it in your function.
– Kevin
Nov 20 '18 at 16:13
I tried putting this: def mult_two(a, b): mult_two= 3*2 return mult_two
– emilie davis
Nov 20 '18 at 16:16
Edit the question with your attempt. Don't put it in the comments
– DavidG
Nov 20 '18 at 16:16
But it gave me this error: Example: 6 AssertionError: <module>, 12
– emilie davis
Nov 20 '18 at 16:17
Hint: Generally, the parameters of a function should be used inside the body of that function. In other words,a
andb
should appear somewhere in your return statement.
– Kevin
Nov 20 '18 at 16:18
add a comment |
Im playing Checkio website to learn more about python but I dont seem to be able to solve the very first problem.This is it:
Write a function that will receive 2 numbers as input and it should return the multiplication of these 2 numbers.
Input: Two arguments. Both are int
Output: Int.
Now, they give me this code:
def mult_two(a, b):
# your code here
return mult_two
if __name__ == '__main__':
print("Example:")
print(mult_two(3, 2))
# These "asserts" are used for self-checking and not for an auto-testing
assert mult_two(3, 2) == 6
assert mult_two(1, 0) == 0
print("Coding complete? Click 'Check' to earn cool rewards!")
in the #Your code here part, i need to add the answer, but I have no clue. Please help.
python input int multiplying
Im playing Checkio website to learn more about python but I dont seem to be able to solve the very first problem.This is it:
Write a function that will receive 2 numbers as input and it should return the multiplication of these 2 numbers.
Input: Two arguments. Both are int
Output: Int.
Now, they give me this code:
def mult_two(a, b):
# your code here
return mult_two
if __name__ == '__main__':
print("Example:")
print(mult_two(3, 2))
# These "asserts" are used for self-checking and not for an auto-testing
assert mult_two(3, 2) == 6
assert mult_two(1, 0) == 0
print("Coding complete? Click 'Check' to earn cool rewards!")
in the #Your code here part, i need to add the answer, but I have no clue. Please help.
python input int multiplying
python input int multiplying
asked Nov 20 '18 at 16:12
emilie davisemilie davis
51
51
As a starting point, think about how you would write a program that multiplies two numbers, without a function. Then take that code and put it in your function.
– Kevin
Nov 20 '18 at 16:13
I tried putting this: def mult_two(a, b): mult_two= 3*2 return mult_two
– emilie davis
Nov 20 '18 at 16:16
Edit the question with your attempt. Don't put it in the comments
– DavidG
Nov 20 '18 at 16:16
But it gave me this error: Example: 6 AssertionError: <module>, 12
– emilie davis
Nov 20 '18 at 16:17
Hint: Generally, the parameters of a function should be used inside the body of that function. In other words,a
andb
should appear somewhere in your return statement.
– Kevin
Nov 20 '18 at 16:18
add a comment |
As a starting point, think about how you would write a program that multiplies two numbers, without a function. Then take that code and put it in your function.
– Kevin
Nov 20 '18 at 16:13
I tried putting this: def mult_two(a, b): mult_two= 3*2 return mult_two
– emilie davis
Nov 20 '18 at 16:16
Edit the question with your attempt. Don't put it in the comments
– DavidG
Nov 20 '18 at 16:16
But it gave me this error: Example: 6 AssertionError: <module>, 12
– emilie davis
Nov 20 '18 at 16:17
Hint: Generally, the parameters of a function should be used inside the body of that function. In other words,a
andb
should appear somewhere in your return statement.
– Kevin
Nov 20 '18 at 16:18
As a starting point, think about how you would write a program that multiplies two numbers, without a function. Then take that code and put it in your function.
– Kevin
Nov 20 '18 at 16:13
As a starting point, think about how you would write a program that multiplies two numbers, without a function. Then take that code and put it in your function.
– Kevin
Nov 20 '18 at 16:13
I tried putting this: def mult_two(a, b): mult_two= 3*2 return mult_two
– emilie davis
Nov 20 '18 at 16:16
I tried putting this: def mult_two(a, b): mult_two= 3*2 return mult_two
– emilie davis
Nov 20 '18 at 16:16
Edit the question with your attempt. Don't put it in the comments
– DavidG
Nov 20 '18 at 16:16
Edit the question with your attempt. Don't put it in the comments
– DavidG
Nov 20 '18 at 16:16
But it gave me this error: Example: 6 AssertionError: <module>, 12
– emilie davis
Nov 20 '18 at 16:17
But it gave me this error: Example: 6 AssertionError: <module>, 12
– emilie davis
Nov 20 '18 at 16:17
Hint: Generally, the parameters of a function should be used inside the body of that function. In other words,
a
and b
should appear somewhere in your return statement.– Kevin
Nov 20 '18 at 16:18
Hint: Generally, the parameters of a function should be used inside the body of that function. In other words,
a
and b
should appear somewhere in your return statement.– Kevin
Nov 20 '18 at 16:18
add a comment |
1 Answer
1
active
oldest
votes
Your problem seems pretty basic. Here is a possible way of writing you function mult_two:
def mult_two(a, b):
""" Return the product of the two arguments."""
return a * b
I got it, thanks! Im very new at python.
– emilie davis
Nov 20 '18 at 16:29
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397103%2ffunction-that-will-receive-2-numbers-as-input-and-it-should-return-the-multiplic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your problem seems pretty basic. Here is a possible way of writing you function mult_two:
def mult_two(a, b):
""" Return the product of the two arguments."""
return a * b
I got it, thanks! Im very new at python.
– emilie davis
Nov 20 '18 at 16:29
add a comment |
Your problem seems pretty basic. Here is a possible way of writing you function mult_two:
def mult_two(a, b):
""" Return the product of the two arguments."""
return a * b
I got it, thanks! Im very new at python.
– emilie davis
Nov 20 '18 at 16:29
add a comment |
Your problem seems pretty basic. Here is a possible way of writing you function mult_two:
def mult_two(a, b):
""" Return the product of the two arguments."""
return a * b
Your problem seems pretty basic. Here is a possible way of writing you function mult_two:
def mult_two(a, b):
""" Return the product of the two arguments."""
return a * b
answered Nov 20 '18 at 16:22
eapetchoeapetcho
42927
42927
I got it, thanks! Im very new at python.
– emilie davis
Nov 20 '18 at 16:29
add a comment |
I got it, thanks! Im very new at python.
– emilie davis
Nov 20 '18 at 16:29
I got it, thanks! Im very new at python.
– emilie davis
Nov 20 '18 at 16:29
I got it, thanks! Im very new at python.
– emilie davis
Nov 20 '18 at 16:29
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53397103%2ffunction-that-will-receive-2-numbers-as-input-and-it-should-return-the-multiplic%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
As a starting point, think about how you would write a program that multiplies two numbers, without a function. Then take that code and put it in your function.
– Kevin
Nov 20 '18 at 16:13
I tried putting this: def mult_two(a, b): mult_two= 3*2 return mult_two
– emilie davis
Nov 20 '18 at 16:16
Edit the question with your attempt. Don't put it in the comments
– DavidG
Nov 20 '18 at 16:16
But it gave me this error: Example: 6 AssertionError: <module>, 12
– emilie davis
Nov 20 '18 at 16:17
Hint: Generally, the parameters of a function should be used inside the body of that function. In other words,
a
andb
should appear somewhere in your return statement.– Kevin
Nov 20 '18 at 16:18