Ask Your Question

Revision history [back]

Write a script that takes two arguments the first being either pi/e and the second being an integer between 1 and 200.

If the first argument is x and second argument is n then your script is expected to display the nth digit of x after the decimal point. The script should display a message if n is outside the range and exit elegantly. If the number of arguments is less than 2, then too the script should display an appropriate message and exit properly. trying in sage math jupyter notebook

import sys if len(sys.argv) < 3: print("Usage: python assn2a.py {pi/e} n") sys.exit(1)

x = sys.argv[1] n = int(sys.argv[2])

if n < 1 or n > 200: print("n should be an integer between 1 and 200.") sys.exit(1)

if x == "pi": value = str(pi) elif x == "e": value = str(e) else: print("Invalid value for x. Please choose 'pi' or 'e'.") sys.exit(1)

digit = value.split(".")[1][n-1]

print(digit)

Write a script that takes two arguments the first being either pi/e and the second being an integer between 1 and 200.

If the first argument is x and second argument is n then your script is expected to display the nth digit of x after the decimal point. The script should display a message if n is outside the range and exit elegantly. If the number of arguments is less than 2, then too the script should display an appropriate message and exit properly. trying in sage math jupyter notebook

import sys
if len(sys.argv) < 3:
    print("Usage: python assn2a.py {pi/e} n")
    sys.exit(1)

sys.exit(1) x = sys.argv[1] n = int(sys.argv[2])

int(sys.argv[2]) if n < 1 or n > 200: print("n should be an integer between 1 and 200.") sys.exit(1)

sys.exit(1) if x == "pi": value = str(pi) elif x == "e": value = str(e) else: print("Invalid value for x. Please choose 'pi' or 'e'.") sys.exit(1)

sys.exit(1) digit = value.split(".")[1][n-1]

print(digit)

value.split(".")[1][n-1] print(digit)

Write a script that takes two arguments the first being either pi/e and the second being an integer between 1 and 200.

If the first argument is x and second argument is n then your script is expected to display the nth digit of x after the decimal point. The script should display a message if n is outside the range and exit elegantly. If the number of arguments is less than 2, then too the script should display an appropriate message and exit properly. trying in sage math jupyter notebook

import sys
if len(sys.argv) < 3:
    print("Usage: python assn2a.py {pi/e} n")
    sys.exit(1)

x = sys.argv[1]
n = int(sys.argv[2])

if n < 1 or n > 200:
    print("n should be an integer between 1 and 200.")
    sys.exit(1)

if x == "pi":
    value = str(pi)
elif x == "e":
    value = str(e)
else:
    print("Invalid value for x. Please choose 'pi' or 'e'.")
    sys.exit(1)

digit = value.split(".")[1][n-1]

print(digit)

Help writing a script

Write a script that takes two arguments the first being either pi/e and the second being an integer between 1 and 200.

200. If the first argument is x and second argument is n then your script is expected to display the nth digit of x after the decimal point. The script should display a message if n is outside the range and exit elegantly. If the number of arguments is less than 2, then too the script should display an appropriate message and exit properly. trying properly.

Trying in sage math jupyter SageMath Jupyter notebook

import sys
if len(sys.argv) < 3:
    print("Usage: python assn2a.py {pi/e} n")
    sys.exit(1)

x = sys.argv[1]
n = int(sys.argv[2])

if n < 1 or n > 200:
    print("n should be an integer between 1 and 200.")
    sys.exit(1)

if x == "pi":
    value = str(pi)
elif x == "e":
    value = str(e)
else:
    print("Invalid value for x. Please choose 'pi' or 'e'.")
    sys.exit(1)

digit = value.split(".")[1][n-1]

print(digit)