March 8th, 2013, 04:52 PM
Python encription (college intro assignment)
Any help or tips will be appreciated! Thanks!
Please answer in version 3.3!
You will write a Python module which will do a simple scrambling of a string. The module asks two questions to the user:
- the string to be scambled (call it A in the module)
- a scrambling key, N (that should be smaller than half the length of the string)
The module will read the string, then:
Check if N is larger than half the length of the string. If N is larger, enter a while loop that asks the user to enter in a new value for N with the following phrase written to the terminal "Scrambling key too long, enter a smaller value:". Keep iterating this loop while N remains greater than half the length of the string. (In other words: If N is larger you may want to use a statement such as: "while" N is longer than half the string length ask the user to enter a new value for N, and keep repeating until the condition is no longer satistfied. And don't forget about SYNTAX for loops and conditional statements.)
reverse its N first characters
reverse its N last characters
in that order, and print the resulting string.
Examples of output after steps 2 and 3:
The string "This is a test" with the key 4 will be scrambled to "sihT is a tset"
The string "Another example" with the key 2 will be scrambled to "nAother exampel"
March 8th, 2013, 05:08 PM
You already have some hint in the assignment: "while" and SYNTAX for loops and conditional statements
The first think you could/should do is to look up how Control Flow works.
You should also take a look at the sticky posts at top of of the forum.
March 8th, 2013, 11:02 PM
Here's a big chunk of the solution but I had to scramble it.
[/code] are essential for python code and Makefiles!