Question: Note: Paste these codes of 10 projects on replit and give the 10 screenshots. File: encrypt Project -1 Encypts an input string of the

Note: Paste these codes of 10 projects on replit and give the 10 screenshots.

"""

File: encrypt

Project -1

Encypts an input string of the ASCII characters and prints

the result. The other input is the distance value.

"""

# The ASCII values range from 0 through 127

plainText = input("Enter a message: ")

distance = int(input("Enter the distance value: "))

code = ""

for ch in plainText:

ordValue = ord(ch)

cipherValue = ordValue + distance

if cipherValue > 127:

cipherValue = distance - (127 - ordValue + 1)

code += chr(cipherValue)

print(code)

***************************************************************************

""

File: decrypt

Project -2

Decypts an input string characters and prints

the result. The other input is the distance value.

"""

# The ASCII values range from 0 through 127

code = input("Enter the coded text: ")

distance = int(input("Enter the distance value: "))

plainText = ''

for ch in code:

ordValue = ord(ch)

cipherValue = ordValue - distance

if cipherValue < 0:

cipherValue = 127 - \

(distance - (1 - ordValue))

plainText += chr(cipherValue)

print(plainText)

******************************************************************************

"""

File: decimaltooctal

Project -3

Converts a decimal integer to a string of octal digits.

"""

decimal = int(input("Enter a decimal integer: "))

if decimal == 0:

print(0)

else:

print("Quotient Remainder Octal")

ostring = ""

while decimal > 0:

remainder = decimal % 8

decimal = decimal // 8

ostring = str(remainder) + ostring

print("%5d%8d%12s" % (decimal, remainder, ostring))

print("The octal representation is", ostring)

****************************************************************************

"""

File: octaltodecimal

Project -4

Converts a string of octal digits to a decimal integer.

"""

ostring = input("Enter a string of octal digits: ")

decimal = 0

exponent = len(ostring) - 1

for digit in ostring:

decimal = decimal + int(digit) * 8 ** exponent

exponent = exponent - 1

print("The integer value is", decimal)

*********************************************************************************

"""

File: shiftleft

Project -5

Shifts the bits in an input string one place to the left.

The leftmost bit wraps around to the rightmost position.

"""

bits = input("Enter a string of bits: ")

if len(bits) > 1:

bits = bits[1:] + bits[0]

print(bits)

********************************************************************************

"""

File: shiftright.py

Project -5

Shifts the bits in an input string one place to the right.

The rightmost bit wraps around to the leftmost position.

"""

bits = input("Enter a string of bits: ")

if len(bits) > 1:

bits = bits[-1] + bits[:-1]

print(bits)

********************************************************************************

"""

File: copyfile.py

Project -6

Copies the text from a given input file to a given

output file.

"""

# Take the inputs

inName = input("Enter the input file name: ")

outName = input("Enter the output file name: ")

# Open the input file and read the text

inputFile = open(inName, 'r')

text = inputFile.read()

# Open the output file and write the text

outFile = open(outName, 'w')

outFile.write(text)

outFile.close()

***********************************************************************************

"""

File: numberlines.py

Project -7

Copies the text from a given input file to a given

output file, numbering them as it goes.

"""

# Take the inputs

inName = input("Enter the input file name: ")

outName = input("Enter the output file name: ")

# Open the files

inputFile = open(inName, 'r')

outputFile = open(outName, 'w')

# Output the numbered lines

lineNumber = 0

for line in inputFile:

lineNumber += 1

outputFile.write("%4d> %s" % (lineNumber, line))

outputFile.close()

***************************************************************************

"""

File: dif

Project -8

Deterines whether or not the contents of two text

files are the same. Outputs "Yes" if that is the

case or "No" and the first two lines that differ if

that is not the case.

"""

# Take the inputs

fileName1 = input("Enter the first file name: ")

fileName2 = input("Enter the second file name: ")

# Open the input files

inputFile1 = open(fileName1, 'r')

inputFile2 = open(fileName2, 'r')

# Read each pair of lines and compare them

while True:

line1 = inputFile1.readline()

line2 = inputFile2.readline()

if line1 == "" and line2 == "": # Ends of both files

print("Yes")

break

elif line1 != line2:

print("No")

print(line1)

print(line2)

break

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!