Menu
info@onlinenursinghomework.com
Cell: +1 (985) 805-5163

I have to write a pep8 program with these requirements. But whenever I try programing it I keep getting an error. Background:

I have to write a pep8 program with these requirements. But whenever I try programing it I keep getting an error. Can u please tell me how to code this assignment.

Background:  There are two primary methods for how strings are stored.

Don't use plagiarized sources. Get Your Custom Essay on
I have to write a pep8 program with these requirements. But whenever I try programing it I keep getting an error. Background:
Just from $9/Page or 300 words
Order Now

The C programming language is an example of one where strings are stored  as an array of characters in memory (for our purposes here, each character is a single byte using the ASCII character set) terminated with a “null character” – a byte with the value 0.  Thus, strings don’t have a pre-defined length and if you want to know how long a string is, you have to go and count the characters.  Also, you always have to remember to declare your array 1 character longer than the actual characters.  E.g. to store the word “hello” you would actually have to declare an array with 6 characters, so there is room for the “null” character at the end.  Forgetting to allocate space for the null character is a common mistake in C programs.  The benefit of this method is that the length of strings are not really limited in any way – they just keep going until you get to the “null” character.

The Java programming language is an example of one where strings are stored as an array of characters in memory, but the length of the string is also stored along with it using one of the integer data types supported by the language.  Java uses an “int”, which is a 32-bit integer, meaning that strings can be up to 2 billion characters in length (32-bits can actually be used to represent 4 billion things, but since Java doesn’t have “unsigned” primitve data types, and the length of a string has to be positive, it only uses the positive numbers).  This means that the length of a string can be known by accessing the length value in memory (saves a lot of processing on long strings) and there is less chance of errors caused by forgetting about the “null” character.  The trade-off is that there is extra processing required to maintain the length value in memory and that every string uses extra memory for the length value (4 bytes in Java, 2 bytes for the PEP8)

Assignment:

  1. Reserve memory for 3 C-style strings – 2 of them should be up to 10 characters in length and the 3rd should have enough room to combine the two short ones together.You can pre-load 2 strings of appropriate length into the first two, e.g. “Hello, ” and “World!” and don’t forget the null characters.The memory reserved for the combined strings should be initialized to all hex FF values, so that it will be easy to see if the result gets created correctly.
  2. Reserve memory for 3 Java-style strings – 2 of them should be up to 10 characters in length and the 3rd should have enough room to combine the two short ones together.You can pre-load 2 strings of appropriate length into the first two, e.g. “South ” and “Forsyth!” and don’t forget to set the length values correctly.If you set aside the maximum 10 bytes of space, any unused bytes should be initilized to hex FF.The memory reserved for the combined strings should be initlialized to length 0 and all the bytes should be hex FF.
  3. Write a looping algorithm that combines the two C-style strings together into the space reserved for the 3rd C-style string.
  4. Write a looping algorithm that combines the two Java-style strings together into the space reserved for the 3rd Java-style string.
  5. Use a looping algorithm to output the lines (your lines will be different if you choose different strings):13 Hello, World!14 South Forsyth!where the digits are the length of the combined string, followed by a space, followed by the combined string, followed by a newline character.

Looking for a similar assignment? Get help from our nursing qualified experts!

Order Now

Open chat
Get help
You can now contact our live agent via whatsapp! ping +1 ( 681) 249-1107.
You will get plagiarism free custom written paper