Recap - True or False
Part of the Fundamentals section of Coddy's Ruby journey — lesson 33 of 88.
Challenge
EasyRead three integers from the user as input:
- A number to check
- A lower bound
- A upper bound
Determine if the first number falls within the range (inclusive) defined by the lower and upper bounds. Print the result as true or false.
Use comparison operators and the logical && operator to check if the number is greater than or equal to the lower bound AND less than or equal to the upper bound.
For example, if the inputs are 15, 10, and 20, the output should be:
trueIf the inputs are 5, 10, and 20, the output should be:
falseTry it yourself
# Read input
number = gets.chomp.to_i
lower_bound = gets.chomp.to_i
upper_bound = gets.chomp.to_i
# TODO: Write your code below
# Check if number is within the range (inclusive) using && operator
# Output the result
puts resultAll lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Logical Operators Part 42Variables and Data Types
Numbers and VariablesString Data TypeBoolean Data TypeSymbol Data TypeChecking Data TypesNaming ConventionsRecap - Variable Creation8Loops
For Loop with RangesWhile LoopBreakNextRecap - FactorialTimes LoopUntil LoopNested LoopsRecap - Dynamic Input3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators6Basic IO
Output with putsOutput with print and pOutput With VariablesInput with getsChomp MethodType ConversionRecap - Age CalculatorRecap - True or False