Create a week06 subdirectory in your cs21/class directory, and copy over my week06 files into this new directory:
$ cd $ cd cs21/class $ pwd /home/your_user_name/cs21/class $ mkdir week06 $ cd week06 $ pwd /home/your_user_name/cs21/class/week06 $ cp ~newhall/public/cs21/week06/* . $ ls fivequestions.py randOps.py stringOps.py listOps.py squareevens.py syracuse.pyAfter we do in-class work together, you can copy over my in-class solutions into your cs21/class/week06 directory by doing the following (my solutions will be in files named with the in-class file name prefixed with "tias_"):
$ cd $ cd cs21/class/week06 $ cp ~newhall/public/cs21/week06/tia* .It is good to wait a couple hours after class to do this because I occationally add additional comments to these files for you.
Once we get that to work, lets see what happens if the user enters a negative value.
To kill a program with an infinite loop, hold down the CNTRL and the c keys (CNTL-C).
Now, lets write a function GetPositiveInt, that prompts the user to enter a positive int value and returns it to the caller. The function will keep prompting the user to enter a vaild value until s/he enters a positive value, only then will the function return the value to the caller. We will test this function by replacing the call to input in main with a call to the GetPositiveInt function.
strings and lists as objects
Some practice with functions with list and object parameters:
the random library
Next, let's change the main function to make a call to our new function to create the list, main should print the list out, call squareEvens, and then print out the list again.