text 功能介绍

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 功能介绍相关的知识,希望对你有一定的参考价值。

#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


以上是关于text 功能介绍的主要内容,如果未能解决你的问题,请参考以下文章

Unity UGUI——提供可视功能的UI组件(Text)

猿如意中的Sublime Text开发工具详情介绍

Sublime Text 3前端开发常用优秀插件介绍

猿如意中的Sublime Text Build 3211开发工具详情介绍

猿如意中的Sublime Text Build 3211开发工具详情介绍

sublime text 添加到鼠标右键功能