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. ios基础篇(二十六)—— UITableViewCell的分组索引与标记

    一.表视图的索引目录 首先要创建一个TableView,之前有说过,这里就不详细说了(参考前面第十四篇). 直接贴代码吧, #import "ViewController.h" @ ...

  2. org.apache.catalina.webresources.Cache.getResource Unable to add the resource

    org.apache.catalina.webresources.Cache.getResource Unable to add the resource at xxx to the cache be ...

  3. centOS 6.7 中安装matlab R2014b

    参考资料: [1] http://www.centoscn.com/image-text/config/2014/1222/4354.html 系统: centOS 6.7 2.6.32-573.el ...

  4. Android ORM应用开发框架KJFrameForAndroid使用详解

    本文将为大家介绍一款Android ORM应用开发框架KJFrameForAndroid,很多时候我们也叫它KJLibrary. KJFrameForAndroid简介 KJFrameForAndro ...

  5. MySQL5.6 GTID、多线程复制

    MySQL5.6新特性GTID.多线程复制 在Oracle发布MySQL5.6看到众多新特性之后很兴奋,包括对复制的改进.在MySQL5.5半同步复制之后MySQL5.6又引入GTID.多线程复制,在 ...

  6. JS 跑马灯

    利用jquery 来实现图片切换.文字转换移动的工具. MSClass 连接 http://www.popub.net/script/MSClass.html Mark 用

  7. $(document).ready() 与 window.onload 之间的区别

    1.执行时机 window.onload 是网页中所有的元素都加载到浏览器后才执行 $(document).ready() 是dom完全就续就可以调用 例如:如果给一副图片添加点击事件,window. ...

  8. Operational Amplifiers

    1>.Operational Amplifiers:different from the resistor,the inductor and the capacitor,it's a multi ...

  9. sqlserver 2008 孤立用户解决方法

    从别一台服务器上得到一个数据库备份.还原到本地,数据库中的用户无法登录,也就是联机帮助中说的还原备份可能产生的孤立用户问题. 一.新建一个 MyDataBase 数据库 二.把备份文件放到 C 盘根目 ...

  10. 关于CSS三列Float布局任务

    任务目标 掌握HTML/CSS布局的概念 掌握盒模型的概念 掌握position与float的概念以及在布局时的用法 任务描述 使用 HTML 与 CSS 按照示意图;实现三栏式布局. 左右两栏宽度固 ...