通过实例学Ruby编程
通过实例学Ruby编程
關於本書
2013年12月8日,美国总统奥巴马“要求每一个美国人都要尝试学习编程”,以此拉开计算机科学教育周刊2013年发起的每天学习代码一小时的活动序幕。奥巴马说: “学习这些技能不仅对你的未来十分重要,它对国家的未来也意义重大。” 可见,编程是这个信息时代一个重要的技能。
一个典型的教授如何编程的书将通过编程概念,语法和用简单例子做示范等方式来教学。我以前看过几十本这样的编程语言或工具书,而且在大学任教时也是用这种方式教学。我认为这并不是一种有效的方法,因为它更像是一个老师对学生的知识倾倒。我相信更好的办法是,让学生们通过编程练习循序渐进地学习,并指导他们解决有趣和实用的计算机程序,包括:
• 求最大公约数
• 个人所得税计算
• 随机产生六合彩号码
• 狼、羊、白菜和农夫过河谜题
每个练习(共43个)都有针对性地引进新的编程概念并适当地巩固先前知识。本书强调实用性并着重培养读者的编程思维能力。书的最后一章介绍了利用编程来做自动化测试,这是在美国评为最幸福职业 “软件测试工程师”的必备技能。
我把我的编程教学思想付诸实践,本书也是在教我的13岁的女儿Courtney学习编程时所做的总结。
Ruby是一种流行的编程语言,它被广泛用于Web应用程序和软件测试。 由于Ruby的简单,优雅和简洁的语法,它被认为是最佳的初学编程语言之一。
書籍目錄
-
前言
- 本书的独特之处
- 谁应该读这本书?
- 英文术语
- 如何读这本书
- 反馈
-
1. 介绍
- 1.1 在Windows电脑运行Ruby程序
- 1.2 在苹果电脑(Mac OS X)上运行Ruby程序
- 1.3 在线Ruby教程
- 1.4 做练习的步骤
- 1.5 窗口布局建议
- 1.6 常见错误
- 1.7 交互式Ruby (IRB )
-
2. 打印形状
- 2.1 打印出三角形
- 2.2 打印半个菱形
- 2.3 打印菱形
- 2.4 打印指定大小菱形
-
3. 互动测验
- 3.1 加法计算器
- 3.2 加法测验
- 3.3 减法测验
- 3.4 猜数字游戏
-
4. 数组(Array)和哈希表(Hash)
- 4.1 名字排序
- 4.2 从指定的字母位置获得字符
- 4.3 计算平均数
- 4.4 英文单词的生命意义的百分比?
-
5. 实用工具程序
- 5.1 华氏度到摄氏度的转换
- 5.2 个人收入所得税计算
- 5.3 字数统计
- 5.4 生成六合彩数字
- 5.5 数字排序
-
6. 趣味数学
- 6.1 查找约数
- 6.2 寻找最大公约数
- 6.3 寻找最小公倍数(LCM)
- 6.4 查找质数
- 6.5 斐波那契(Fibonacci) 序列
- 6.6 连续求和
-
7. 方法 (Method)
- 7.1 寻找最大公约数(使用Method)
- 7.2 生成六合彩号码(使用Method)
- 7.3 寻找多个数字的LCM(使用Method)
-
8. 文件和网络
- 8.1 计算平均得分
- 8.2 计算在文本文件中的单词和行数
- 8.3 生日派对邀请卡
- 8.4 重命名多个文件
- 8.5 实时货币兑换
- 8.6 发送个人致谢电子邮件
-
9. 面向对象的编程
- 9.1 计算器(Class)
- 9.2 教师和学生的年龄
- 9.3 计算销售税
- 9.4 图书馆系统
- 9.5 向日葵战僵尸模拟游戏
-
10. 经典谜题
- 10.1 谷歌能力倾向面试
- 10.2 斐波那契数列和HCF(递归)
- 10.3 计算复合利率
- 10.4 狼、羊、白菜和农夫过河谜题
- 10.5 神秘的数学公式(回溯)
- 10.6 更多练习
-
11. 自动化测试Web App
- 11.1 最幸福的职业
- 11.2 安装Selenium WebDriver
- 11.3 用Selenium WebDriver 驱动 Chrome
- 11.4 用Selenium WebDriver 驱动 Firefox
- 11.5 用Selenium WebDriver 驱动 IE
- 11.6 通过验证来完成测试
- 11.7 欲了解更多有关测试自动化…
-
12. 本书之后
- 12.1 更多Ruby
- 12.2 更多练习
- 12.3 使用Ruby写自动化测试
- 12.4 用Ruby on Rails开发Web App
- 12.5 游戏编程和移动应用程序
- 12.6 学习另一种编程语言
- 附录 1 Ruby语法简要
-
附录 2 答案
- 第二章
- 第三章
- 第四章
- 第五章
- 第六章
- 第七章
- 第八章
- 第九章
- 第十章
-
资源
- 代码编辑器
- Ruby 语言
- Ruby 教程
- 更多练习
- 自动化测试
Leanpub 無條件、無風險的 100% 滿意保證
從付款之後的 60 天內,只要點個兩下,你就可以完成退書並且取回先前支付的全數金額。退書是採用人工作業,因此可能需要花幾天的時間才能完成整個程序。
See full terms.
Do Well. Do Good.
Authors have earned$11,718,542writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
Recipes for Decoupling
Matthias NobackWrite software that survives
CQRS by Example
Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary- Leverage your Software Architecture skills by learning everything about CQRS in detail with lots of examples
- Develop faster applications by applying CQRS and fostering Read Models and Projections
- Learn how to apply CQRS into a brownfield project from a pragmatic approach
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Maîtriser Apache JMeter
Philippe Mouawad, Bruno Demion (Milamber), and Antonio Gomes RodriguesToute la puissance d'Apache JMeter expliquée par ses commiteurs et utilisateurs experts. De l'intégration continue en passant par le Cloud, vous découvrirez comment intégrer JMeter à vos processus "Agile" et Devops.
If you're looking for the newer english version of this book, go to Master JMeter : From load testing to DevOps
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
The PowerShell Scripting and Toolmaking Book
Don Jones and Jeff HicksLearn the patterns, practices, and details of PowerShell Scripting and Toolmaking from the industry's two most recognized experts on the subject.
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Introduction to Data Science
Rafael A IrizarryThe demand for skilled data science practitioners in industry, academia, and government is rapidly growing. This book introduces concepts from probability, statistical inference, linear regression and machine learning and R programming skills. Throughout the book we demonstrate how these can help you tackle real-world data analysis challenges.
Top Bundles
- #1
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #3
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #5
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #10
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon...