Skip to content

aquaranto/PineLTPAnswers

Repository files navigation

PineLTPAnswers

Solutions for the 'A Few Things to Try' sections for the Buffalo Learning to Code group

Contents

Chapter 1 : Numbers

1.5.0numbers.rb

Calculate the Following

-Hours in a year -Minutes in a decade -Your age in seconds -The author's age in years.

###Chapter 4 : Mixing It Up

4.6.1FullName.rb

Ask the user for their full name and greet them!

4.6.2BetterNumber.rb

Ask the user what their favorite number is. Suggest a number that is bigger and better.

###Chapter 5 : More About Methods

5.2.1AngryBoss.rb

Ask the user what they want. Throw them out of your office and fire them!

5.2.2TableOfContents.rb

Display a table of contents using .ljust(), .rjust(), and .center().

###Chapter 6 : Flow Control

6.5.1BottleOfBeer.rb

Write a program that prints out the lyrics 99 Bottle of Beer. My example asks the user for a number and only runs if the number is between 1 and 99.

6.5.2DeafGrandma.rb

Whatever you say to grandma needs to be in ALL CAPS. If it isn't ALL CAPS she should ask you to repeat yourself. When it is in ALL CAPS she should pretend that she heard you.

6.5.3DeafGrandma2.rb

Same as the first DeafGrandma with a small twist. When you say 'BYE' she should pretend not to hear you but when said 3 times in a row she should let you leave. REMINDER: if you shout 'BYE', but not three times in a row, you should still be talking to grandma.

6.5.4LeapYear.rb

Write a program which will ask for a starting year and an ending year, and then puts all of the leap years between them (and including them, if they are also leap years). Leap Years are those years divisible by 4, those divisible by 100 aren't leap years, but those divisible by 400 are.

###Chapter 7 : Arrays and Iterators

7.5.1SortedWords.rb

Write a program which asks us to type in as many words as we want (one word per line, continuing until we just press Enter on an empty line), and which then repeats the words back to us in alphabetical order. Use the .sort method

7.5.2SortedWordsReboot.rb

THIS EXAMPLE IS INCOMPLETE Write the same program as 7.5.1 but without the .sort method. I used the bubble sort method.

7.5.3TableofContentsREVISITED.rb

Rewrite your table of contents program from chapter 5. Start with an array holding all of your information.

7.5.4TableofContentsBeccaChallenge.rb

Using the ToC REVISITED example from above, retrieve the values for the chapter name and page number from the user. Print them in the same way.

###Chapter 8 : Writing your own Methods

8.5.1EnglishNum.rb

Expand upon the english number example from the online book (trillions, billions, millions, thousands, hundreds, tens, ones)

8.5.2BottlesREBOOT.rb

Take the number method created in 8.5.1EnglishNum and apply it to the bottles of beer example from chapter 6 (Thanks to Andy S. for the code!)

About

Solutions for the 'A Few Things to Try' sections for the Buffalo Learning to Code group

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages