CSC111 Exercises on Loops
Loop Exercises
- Exercise 1
- Write a function that asks the user to enter a number that is greater than 0. The function will keep on asking the user for a number until the number is correct. The function will return the number.
- Exercise 2
- Write a function that asks the user to respond by 'Y', 'y', 'yes', 'YES' or 'N', 'n', 'no', 'NO'. The function keeps on asking until the user enters the correct information. The function will return True if the user entered Yes, and False otherwise.
- Exercise 3
- Write a function that reads lines from the file until it finds a line that contains a particular string. The function receives the name of the file, and the string.
- Exercise 4
- Pi can be computed by adding the following terms: