CIS 41A Unit B, Problem B

This assignment consists of two separate scripts.

At the top of each of your scripts, put the following multi-line comment with your information:

'''
Your name as registered, with optional nickname in parentheses
CIS 41A   Fall 2021
Unit B, Problem B
'''

First Script - Working with Strings

This script contains four parts.

1) String Type Tests

  1. Ask the user for a string (test with "ABC123").
  2. Use method isupper to test the string, print the result.
  3. Use method isdigit to test the string, print the result.
  4. Use method isalpha to test the string, print the result.

2) Escape Characters within a string

Use newline escape characters within a line of haiku

  1. Assign the text "Type, type, type away. Compile. Run. Hip hip hooray! No error today!" to a single variable (be sure to add newline escape characters). This should be done in a single line of code.
  2. Print, so that the output appears as follows:
    Type, type, type away.
    Compile. Run. Hip hip hooray!
    No error today!
          
    Haiku by Samantha W.

3) Slicing a string

  1. Assign the text "And now for something completely different" to a variable called quote.
  2. Slice quote to obtain the text "And no" from the beginning of the quote, print the results.
  3. Slice quote to obtain the text "rent" from the end of the quote, print the results.
  4. Slice quote to obtain the text "me" from the middle of the quote, print the results.
  5. Slice quote to obtain the text "Adnwf..." by extracting every other letter, print the results.
  6. Slice quote to obtain the text "tnere..." by reversing the quote, print the results.

4) Using string operators + and *

  1. Assign the text ".~*'" to a variable called pattern1.
  2. Create a variable called pattern2, assign to it pattern1 combined with pattern1 reversed. pattern2 should now contain the string ".~*''*~."
  3. Print pattern2 repeated five times. The output should appear as follows:
    .~*''*~..~*''*~..~*''*~..~*''*~..~*''*~.
          

Second Script:

Printing a well formatted invoice

Use three named "constants" for the following prices:
Small beads have a price of 10.20 dollars per box.
Medium beads have a price of 8.52 dollars per box.
Large beads have a price of 7.98 dollars per box.

Ask the user how many boxes of small beads, how many boxes of medium beads, and how many large beads they need (use the int Built-in Function to convert these values to int).

Print the invoice in the following format:

SIZE      QTY    COST PER BOX      TOTALS
Small       n            x.xx       xx.xx
Medium      n            x.xx       xx.xx
Large       n            x.xx       xx.xx
TOTAL                              xxx.xx

Replace the n and x placeholders with actual numeric data values. Right align all numeric values. All dollar amounts should have two decimal places and should align on the decimal point.

Test your script twice, first with user input of 10 boxes of small beads, 9 boxes of medium beads, and 8 boxes of large beads, and then a second time with user input of 5 boxes of small beads, 10 boxes of medium beads, and 15 boxes of large beads.

Add the following at the end of the script to show your results:

'''
Execution results:
paste execution results here
'''

Submit both your finished py scripts in Canvas, Problem B.