CSC 241 Lab 7



Submission:  Submit the python or text file that contains all your answers to the submission folder for this lab by the end of the lab. To simplify Drew's (our tutor) work, please include your name and the number of the lab at the top of the file (if you're submitting a Python file, use comments: start the line with a #).

Grading: see the grading criteria for lab assignments.


 1. (Exceptions I) Write short code snippets (each of these can be done in a single line, you don't need to write a function/program) causing each of the following exceptions (use Section 5.2 in Built-in Exceptions to do research on these if you need to):

2. (Exceptions II) Write a function age() which prompts the user to input their age, and then tells them how old they'll be next year. If the user enters anything that doesn't convert to an integer (via the int() function), or the user interrupts the input (via ctrl+c), the program should print a message saying so. Use appropriate exceptions for this:

You will need two except clauses.

3. (Repeated Words) A common mistake in writing is repeating a word word by accident. Write a function dblword(text) which reports any double words in the text text (a string, you can assume that there is no punctuation). Output should be as follows:


4. (Anti-diagonal) Write a function fslash(n) that prints a forward slash as part of an nxn display (in class we did the backslash).



Marcus Schaefer
Last updated: May 13th, 2019.