怎样学好一门编程语言

从键盘输入x值,编写函数计算y=2x的3次方+1/2,从键盘输入x值,编写函数计算y=2x的3次方+1/2

可以参考下列代码

import math


def fun(x):
    y = math.pow(2 * x, 3) + 1 / 2
    return y


x = int(input())
print("y=%.2f" % fun(x))
def calculate_y(x):
    y = pow(2*x, 3) + 1/2
    return y

x = float(input("请输入 x 值:"))
y = calculate_y(x)
print("y = {:.2f}".format(y))