Solution 1 - Direct Addition
Given two integers num1 and num2, return their sum. This is a straightforward arithmetic problem — simply use the + operator to add the two numbers and return the result.
Given two integers num1 and num2, return their sum. This is a straightforward arithmetic problem — simply use the + operator to add the two numbers and return the result.
""" 2235.1 - Add Two Integers - Solution 1 - Direct Addition """
#####################################################################################
# Imports
#####################################################################################
#####################################################################################
# Classes
#####################################################################################
class Solution:
"""Solution Class"""
def sum(self, num1: int, num2: int) -> int:
"""Add Two Integers Function"""
return num1 + num2
#####################################################################################
# Functions
#####################################################################################
def testcase():
"""Test Function"""
print(Solution().sum(12, 5)) # Expected: 17
print(Solution().sum(-10, 4)) # Expected: -6
print(Solution().sum(0, 0)) # Expected: 0
print(Solution().sum(-100, 100)) # Expected: 0
#####################################################################################
# Main
#####################################################################################
if __name__ == "__main__":
testcase()