Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

python - Python:如何为变量分配功能?(Python: how can I assign a function to a variable?)

I created a data quantity calculator.

(我创建了一个数据量计算器。)

I want, that I input a number and the number is assign to a function.

(我想要输入一个数字并将数字分配给一个函数。)

For example: inputChose your input 1 and I get the bit calculator.

(例如:input选择您的输入1,我得到位计算器。)

input("Choose your calculator") and then 1 is assign to the bit calculator

(输入(“选择您的计算器”),然后将1分配给位计算器)

#Tebibyte Calculator
def tebi():
    x = int(input("Please enter number of tebibytes")))
    # y = Bit, z = Byte, a = Kibibytes, b = Mebibytes, c = Gibibytes
    y = x * 8,796*10**9
    z = x * 1.1*10**12
    a = x * 1.1*10**9
    b = x * 1,1049*10**9
    c = x * 1024
    # Output of invoices
    print(
        x, "Tebibyte :", y, "Bits 
",
        x, "Tebibyte :", z, "Byte
",
        x, "Tebibyte :", a, "Kibibyte
",
        x, "Tebibyte :", b, "Mebibyte
",
        x, "Tebibyte :", c, "Gibibytes"
    )
input("Please choose your converter
"
    "1 - Input in Bit
"
    "2 - Input in Byte
"
    "3 - Input in Kibibyte
"
    "4 - Input in Mebibyte
"
    "5 - Input in Gibibyte
"
    "6 - Input in Tebibyte
"
    "0 - Exit"
    )
6 = tebi()
  ask by TheTjschulze translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...