In this exercise we work mainly with if-elif-else statements and while loops, but also learn a little bit about some functions which can operate on strings. You should read Dawson's Chapter 3. The source code for the programs he goes through can be found here.
Exercise 1: Write a program that asks for the first and last names of a person. Something like this.
Please enter your first name: Please enter your second name:
You are called Miriam Butt. Your first name consists of 6 letters. Your last name consists of 4 letters. Taken togehter, your name consits of 10 letters. The "smallest" letter in your first name is 'a'. The "largest" letter in your last name is 'u'.
Exercise 2: Write a program which simulates the throwing of two dice. Inform the user which dice won, i.e., had the higher number.
Exercise 3: Write a program that asks the user for a number and then produces exactly as many random numbers as specified by the user. You should use a while loop to do this.
Exercise 4: Go through Dawson's Losing Battle program. Modify the final version (the one without the infinite loop) so that it includes several different possible scenarios. I.e., the scenario does not always involve a troll thumping our hero. Ogres could come out in addition, as could good witches with healing potions to restore our hero's health. Bring your program (or your ideas) to class, where we will discuss them.
Please hand in the programs for the exercises to aikaterini-lida at uni konstanz by Friday the 14th of November by 11 am.