简体   繁体   中英

How do I ask for the input of a variable when needed instead of typing input() before every line?

How do I make it so if this variable is needed, it'll ask for the input of this variable?

"""imports"""
import math
"""def"""
def rectArea:
    return A = l * b
def rectPeri:
    return P = 2 * (l+b)
def squareArea:
    return A = l*l
def squarePeri:
    return P = l * 4
def parallelogramArea:
    return A = l * h
def parallelogramPeri:
    return P = 2 * (l+b)

For example in rectArea , length( l ) and breadth( b ) are needed, so it would ask for an input of the l and b variables?

对于用户输入,请使用input()方法。

length = input("Enter rectangle length: ")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM