puts "Let's practice everything."
puts 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.' # the <<END is a "heredoc". See the Student Questions.
poem = <<END
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.
END puts "--------------"
puts poem
puts "--------------" five = 10 - 2 + 3 - 6
puts "This should be five: #{five}" def secret_formula(started)
jelly_beans = started * 500
jars = jelly_beans / 1000
crates = jars / 100
return jelly_beans, jars, crates
end start_point = 10000
beans, jars, crates = secret_formula(start_point) puts "With a starting point of: #{start_point}"
puts "We'd have #{beans} beans, #{jars} jars, and #{crates} crates." start_point = start_point / 10
puts "We can also do that this way:"
puts "We'd have %s beans, %d jars, and %d crates." % secret_formula(start_point)

""与<<XXX的写法,\t会变成空格,\n会换行

''里面是什么就是什么

Let's practice everything.
You'd need to know 'bout escapes with \ that do \n newlines and \t tabs.
--------------
The lovely world
with logic so firmly planted
cannot discern
the needs of love
nor comprehend passion from intuition
and requires an explanation where there is none.
--------------
This should be five: 5
With a starting point of: 10000
We'd have 5000000 beans, 5000 jars, and 50 crates.
We can also do that this way:
We'd have 500000 beans, 500 jars, and 5 crates.

  

Exercise 24: More Practice的更多相关文章

  1. 【Bell-Ford 算法】CLRS Exercise 24.1-4,24.1-6

    本文是一篇笔记,大部分内容取自 CLRS 第三版,第 24.1 节. Exercise 24.1-4 Modify the Bellman-Ford algorithm so that it sets ...

  2. Simple Tips for Collection in Python

    I believe that the following Python code is really not hard to understand. But I think we should use ...

  3. 【239】◀▶IEW-Unit04

    Unit 4 Youth Issues: Computer Use 1 Model1题目及范文分析 Some teenagers spend a lot of time playing compute ...

  4. Building Applications with Force.com and VisualForce(Dev401)(十一):Designing Applications for Multiple Users: Proseving Data Quality

    Dev401-012:Proseving Data Quality Universal Containers Scenario1.Universal Containers(UC) wants to e ...

  5. Matlab解析LQR与MPC的关系

    mathworks社区中的这个资料还是值得一说的. 1 openExample('mpc/mpccustomqp') 我们从几个角度来解析两者关系,简单的说就是MPC是带了约束的LQR. 在陈虹模型预 ...

  6. CMSC 216 Exercise #5

    CMSC 216 Exercise #5 Spring 2019Shell Jr (”Shellito”) Due: Tue Apr 23, 2019, 11:30PM1 ObjectivesTo p ...

  7. MIT 6.828 JOS学习笔记5. Exercise 1.3

    Lab 1 Exercise 3 设置一个断点在地址0x7c00处,这是boot sector被加载的位置.然后让程序继续运行直到这个断点.跟踪/boot/boot.S文件的每一条指令,同时使用boo ...

  8. OpenJudge 2787 算24

    1.链接地址: http://poj.org/problem?id=1631 http://bailian.openjudge.cn/practice/2787/ 2.题目: 总时间限制: 3000m ...

  9. JavaSE学习总结第24天_多线程2

      24.01  JDK5之后的Lock锁的概述和使用 虽然我们可以理解同步代码块和同步方法的锁对象问题,但是我们并没有直接看到在哪里加上了锁,在哪里释放了锁,为了更清晰的表达如何加锁和释放锁,JDK ...

随机推荐

  1. 数据类型、常量、变量、printf、scanf和运算符

    数据类型 常量 变量 printf函数介绍 scanf函数介绍 运算符 数据类型 数据类型是指数据在内存中存储的方式. C语言中有5大数据类型:基本类型.构造类型.指针类型.空类型.定义类型. C语言 ...

  2. 微信JS SDK Demo 官方案例[转]

    摘要: 微信JS-SDK是微信公众平台面向网页开发者提供的基于微信内的网页开发工具包. 通过使用微信JS-SDK,网页开发者可借助微信高效地使用拍照.选图.语音.位置等手机系统的能力,同时可以直接使用 ...

  3. Excel学习技巧

    ctrl+R 初始化信息 ctrl+T 创建表列 ctrl+o 保存文件

  4. HTML5 和HTML4的区别

    1.推出理由和目标 HTml5的出现,对于web来说意义是非常重大的,因为它的意图是想要把目前web 上存在的各种问题一并解决掉. (1)web之间的兼容性很低 (2)文档结构不明确 (3)web应用 ...

  5. 160809208沈昊辰c语言程序设计实验选择结构设计

    <C语言程序设计>实验报告 学 号 160809208 姓 名 沈昊辰 专业.班 计科16-2班 学    期 2016-2017 第1学期 指导教师 黄俊莲 吴喆 实验地点 C区二层机房 ...

  6. Codeforces Round #284 (Div. 2) C题(计算几何)解题报告

    题目地址 简要题意: 给出两个点的坐标,以及一些一般直线方程Ax+B+C=0的A.B.C,这些直线作为街道,求从一点走到另一点需要跨越的街道数.(两点都不在街道上) 思路分析: 从一点到另一点必须要跨 ...

  7. Android studio打开之后 cannot load project: java.lang.NUllpointerException

    参考来源:http://bbs.csdn.net/topics/391014393 关闭网络,重新打开Android studio就好了.(但是原因不清楚是为什么?) Internal error.  ...

  8. uva 1339 Ancient Cipher

    大意:读入两个字符串(都是大写字母),字符串中字母的顺序可以随便排列.现在希望有一种字母到字母的一一映射,从而使得一个字符串可以转换成另一个字符串(字母可以随便排列)有,输出YES:否,输出NO:ex ...

  9. eclipse 相同变量高亮显示

    windows-> preferences-> java-> Editor-> Mark Occurences

  10. js动画之链式运动

    链式运动就是当一个运动完,又启动另外一个运动,这个怎么实现呢?这里我们是用用回调函数实现一套链式动画 显示给div左移100像素,然后然后透明度变100 <!DOCTYPE html> & ...