美文网首页
函数和变量ex19.py

函数和变量ex19.py

作者: 一盏省油的小灯 | 来源:发表于2018-05-20 13:32 被阅读10次
# -*- coding: utf-8 -*-
# @Author: yt
# @Date:   2018-05-15 13:46:02
# @Last Modified by:   yt
# @Last Modified time: 2018-05-15 14:44:24

def cheese_and_crackers(cheese_count,boxes_of_crackers):
    print "You have %d cheeses!"% cheese_count
    print "You have %d boxes of crackers!"%boxes_of_crackers
    print "Man that's enough for a party!"
    print "Get a blanket.\n"

print "We can just give the function numbers directly:"
cheese_and_crackers(20,30)

print "OR,we can use variables from our script:"
amount_of_cheese =10
amount_of_crackers = 50
cheese_and_crackers(amount_of_cheese, amount_of_crackers)

print "We can even do math inside too:"
cheese_and_crackers(10+20, 5+6)

print "And we can combine the two, variables and math:"
cheese_and_crackers (amount_of_cheese+100, amount_of_crackers+1000)
运行结果如下: 图1

相关文章

  • 函数和变量ex19.py

  • 第一章 灵活的javascript

    1。 用对象来收编变量和函数,减少全局变量数,防止变量和函数覆盖。 2。可以使用类来收编变量和函数:

  • Kotlin | 2.Kotlin基础

    声明函数、变量、类、枚举以及类型Kotlin中的控制结构智能转换抛出和处理异常 函数学习 函数和变量 函数 变量 ...

  • 变量和函数

    可以使用下划线来增强可读性(Kotlin1.1版本开始支持)val oneMillion = 1_000_000v...

  • 变量和函数

    变量的作用域 通过上述的程序简单的表达作用域,我们来一道例题学习学习,还有c语言毕竟是一门程序语言,希望大家在编译...

  • 变量和函数

    变量 Kotlin中声明变量有两种关键字 val 和 var val (value的简写)用来声明一个不可变的变量...

  • Cloneable接口

    前置知识 Java在处理对象和变量时是不同的.变量传入函数实际上是引用传入函数内,在函数内的变量和函数外传入的变量...

  • 前端面试题

    闭包1.函数嵌套函数--设计私有方法和变量。2.函数内部可以应用外部参数和变量--避免全局变量污染。3.参数和变量...

  • 【Kotlin 】Kotlin基础

    函数和变量函数 变量可变变量和不可变变量 val - 不可变引用。 相当于Java的final变量。var - 可...

  • 菜鸟学习javaScript9

    11 变量和参数深入了解 变量 全局变量:在函数外面声明的变量。 局部变量:在函数内部声明的变量,只有在函数内部使...

网友评论

      本文标题:函数和变量ex19.py

      本文链接:https://www.haomeiwen.com/subject/xfaedftx.html