Implement a function that takes arguments x, y, z and returns the string "y at x is z". Furthermore, set x = 12, y = "temperature", z = 22.4, and check the execution result.
Go
package main
import "fmt"
func template(x,y,z string) string {
return fmt.Sprintf("%s time%s is%s",x,y,z)
}
func main() {
fmt.Println(template("12","temperature","22.4"))
}
python
# -*- coding: utf-8 -*-
def template(x,y,z):
return '{0}of time{1}Is{2}'.format(x,y,z)
print template(12,"temperature",22.4)
Javascript
function template(x,y,z) {
return "y at x is z".replace("x",x).replace("y",y).replace("z",z);
}
console.log(template(12,"temperature",22.4));
Is this all right? ..
Recommended Posts