簡體   English   中英

我如何使用 =、>、< 比較 python 中的兩個函數。 我不知道如何撤銷功能

[英]How can i compare between two funtions in python using =,>,<. I dont know how to revoke functions

def plus(x,y):

   return x+y

def multiply (u,z):

   return u*z

answer1 = int(input("what is x ?"))

answer2 = int(input("what is y? "))

answer3 = int(input("what is u ?"))

answer4 = int(input("what is z? "))

if plus > multiply:

   print("plus is bigger")

elif multiply > plus:

   print(" multiply is bigger")

else:

   print("they are equal") 

調用函數:

if plus(x, y) > multiply(u, z):

   print("plus is bigger")

elif multiply(x, y) > plus(u, z):

   print(" multiply is bigger")

else:

   print("they are equal") 

或者先分配它們:

x = plus(x, y)
y = multiply(u, z)
if x > y:

   print("plus is bigger")

elif y > x:

   print(" multiply is bigger")

else:

   print("they are equal") 

您還沒有撥打 function。

這應該工作。

def plus(x, y):
    return x+y

def multiply(u, z):
    return u*z

answer1 = int(input("what is x ?"))
answer2 = int(input("what is y? "))
answer3 = int(input("what is u ?"))
answer4 = int(input("what is z? "))

Sum, Product = plus(answer1, answer2), multiply(answer3, answer4)

if Sum == Product:
    print("Equal")
elif Sum > Product:
    print("Sum is greater")
else:
    print("product is greater")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM