1
I am a beginner in Python and am facing the following problem to pass an argument via Python command line.
from math import pi
import sys
def circulo(r):
return pi * float(r) ** 2
if __name__ == '__main__':
r = sys.argv[1]
area = circulo(r)
print('Area do circulo ', area)
I’m having the following exit at the terminal:
you have to put in place of 1 the value 0, since the first index is 0
– Wictor Chaves
I ran your code on my machine and had no problems. You are calling the file
python
by name alone? For right is right:$ python nome_arquivo.py args
.– user89389