博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
阅读量:4057 次
发布时间:2019-05-25

本文共 1248 字,大约阅读时间需要 4 分钟。

  1. 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 sdef mult(mnum):    b = mnum * addit(mnum)   # 调用另一个函数    return bfhand = 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 sdef sum(number):    x = divide(number) + 6    return xfhand = int(input())print(sum(fhand))

转载地址:http://birci.baihongyu.com/

你可能感兴趣的文章
iOS 扫一扫功能开发
查看>>
iOS app之间的跳转以及传参数
查看>>
iOS __block和__weak的区别
查看>>
Android(三)数据存储之XML解析技术
查看>>
Spring JTA应用之JOTM配置
查看>>
spring JdbcTemplate 的若干问题
查看>>
Servlet和JSP的线程安全问题
查看>>
GBK编码下jQuery Ajax中文乱码终极暴力解决方案
查看>>
Oracle 物化视图
查看>>
PHP那点小事--三元运算符
查看>>
解决国内NPM安装依赖速度慢问题
查看>>
Brackets安装及常用插件安装
查看>>
Centos 7(Linux)环境下安装PHP(编译添加)相应动态扩展模块so(以openssl.so为例)
查看>>
fastcgi_param 详解
查看>>
Nginx配置文件(nginx.conf)配置详解
查看>>
标记一下
查看>>
IP报文格式学习笔记
查看>>
autohotkey快捷键显示隐藏文件和文件扩展名
查看>>
Linux中的进程
查看>>
学习python(1)——环境与常识
查看>>