Coding Assignment 1: Solving problems

Coding Assignment 1: Solving problems

All this should be done with Visual Studio Code(python).

Question 1:

Assume s is a string.

Write a program that separates a long string (at least length of 16) that contains both numbers and letters (upper and lower case) into two substrings of numbers and letters. And then convert the even numbers in the ‘number substring’ and upper-case letter in the ‘letter string’ into ASCII Code Decimal Values.

Example Scenario:

String = \’56aAww1984sktr235270aYmn145ss785fsq31D0\’

Separate them – 56198235270145785310 (number string) and aAwwsktraYmnssfsqD (letterstring).

Convert the even numbers in the number string to ASCII Code Decimal Values.

6, 8, 2, 2, 0, 4, 8, 0 (Even Numbers)

54, 56, 50, 50, 48, 52, 56, 48 (ASCII CODE)

Convert the upper-case letter in letter string to ASCII Code Decimal Values.

A, Y, D (Upper-case Letters)

65, 89, 68 (ASCII CODE Decimal Values)

Question 2:

The cryptogram below is a quote from a famous author or celebrity.

VZ FRYSVFU VZCNGVRAG NAQ N YVGGYR VAFRPHER V ZNXR ZVFGNXRF V NZ BHG BS PBAGEBY NAQ NG GVZRF UNEQ GB UNAQYR OHG VS LBH PNAG UNAQYR ZR NG ZL JBEFG GURA LBH FHER NF URYY QBAG QRFREIR ZR NG ZL ORFG ZNEVYLA ZBAEBR

To get the original quote, you should replace each character in the ciphered quote using a shift key value (s) condition.

Example 1: If the ciphered quote is AB, and ‘s’ is 1, then the original quote is ZA

Example 2: If the ciphered quote is AB, and ‘s’ is 2, then the original quote is YZ

Decrypting the provided cryptogram using a ‘certain’ shift key value (s) gives an original quote. Print all the decrypted messages for shift key values in the range of (1, 26) in the console.

Check the outputs visually and see what the shift key value (s) is to get the original quote. Print
shift key value along with the original quote.

The following is the marking rubric:

  1. The code should be simple, clear, easy to understand, and readable for the reader. The need for comments and improper white spaces should be minimal.
  2. The code should be efficient & redundant (not too long). Refactored code should be present. Namespaces should be used. The programs should have continuous flow (Quality Coding). Perfect loops should be used.
  3. Errors should never pass silently unless explicitly silenced (mainly syntax errors). The code is well tested for errors
  4. The output is achieved. Even if the output is not reached, you could be marked based on the logic used in writing the code.
  5. Mostly used the concepts taught in the class. And demonstrated evidence of additional effort and learning above and beyond the requirements that add value to the outcome of the task

Leave a Reply