Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON HELP 1. We will pass in 2 values, X and Y. You should calculate XYXY and

ID: 3878341 • Letter: P

Question

PYTHON HELP

1. We will pass in 2 values, X and Y. You should calculate XYXY and output only the final result.

You will probably know that XYXY can be calculated as X times itself Y times.


# Get X and Y from the command line
import sys
X= int(sys.argv[1])
Y= int(sys.argv[2])

# Your code goes here

2. We will pass in 2 values, X and Y. You should calculate XYXY and output only the final result.

You will probably know that XYXY can be calculated as X times itself Y times.


# Get X and Y from the command line
import sys
X= int(sys.argv[1])
Y= int(sys.argv[2])

# Your code goes here

Explanation / Answer

Hi

myprogram.py

import sys
X=int(sys.argv[1])
Y=int(sys.argv[2])
print (X*Y*X*Y)

the command to run:

$ python myprogram.py 4 5

sample output:

400

we can save a python program in a file and we have to name it.copy the above program in a file and you can name it. naming format myprogram.py

now we have two pass our input directly from command line. Means we need to pass the arguments while we run the program itself

The format to pass command line inputs will be

$ python filename arg1 arg2 arg3

now we should pass X and Y so run the program like

$ python myprogram.py 4 5

now the output will get generated

Please comment on the question for any further queries your program is not specific

and both of them are equal

myprogram.py

import sys
X=int(sys.argv[1])
Y=int(sys.argv[2])
print (X*Y*X*Y)

the command to run:

$ python myprogram.py 4 5

sample output:

400