Menu

[Solved]-Use Python Need Execution Output First Script Working Strings Script Contains Four Parts S Q37168635

Use Python and need execution output

First Script – Working with Strings

This script contains four parts.

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.

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 hiphooray! No error today!” to a single variable (be sure to addnewline escape characters). This should be done in a single line ofcode.
  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.

Slicing a string

  1. Assign the text “And now for something completely different” toa variable called quote.
  2. Slice quote to obtain the text “And no” from the beginning ofthe quote, print the results.
  3. Slice quote to obtain the text “rent” from the end of thequote, print the results.
  4. Slice quote to obtain the text “me” from the middle of thequote, print the results.
  5. Slice quote to obtain the text “Adnwf…” by extracting everyother letter, print the results.
  6. Slice quote to obtain the text “tnere…” by reversing thequote, print the results.

Using string operators + and *

  1. Assign the text “.~*'” to a variable called pattern1.
  2. Create a variable called pattern2, assign to it pattern1combined with pattern1 reversed. pattern2 should now contain thestring “.~*”*~.”
  3. Print pattern2 repeated five times. The output should appear asfollows:.~*”*~..~*”*~..~*”*~..~*”*~..~*”*~.

    Second Script:

    Printing a well formatted invoice

    Use three named “constants” for the following:
    small beads with a price of 9.20 dollars per box
    medium beads with a price of 8.52 dollars per box
    large beads with a price of 7.98 dollars per box

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

    Print the invoice in the following format:

    SIZE QTY COST PER BOX TOTALSSmall n x.xx xx.xxMedium n x.xx xx.xxLarge n x.xx xx.xxTOTAL xxx.xx

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

    Test your script twice, first with user input of 10 boxes ofsmall 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 each script to show yourresults

Expert Answer


Answer to Use Python and need execution output First Script – Working with Strings This script contains four parts. String Type Te… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *