![](/img/trans.png)
[英]How can I create a dictionary without distinction and only using python built-in funtions(from two lists)?
[英]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.