ruby string format

# Step 1: Define variables
name = "John"
age = 25
height = 6.2

# Step 2: Use string interpolation to format a string
formatted_string = "My name is #{name}, I am #{age} years old, and my height is #{height} feet."

# Step 3: Print the formatted string
puts formatted_string

# Step 4: Use printf for more controlled formatting
printf("Name: %-10s | Age: %03d | Height: %.2f feet\n", name, age, height)

This Ruby script demonstrates string formatting using string interpolation and printf. In Step 1, variables name, age, and height are defined. Step 2 utilizes string interpolation to create a formatted string with the values of these variables. Step 3 prints the formatted string to the console. Step 4 shows an alternative formatting approach using printf for more control over the output.