Writing formatted strings to a file

Report a typo

Emma has created a function circleArea that calculates the area of a circle ⭕ and then writes it to a file circle_area.txt:

package main

import (
    "fmt"
    "log"
    "math"
    "os"
)

func circleArea(radius float64) {
    area := math.Pi * math.Pow(radius, 2)

    file, err := os.Create("circle_area.txt")
    if err != nil {
        log.Fatal(err)
    }

    _, err = ? // the selected code line goes here
    if err != nil {
        log.Fatal(err)
    }
}

Can you help Emma select the correct code line required to write the area to the file with 3 decimal places?

Select one option from the list
___

Create a free account to access the full topic