x= 2000
y= 3000
z= 3500
a = int (input ("Number of Americano Sales: ")))
b = int (input ("Café latte sales count: ")))
c = int (input ("number of cappuccino sold: ")))
t = x*a
t = t + y*b
t = t + z*c
print ("Total sales are", t, ")
m=1000000
if t < m :
print(t - m, "far deficit")
else: print (m-t, "one surplus")
How can I write the last paragraph without using an ifelse statement?
python if문 else
There is a way to use the dictionary as shown below.
d = {True:lambda:print ("True"), False:lambda:print ("False").}
d[300>200]()
It's true.
t = 2000000
m = 1000000
D = {True:lambda:print (m - t, "original surplus"), False:lambda:print (t - m, "original deficit")}
D[t < m]()
It's a loss of 10,000 won
© 2024 OneMinuteCode. All rights reserved.