What will happen when you run the following program:
import sys
try:
t = sys.arg[1]
a = sys.arg[2]
except:
print ‘You must provide TWO
command-line arguments!!!’
sys.exit(1)
s = 0.5*a*t**2
print s
Answers
Answered by
1
Output : You must provide TWO command-line arguments!!!
Program :
import sys
try:
t = sys.arg[1]
a = sys.arg[2]
except:
print("you must provide TWO command-line arguments!!!")
sys.exit(1)
s = 0.5*a*t**2
print(s)
Output :
You must provide TWO command-line arguments!!!
Reason :
- The library sys doesn't have a function arg[].
- Instead, it has argv[] to take command line arguments.
- So, the exception raises and print statement in the except block will be printed, program execution stops as soon as it encounters exit().
Learn more :
- When will the else part get executed?
https://brainly.in/question/10007112
- Sailent features of python.
https://brainly.in/question/12206981
Hope it helps you! Thank you!
Attachments:
Similar questions