ブリブリ備忘録 おっ、python

HackerRankの問題とコメント(python3) 拙いですが...

Solve Me First 関数の定義

・問題

Complete the function solveMeFirst to compute the sum of two integers.

Function prototype:

int solveMeFirst(int x, int y);

where,

  • x is the first integer input.
  • y is the second integer input

Return values

  • sum of the above two integers

Sample Input

x = 2
y = 3

Sample Output

5

Explanation

The sum of the two integers  and  is computed as: .

ソースコード

def solveMeFirst(a,b):
    return a+b
num1 = int(input())
num2 = int(input())
res = solveMeFirst(num1,num2)
print(res)

コメント

def solveMeFirst(a,b):
    return a+b

の部分で関数の定義を行うのがポイント。

ここでは

solveMeFirst(a,b)

は2つの数a,bが与えられたときにa+bを返す関数として定義されている。

・URL

https://www.hackerrank.com/challenges/solve-me-first/copy-from/71500655