Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions WarmUpExercises/AddGivenNumbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Program to add given 'n' numbers and print the total sum of it.


inputYourNumbers = input("Enter the numbers to add separated by whitespace.")

fetchInputedNumbers = inputYourNumbers.split()

numbersFetchedAsInt = list(map(int, fetchInputedNumbers))

totalSum = sum(numbersFetchedAsInt)

print("The total sum of given numbers is ", totalSum)
8 changes: 8 additions & 0 deletions WarmUpExercises/AddTwoNumbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# Program to add two given numbers.

numberOne = 10
numberTwo = 9

totalSum = numberOne + numberTwo
print("The sum of given two numbers is: ", totalSum)
15 changes: 15 additions & 0 deletions WarmUpExercises/AddTwoNumbersWithFunction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Program to define user defined function for adding two numbers.

# function to add two given numbers.
def AddTwoNumbers(numberOne, numberTwo):
totalSum = numberOne + numberTwo
return totalSum

# converting the string entered to type integer.
numberOne = int(input("What is the first number to be added? "))
numberTwo = int(input("What is the second number to be added? "))

# passing the two integers to above defined function -- AddTwoNumbers
sumOfTwoNumbers = AddTwoNumbers(numberOne, numberTwo)
print("The sum of given two numbers is: ", sumOfTwoNumbers)