Exercise 6#
Question 1#
Code up a “guess the number game”. Pick a number between 0 and 99 (as the developer) and then prompt the user to guess the number. If the user’s guess is too low. print the message “Sorry, that is too low.”. If they guess too high, print “Oops, you are too high!”. When they guess the correct number say “Well done! You got it!”. If they enter a number that is not between 0 and 99, print a message saying “Oops, invalid entry. Try again!”.
Question 2#
Write some code that takes a character (i.e. a string of length 1) and prints a message informing the user if it is a vowel or not. Make sure to check that the input is indeed one character long.
Question 3#
Write some code that prompts the user to enter 3 numbers, and then prints them to screen in ascending order. What if a number is repeated? E.g. 6, 2, 6.
Question 4#
Write some code that will prompt a user to enter the coefficients \(a\), \(b\) and \(c\) for a second-order polynomial (\(ax^2 + bx + c\)) and then print the roots to the screen. Test your code for \((a,b,c) = (3, 6, 2)\), which has roots \(-0.42\) and \(-1.57\).
Only find real roots, you will need to implement a check for this.
Question 5#
The third person singular verb form in English is distinguished by the suffix -s, which is added to the stem of the infinitive form: run \(\rightarrow\) runs. A simple set of rules can be given as follows:
If the verb ends in “y”, remove it and add “ies”
If the verb ends in “o”, “ch”, “s”, “sh”, “x” or “z”, add “es”
By default just add “s”
Your task in this exercise is to write some code which given a verb in infinitive form returns its third person singular form. Test your function with words like: try, brush, run and fix.