Changes

Jump to: navigation, search

OPS435 Python Lab 2

48 bytes added, 11:43, 26 May 2017
PART 3 - Using WHILE Loops With IF Statements
:#Modify '''lab2g.py''', add a 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.
<blockquote style="margin-left:35px;">{{Admon/important|style="padding-left:25px"|ADDITIONAL WARNINGS|When using arguments as numbers/integers or performing math on arguments you must wrap them in the '''int()''' function:<br><source>count timer = int(sys.argv[1])</source>Remember to check the number of arguments in an IF statement using:<source>len(sys.argv)</source>}}</blockquote>
:::'''Additional Input / Output / Processing Requirements'''
:::*The script should have a '''Shebang line''':::*The script should '''import sys''':::*The script should use a variable named '''timer ''' with the value of '''3 ''' if '''no arguments ''' are entered :::*The script should use a variable named timer with the value of '''int(sys.argv[1]) ''' if '''arguments ''' are entered :::*The script should have a while WHILE loop that repeats until timer equals 0
:::*The script should print the EXACT OUTPUT as shown
</source>
:::'''Sample run 3:'''<source>
run lab2g.py
3
13,420
edits

Navigation menu