zoukankan      html  css  js  c++  java
  • 函数与变量

    #coding=gbk
    #coding=utf-8
    from pip._vendor.distlib.compat import raw_input
    from builtins import int
    
    #定义一个函数与两个形参
    def  one_function(first_function,second_function):
        print("You have %s book!" % first_function)
        print("XiaoMing have %s book!" % second_function)
        print("I LOVE PYTHON")
        #"\n"代表空一行
        print(" Get a book.\n")
    
    print("第一次传参:")
    #传入实参
    one_function(20, 30)
    
    print("第二次传参:")
    #定义实参
    a_first_function = 6
    b_second_function = 6
    #a_first_function = int(raw_input()) #传入的数字转换为int类型,而不是str类型
    #b_second_function = int(raw_input())#传入的数字转换为int类型,而不是str类型
    one_function(a_first_function, b_second_function)
    
    print("第三次传参:")
    #传入参数first_function=1+2,second_function=4+6
    one_function(1+2, 4+6)
    
    print("第四次传参")
    #读取第二次传入的参数值--->a_first_function的值+6和b_second_function的值+66
    one_function(a_first_function + 6, b_second_function + 6)

    执行结果如下:

    第一次传参:
    You have 20 book!
    XiaoMing have 30 book!
    I LOVE PYTHON
    Get a book.

    第二次传参:
    You have 6 book!
    XiaoMing have 6 book!
    I LOVE PYTHON
    Get a book.

    第三次传参:
    You have 3 book!
    XiaoMing have 10 book!
    I LOVE PYTHON
    Get a book.

    第四次传参
    You have 12 book!
    XiaoMing have 12 book!
    I LOVE PYTHON
    Get a book.

  • 相关阅读:
    deepin 安装版本管理工具
    deepin 安装maven
    deepin 安装 idea
    启动VMware环境下的Linux操作系统,添加新分区
    Centos6.*安装vsftpd
    easyui-datebox 年月视图显示
    oracle-数据库泵EXPDP导出用户下所有
    Oracle虚拟机配置
    JSON理解
    Python语法基础_04.元组、函数-上
  • 原文地址:https://www.cnblogs.com/AIHEN/p/9011492.html
Copyright © 2011-2022 走看看