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. Windows Store App JavaScript 开发:小球运动示例

    通过前面内容的学习,相信读者已经对开发基于JavaScript的Windows应用商店应用有了一定的了解,本小节通过一个小球运动的示例来介绍如何新建一个JavaScript的Windows应用商店项目 ...

  2. 【转】js插件zClip实现复制到剪贴板功能

    相信这个功能大家平时上网经常能碰到,以前也没怎么留意怎么实现的,直到项目中需要. 网上一搜一大堆,单纯使用js方法也不是没有,但是由于各浏览器的安全机制不同,不是跨浏览器的.去看了几个常用的网站,都是 ...

  3. JS中关于clientWidth offsetWidth scrollWidth 等的含义

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...

  4. 浏览器主页被hao123贱贱的篡改的一种方式

    今天打开一个PDF文件(正经文件,不要想歪了),误点了一个“编辑”按钮,出来发现浏览器主页被篡改了,包括chrome和IE.通过一个网址"www.qquuu8.com"跳转到hao ...

  5. EF框架学习

    简称EF,ADO.NET Entity Framework是微软以ADO.NET为基础所发展出来的对象关系对应(O/R Mapping)解决方案,是微软的一个ORM(面向对象的对象模型和关系型数据库的 ...

  6. mysql-5.6.17-win32的安装?

    官方mysql最新版本:http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz 解压后,以管理员的身份打开cmd.exe,切入安装目录 ...

  7. 1627. Join

    http://acm.timus.ru/problem.aspx?space=1&num=1627 给一个无向图,问可以有多少生成树 参照     周冬<生成树的计数及其应用> 代 ...

  8. adapter用法

    Android之Adapter用法总结 1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的View(ListView,GridView) ...

  9. Pyunit测试框架

    一.概述 本系列主要解决的问题是“接口自动化测试”,选择的测试语言是 python 脚本语言.截至目前为止,python是公认的最好的用于自动化应用的语言之一 二.PyUnit测试框架 使用 pyth ...

  10. Spring(1)

    一.Spring是什么? .Spring是一个开源的框架 .是一个IOC(DI)和AOP容器的框架 .这个框架是为了简化企业级应用开发而生的,使用Spring可以使简单的JavaBean实现以前只有E ...