If I understand your question correctly: You have a web application and you want to send two values to a Python script; have it perform some operation and return a result.
While you could do this with EC2 I wouldn't recommend it - you would have a whole instance running all the time even when your web application isn't requesting any results.
Instead, consider using Lambda. Create a Lambda function using Python then publish that function using Lambda function URLs - you pass the two values to the URL and it executes the Lambda function, returning the appropriate value.
What is the most effective way to automate the EC2 instance run Python script with a specific argument value?
How can I get the Image ID after importing a disk image?asked a year ago
Using AWS Lambda to run Python script, how can I save data?Accepted Answerasked 3 years ago
How to retrieve job run id from the script itself in python shell glue jobasked 4 months ago
Keep the python script aliveAccepted Answerasked 8 months ago
Unable to run a Python script using BashOperatorAccepted Answerasked a year ago
Install the latest python (3.8) on EC2Accepted Answerasked 3 years ago
from the web application to how can I run the Python script in the Ubuntu terminal?
Component with bash script and python code - how to package/deployasked a year ago
Can I specify the python version?asked 5 months ago