简体   繁体   English

我如何在需要时要求输入变量,而不是在每行之前输入input()?

[英]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? 例如在rectArea ,需要length( l )和rectAreab ),那么它会要求输入lb变量吗?

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

length = input("Enter rectangle length: ")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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