Giter Site home page Giter Site logo

if-statements-chapter's Introduction

Ruby Practice

Run your Ruby file by typing ruby and then the name of the file you want to run in the Terminal.

If we want to run conditionals_rps.rb, we can write the command:

ruby conditionals_rps.rb

To re-run this command, you can use the UP and DOWN arrow keys to look at the history of commands you've run in a Terminal.

Conditionals

conditionals_rps.rb

Write a program that:

Asks the player to input rock, paper, or scissors. Based on what the player chose, prints "You played rock!" or "You played paper!" or "You played scissors!" The computer is pretty dumb in this version of our game; it always plays scissors. Print "The computer played scissors!" Based on what the player chose, prints "You won!" or "You lost!" or "You tied!" If you need a refresher on the rules of Rock, Paper, Scissors: https://en.wikipedia.org/wiki/Rock%E2%80%93paper%E2%80%93scissors

conditionals_palindrome.rb

Ask for a word, check if it is a palindrome, and display true if it is one and false if it isn't.

A word is a palindrome if it reads the same backwards as forwards, e.g. "madam".

Remember to display the actual value true or false, not the strings containing the letters "true" or "false".

Input: hannah

Key output: true

Complete input and output example:

"Enter one word"
hannah
true

Specs

Click here to see names of each test

conditionals_rps.rb should output 'You lost!' given the input 'paper'

conditionals_palindrome.rb should output 'true' given the input 'HanNah'

conditionals_palindrome.rb should output 'false' given the input 'candy'

conditionals_palindrome.rb should output 'false' given the input 'racecars'

conditionals_palindrome.rb should output 'true' given the input 'racecar'

conditionals_rps.rb should output 'You won!' given the input 'rock'

conditionals_rps.rb should output 'You tied!' given the input 'scissors'

if-statements-chapter's People

Contributors

jelaniwoods avatar iblash avatar pmckernin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.