+ 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))

19th Nov 2023, 11:29 PM
Sa ad Mansur Bello
Sa ad Mansur Bello - avatar
2 Réponses
+ 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)
20th Nov 2023, 12:44 AM
Bob_Li
Bob_Li - avatar
+ 1
Thank you sir I really appreciate your answer
20th Nov 2023, 1:31 AM
Sa ad Mansur Bello
Sa ad Mansur Bello - avatar