- Write two functions, one called addit and one called mult. addit takes one number as an input and adds 5. mult takes one number as an input, and multiplies that input by whatever is returned by addit, and then returns the result.
def addit(number):
s = number +5
return s
def mult(mnum):
b = mnum * addit(mnum) # 调用另一个函数
return b
fhand = int(input())
print(mult(fhand)) # 给一个函数赋值即可
Write a function, length, that takes in a list as the input. If the length of the list is greater than or equal to 5, return “Longer than 5”. If the length is less than 5, return “Less than 5”.
def length(lst):
if len(lst) >= 5:
return 'Longer than 5'
else:
return 'Less than 5'
fhand = input('字符用空格隔开')
lst = fhand.split()
print(length(lst))
You will need to write two functions for this problem. The first function, divide that takes in any number and returns that same number divided by 2. The second function called sum should take any number, divide it by 2, and add 6. It should return this new number. You should call the divide function within the sum function. Do not worry about decimals.
def divide(dnum):
s = dnum / 2
return s
def sum(number):
x = divide(number) + 6
return x
fhand = int(input())
print(sum(fhand))