$30
Task 1 [Simple exponent]:
- Prompt the user for input in the following form: "x^y", where x and y are a single digit number, for example 2^8 or 4^2 would be valid inputs.
- Next, output the string "x^y is XXX", where x and y are replaced with the input values and XXX is the result of raising x to the y power, e.g., xy.
Note that this syntax "x^y" is how some other programming languages perform exponent. Recall, Python uses the ** operator for exponent. Your prompt and output should look like that shown on page 3 of this document. You may assume that the input is correct. That is, you do not need to include any code to check to see if the second character is a "^". We haven't learned how to do that yet. Also, see accompanying video linked above.
See next page for Tasks 2-4
Task 2 [Converting a sentence first half to uppercase and second have to lowercase]
- Prompt the user to input a long sentence (you may assume the user types at least 3 or more characters).
- Remove any spaces that appear before or after the string.
- Print out the length of the string and the middle character as shown on page 3. Note: you should use integer divide to compute the middle character index.
- Finally, print out the string with the first half (up to, but not including the middle character) are all uppercase m, followed by a vertical bar symbol "|", followed by second half of the sentence (from the middle character to the last character) all in lowercase.
Your output should look like those shown on page 3 of the lab document. Also see accompanying video.
Task 3 [Remove commas, periods, and convert all spaces to * and all letters to lowercase] - Prompt the user to input a long sentence.
- You should remove any spaces that appear before or after the string.
- Remove all commas and periods from the input.
- Replace all the spaces (" ") in the string with an asterisks *.
- All letters should also be converted to lowercase.
- Printout this processed string.
Your output should look like that shown on page 3 of the lab document. Also see accompanying video.
Note you do not have to perform the operations in the order specified above. Just as long as your output is the same as the required output.
Task 4 [Highlighting a substring]
- Prompt the user to input a sentence.
- Prompt the user to input a substring (i.e., a smaller sequence of characters that is part of the first sentence). You may assume this is a valid substring.
Output the original string, but where the substring first occurs should be modified to be in all uppercase and be surrounded by asterisks *. See page 3 for an example