#defined function that returns lowest value of 3 int inputs
def min(num1,num2,num3):
if num1 < num2 and num1 < num3:
return num1
elif num2 < num1 and num2 < num3:
return num2
elif num3 < num1 and num3 < num2:
return num3
#take 3 value inputs, store them in own names
numUserInput1 = float(input('Enter number one: '))
numUserInput2 = float(input('Enter number two: '))
numUserInput3 = float(input('Enter number three: '))
#can plug in variables into function
#NOTE: arguments can have diff variable names, but must be same TYPES.
minValue = min(numUserInput1,numUserInput2,numUserInput3)
print('lowest value is: ' + str(minValue))
#a defined function that returns shortest word
def shortestWord(wordOne,wordTwo,wordThree):
if wordOne < wordTwo and wordOne < wordThree:
return wordOne
elif wordTwo < wordOne and wordTwo < wordThree:
return wordTwo
elif wordThree < wordOne and wordThree < wordTwo:
return wordThree
#take 3 value inputs, store them in own names
wordUserInput1 = input('Enter word one: ')
wordUserInput2 = input('Enter word two: ')
wordUserInput3 = input('Enter word three: ')
shortestWordReturned = shortestWord(wordUserInput1, wordUserInput2, wordUserInput3)
print('shortest word is: ' + shortestWordReturned)
#a function that concats two substrings, and finds length, returns length of new word
def combineLengths (firstsub, secondSub):
newWord = firstsub + secondSub
lengthOfNewWord = len(newWord)
return lengthOfNewWord
firstUserInputSub = input('Enter substring one: ')
secondUserInputSub = input('Enter substring two: ')
lengthOfNewWord = combineLengths(firstUserInputSub, secondUserInputSub)
print('Length of new String: ' + str(lengthOfNewWord))
Enter number one: 1
Enter number two: 10
Enter number three: .5
lowest value is: 0.5
Enter word one: cat
Enter word two: mouse
Enter word three: elephant
shortest word is: cat
Enter substring one: ma
Enter substring two: tch
Length of new String: 5