Reassigning the value of variables in Ruby?

Try something like this where you use lower case variable names rather than upper case constant names: def square_root(radicand) a, b = radicand, 1 tolerance = 0.00000000000000000001 while (a – b).abs > tolerance a = (a + b) / 2 b = radicand / a end a end print “Enter the radicand:” radicand = gets.to_f … Read more

Explain like I'm LITERALLY five…what does it mean to "format" a string? [closed]

The most common use of the phrase refers to the replacing of variable placeholders within a string with the correct string representations of the variables’ contents. Consider: temp_reading = 25.67528 puts “It is currently %0.1f degrees” % [temp_reading] -> It is currently 25.7 degrees String formatting is what turns the template into the string you … Read more