+ 1
What is the point of contrast between the two?
I wrote these codes to calculate the result of raising a number to a certain power.They both ran perfectly same. x = int(input()) y = pow(x,int(input ())) print(y) x = int(input ()) y = int(input ()) print(pow(x,y))
2 Antworten
+ 4
they are basically the same.
The difference is only where the pow function was called.
you can also do it without variables.
print(pow(int(input()),int(input())))
or you can use the walrus operator :=
to do the variable assignment while using them
print(pow(x:=int(input()),y:=int(input())))
print(x)
print(y)
+ 1
Thank you sir
I really appreciate your answer