forked from OpenGuide/Python-Guide-for-Beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a Python Program to add 2 numbers OpenGuide#1
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Two simple examples of adding two numbers | ||
# They are designed to be implemented within a .py file | ||
# They would need the addition of raw input to run from the | ||
# command line | ||
# Also note that the float version does not round, just | ||
# dropping all numbers after a decimal. This is not always | ||
# practical, but good for teaching | ||
|
||
|
||
# python function to add two numbers | ||
def addTwoNumbers(firstnumber, secondnumber): | ||
sum = float(firstnumber) + float(secondnumber) | ||
return sum | ||
|
||
# python function to add two Integers | ||
def addTwoIntegers(firstnumber, secondnumber): | ||
sum = int(firstnumber) + int(secondnumber) | ||
return sum |