13,420
edits
Changes
→PART 2 - Using WHILE Loops with Arguments
:::3. Before proceeding, make certain that you identify any and all errors in '''lab2e.py'''. When the check script tells you everything is '''OK''', you may proceed to the next step.
== PART 2 - Understanding WHILE Loops with Arguments == You will now learn to make your Python scripts more flexible by using numbers as arguments to be used with WHILE loops. You will learn that arguments used in Python scripts are simply strings and therefore, cannot be used in Mathematical operations unless they are converted into numbers (like an integer). You will be learning how to use the int() function in order to convert a string into an integer. '''Perform the Following Steps:'''
:#Now lets make the same script more intelligent. Make a copy of '''lab2e.py''' and call it '''lab2f.py'''. Now modify '''lab2f.py''', modify the value of timer to user the first argument provided to the script. This will allow the argument to choose how long the timer is.
:::'''WARNING: When using arguments as numbers/integers or performing math on arguments you must wrap them in the int() function, for example: number = int(sys.argv[1])'''