Strings and Loops

In this lab, you will learn a bit more about loops and strings. Read over Chapter 7. Answer the questions below in one big file that your TA Marc can run as a Python script/program by using the Python launcher. Name the file yourlastnameString.py. Email your completed assignment (i.e., attach your script file) from your preferred class email address to marctomlinson@mail.utexas.edu.

1. Instead of each question running sequentially in your script as you have done with past assignments, write a function using the if and while statement that allows Marc decide which question he wants to run. Make each question below a separate function. After a question's function completes, return to the main menu so Marc can decide which other question's function he wants to run. Present Marc with an option of quitting the program.

2. Write a function containing a while loop that asks the user to type in an integer and counts from 1 to that number printing out all numbers from 1 up to and including the number the user enters.

3. Write a function containing a for loop that asks the user to type in some string and prints out how many vowels are in the string.

4. Write a function that asks the user to type in a string and prints it backwards.

5. Write a function that asks the user to type in a string and prints every other letter starting with the first letter.

6. Write a function that asks the user to type in a string and prints out a single string consisting of the first two and last two letters. If the user enters a string that contains less than four characters, have them enter a new string.