In this exercise, you will create a Ruby script to detect the minimum and maximum values from a collection of randomly generated numbers. Specification File Name: random-min-max.rb Input: Several numbers representing the minimum possible randomly generated number, the maximum possible randomly generated number, and the number of random numbers to generate. Output: Several strings containing various prompts, the results of the minimum and maximum detected values from the randomly generated numbers, and all of the randomly generated numbers for verification purposes.
In this exercise, you will create a Ruby script for a simple command line calculator. Specification File Name: simple-calculator.rb Input: Several strings containing your name, the user’s name, integers, and floats. Output: Several strings containing various prompts and the results of various arithmetic calculations. Methods Used: puts, print, gets, to_i, to_f, to_s (for floats) Sample Output Welcome to the Simple Calculator by Disciples of Code Please enter your name: Clark Kent Hello, Clark Kent Let's try some addition!
If you have not yet set up your development environment, please refer to Part 1 of this primer. Using IRB The Ruby Interactive Shell, or IRB, provides a command line with which we can immediately evaluate a Ruby statement or expression. To load IRB, open a Terminal window (OS X or Linux) or a Command Prompt (Windows), and execute the following command. ``` bash Loading IRB $ irb You should now be inside IRB, and should have a command prompt similar to the following.
The first step to learning Ruby (or any programming language) is to set up your development environment, so let’s dive right in. The simplest method is to use a free, online development environment, such as those provided by Koding.com. If you have already signed up for a GitHub account (which is highly recommended for source control and for sharing your code), you can sign up for Koding.com using your GitHub account credentials.
I say ‘code’, you say ‘program’. He says ‘script’, she says ‘app’. Does it matter? Putting aside the many technical definitions and nuances, in practice these terms are nearly synonymous — at least to a general audience. What we’re really talking about is machine language, or a way of communicating with machines (e.g., computers) by combining a set of symbols, words, and statements according to certain predefined rules. Communication is more than just words, communication is architecture, because of course it is quite obvious that a house which would be built without that will, that desire to communicate, would not look the way your house looks today.
You can launch your favorite web browser and do an Internet search, and find any number of individuals and organizations offering reason after reason that learning to code is important. You can most likely find an equal number offering an opposing opinion. Of course, like with nearly all subjects of grand relevance, what this really means is that the ‘Why’ to the importance of coding, is up to you. And with any endeavor, the end result and polished nature of the output is nowhere near as significant as the attitude and approach of the individual undertaking the task.
So you are ready to begin your journey and learn to code, but you don’t know where to begin. Of course, information is free, for those willing to find it, but not all information is as valuable or worthwhile when you are just starting out. At this point, you can’t tell bad code from good. You have no idea whether you should start out by thumbing through some massive tome of seemingly arcane jargon in an attempt to glean some tidbit of understanding, or simply fire up your trusty Internet search engine and dive in head-first.