본문 바로가기

Python_Matter/[Check_IO]Elementary

Multiply (Intro)

반응형

Quiz>

(at the top right of the mission description there always is a list of available translations)

 

This is an intro mission, the purpose of which is to explain how to solve missions on CheckiO and how

to get the most out of solving them. When the mission is solved, one more station become available for you, containing more complex missions.

 

So this mission is the easiest one. 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.

 

Example:

mult_two(2, 3) == 6
mult_two(1, 0) == 0

 

How does it work?:

When you start solving the initial code is always consists of an “empty” function (which you need to fill in as the 

solution) and asserts under this function. You should pay attention to is that your function should return values,

and not to print them. That is, use the return command instead of the print function. Check this short explanation.

 

The asserts after your function you can use in order to check yourself by pressing the “Run” button (). 

CheckiO also uses several additional tests in order to check your solution when you click the “Check” button ().

 

If the solution didn’t pass the internal tests, the right panel will display an error message containing 3 items.

 

Fail: 

- shows how your function was called.

Your Result:

- shows what it returned.

Right Result: 

- what it should’ve returned.

To solve the task the “empty” function must be replaced with the following code.

 

def mult_two(a: int, b: int) -> int:
    return a*b

 

Try to click “Check” button now.

 

If the solution passes all the tests, the congratulations should appear on the right panel along with a suggestion

for the following action. (Yes, this is not the end of the story).

 

View other solutions - when the task is solved, you can access the solutions of other players, which are divided 

into categories.

Publish your solution - publish your own solution.

Next Mission - go to the next mission.

I’d recommend to go through the solutions of other players before publishing your own.

 

The last but not the least, some tasks at the end have a list of hints for solving. 

But since in this task we’ve already described how to solve, then in hints we’ll add some interesting 

facts about CheckiO

 

def mult_two(a, b):
    # your code here
    return None

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!")

 

Solve>

1. a와 b를 받아서 곱하고 mul이라는 변수에 저장한다.

def mult_two(a, b):
    mul = a * b

 

2. mul을 리턴 한다.

def mult_two(a, b):
    mul = a * b
    return mul

 

Code>

def mult_two(a, b):
    mul = a * b
    return mul

 

Example>

if __name__ == '__main__':
    print("Example:")
    print(mult_two(3, 2))

 

Result>

Example:
6

반응형

'Python_Matter > [Check_IO]Elementary' 카테고리의 다른 글

Correct Sentence  (0) 2020.04.11
Fizz Buzz  (0) 2020.04.11
Say Hi  (0) 2020.04.11
First Word (simplified)  (0) 2020.04.10
Easy Unpack  (0) 2020.04.10