Question: Modify lab2f.py (attached pic) , add an IF statement to the script that checks to see if a argument was entered. If a argument was
- Modify lab2f.py (attached pic), add an IF statement to the script that checks to see if a argument was entered. If a argument was entered use that number for the timer, if no argument was entered, then by default, the timer should equal 3.
timer = int(sys.argv[1])
Remember to check the number of arguments in an IF statement using:
len(sys.argv)
Additional Input / Output / Processing Requirements
- The script should have a Shebang line
- The script should have a comment line which contains the word "Author:" and your full name
- The script should have another comment line which contains the word "Author ID:" and your seneca_id
- The script should have another comment line which contains the word "Date Created:" and the actual date in "yyyy/mm/dd" format
- The script should import sys
- The script should assign the value of 3 to an object named timer when there is no arguments provided.
- The script should assign the value of int(sys.argv[1]) if an object named timer when one command line argument (sys.argv[1]) are entered
- The script should have a WHILE loop that repeats until (and not including when) timer equals 0
- The script should print the EXACT OUTPUT as shown
Sample run 1:
./lab2g.py 5
5
4
3
2
1
blast off!
#! /usr/bin/env python3 #Author: Seneca Id 39103436 #Author ID: 39103436 # Date Created: 2020/09/21 import sys timer = int (sys.argv[1]) while timer > 0: print(timer) timer 1 print("blast off!")
Step by Step Solution
3.44 Rating (157 Votes )
There are 3 Steps involved in it
There are some syntax errors in your provided script Her... View full answer
Get step-by-step solutions from verified subject matter experts
