Giter VIP home page Giter VIP logo

conditional-quiz-vowels's Introduction

Quiz: Practicing Conditionals with Vowels

Objectives

You will answer a series of multiple choice questions to help you practice the following:

  1. Flow control and the use of if, elsif, and else statements.
  2. Flow control and the use of case statements.
  3. Using comparative operators.

The questions in this quiz are predicated on the idea of building methods that can determine if a letter is a vowel or a consonant. For the purposes of this quiz, vowels will be "a", "e", "i", "o", and "u" (sorry, but you're not in the club, "y").

???

Conditional Vowels

?: Checking for vowels with if, elsif, and else

We're building a method, vowels_with_if_elsif that will take in a letter and return true if that letter is a vowel and false if that letter is a consonant.

def vowels_with_if_elsif(letter)
  < fill me in!! >
end

Which of the following is the correct implementation of if, elsif, and else?

(X)

if letter == "a"
  true
elsif letter == "e"
  true
elsif letter == "i"
  true
elsif letter == "o"
  true
elsif letter == "u"
  true
else
  false
end

( )

if letter = "a"
  true
elsif letter = "e"
  true
elsif letter = "i"
  true
elsif letter = "o"
  true
elsif letter = "u"
  true
else
  false
end

?: What would the following statement return?

letter = "b"

if letter == "a" || letter == "e" || letter ==  "i" || letter == "o" || letter == "u"
  "vowel"
else
  "not a vowel"
end

( )vowel (X)not a vowel

?: Checking for vowels with case

The method vowels_with_case takes in a letter as an argument and uses a case statement to determine if that letter is a vowel.

def vowels_with_case(letter)
  case letter
  < fill me in! > "a"
    true
  < fill me in! > "e"
    true
  < fill me in! > "i"
    true
  < fill me in! > "o"
    true
  < fill me in! > "u"
    true
  else
    false
  end
end

Which keyword correctly replaces < fill me in! > ?

( )if ( )elsif (X)when ( )while

?: Which of the following methods would correctly return true when given the letter "o" as an argument?

(X)

def vowels_with_if_single_line(letter)
  true if letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u"
end

( )

def vowels_with_if_single_line(letter)
  true if letter == "a" && letter == "e" && letter == "i" && letter == "o" && letter == "u"
end

( )

def vowels_with_if_single_line(letter)
  true if letter == "a" || if letter == "e" || if letter == "i" || if letter == "o" || if letter == "u"
end

???

View Quiz: Practicing Conditionals with Vowels on Learn.co and start learning to code for free.

conditional-quiz-vowels's People

Contributors

sophiedebenedetto avatar sarogers avatar annjohn avatar biancalpadilla avatar jessrudder avatar joll59 avatar markedwardmurray avatar

Watchers

James Cloos 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.