Ruby - Variables and Data TypesWhich of the following is the correct way to write a float number in Ruby?A5.5B5-5C5..5D5,5Check Answer
Step-by-Step SolutionSolution:Step 1: Recall float syntax in RubyFloats use a dot (.) to separate the whole number and decimal parts.Step 2: Check each option5.5 uses a dot correctly. 5,5 uses a comma which is invalid. 5..5 is a range syntax, not a float. 5-5 is subtraction.Final Answer:5.5 -> Option AQuick Check:Float uses dot like 5.5 [OK]Quick Trick: Floats always use a dot, never a comma. [OK]Common Mistakes:Using commas instead of dotsConfusing ranges with floatsUsing operators instead of decimal points
Master "Variables and Data Types" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Control Flow - Why Ruby has multiple control flow styles - Quiz 13medium Hashes - Hash as named parameters pattern - Quiz 7medium Loops and Iteration - While loop - Quiz 11easy Loops and Iteration - For loop (rarely used in Ruby) - Quiz 1easy Loops and Iteration - Each as the primary iterator - Quiz 7medium Methods - Predicate methods (ending with ?) - Quiz 13medium String Operations - Split and join methods - Quiz 15hard Variables and Data Types - Symbol type and immutability - Quiz 8hard Variables and Data Types - String interpolation with #{} - Quiz 5medium Variables and Data Types - Boolean values (true, false, nil) - Quiz 5medium