Note: Homework assignments should be completed in identified pairs (not more than two students), but may be done individually as well. As a pair, you should submit your assignments separately, but you will receive the same grade as your partner.
In this assignment, you will write a python program that manipulates a user-entered string. The user interface should first ask the user to input a sentence. For example:
Enter a sentence: I <3 Smith college!
Your program will then output the following:
0. I <3 Smith college!
1a. I <3 SMITH COLLEGE!
1b. i <3 smith college!
2. I <3 Smiith coolleegee!
3. I <3 ...lege!
4. I <3 Smith College!
5. !egelloc htimS 3< I
6. | I <3 Smith college! |
The submission:
hmwk3.py
and runs without syntax errorsThe program uses some combination of string methods, indexing, splitting, and concatenation to perform print each of the following modifications of the input (1 point each):
|
, where the total distance inbetween (and not including) the verticle bars is double the length of the sentence.Help with 6.: To include a variable name for the length as a parameter in the .format function, you need to put the variable index inside { }
braces. For example:
>>> my_len = 10
>>> print("|{0:{1}}|".format("test", my_len))
|test |
Note: If there is a line you can’t figure out, simply print the number and leave the line blank, e.g.
0. I <3 Smith college!
1a. I <3 SMITH COLLEGE!
1b. i <3 smith college!
2. I <3 Smiith coolleegee!
3.
4. I <3 Smith College!
5.
6.
Your submission must include the course header at the top.
# ------------------------------------------------------
# Name:
# Section: L01, L02, L03, or L04
# Filename: hmwk3.py
# Peers: N/A
# References:
# ------------------------------------------------------
Last Submission February 18, 2020 at 10:00PM (EST). Go to our Moodle page. Submit your hmwk3.py
file and fill out your self-assessment.