answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Gre4nikov [31]
2 years ago
4

Modify the scripts of Projects 1 and 2 to encrypt and decrypt entire files of text. An example of the program interface is shown

below: Enter the input file name: encrypted.txt Enter the output file name: a Enter the distance value: 3
Computers and Technology
1 answer:
STatiana [176]2 years ago
8 0

Answer:

The following are the program in the Python Programming Language.

#get input from the user

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

#get input from the user

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

#get input from the user

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

#open file for only read

infile = open(inputFile, "r")

#open file for only write

outfile = open(outputFile, "w")

#read lines from the file

get = infile.readlines()

#set the for loop

for text in get:

#set variable as empty string variable

code = ""

#then, set the for loop

for char in text:

#store the unicode of the variable

Value = ord(char)

 #perform calculation

cipher = Value + dist

#check that the calculation is greater than 127

      f(cipher > 127):

#then, again perform another calculation

cipher = dist - (127 - Value | 1)

#convert it into the character

code += chr (cipher)

#write the following converted character in it.

 outfile.write(code)

Explanation:

The following are the description of the program.

  • Firstly, set three variables 'inputfile', 'outputfile' and 'dist' that get input from the user, the first one gets the input file name, second one gets the output file name and the last one gets the distance.
  • Then, set two variables 'infile' and 'outfile' which open the 1st file for only read and second one open file for only write then, set the variable 'get' that read the line from the read-only file.
  • Set the for loop that stores that lines in the variable 'text' and then, set the empty string type variable 'code'. Set the for loop that store the variable of the 'text' in the 'char' then, set the variable 'Value' that store the Unicode of the variable 'char' and perform calculation between the variables 'Value' and 'char' and store it in the variable 'cipher'.
  • Then, set the if conditional statement that checks the variable 'cipher' is greater than 127 and perform the another calculation, then convert the variable 'cipher' into the character and store it in the variable 'code'.
  • Finally, we close all the following open files.
You might be interested in
n the video, McWhorter says that “textspeak” might be a good thing for young people’s brains. Why does he think this?
ANEK [815]

As you may know people learn in different ways. Some learn by audio, hands on, and simply just reading. When he says textspeak it more than likely means the text will be read to you in a way you would understand better.

3 0
2 years ago
Without using any additional variables, and without changing the values of ndays or the elements of the parkingTickets array, wr
dusya [7]

Answer:

Explanation:

mostTickets=0;

for (k=0; k< ndays; k++){

if (parkingTickets[k]>mostTickets) mostTickets=parkingTickets[k];

}

7 0
2 years ago
Which of the following is NOT a method in which a macro can be run?
liubo4ka [24]
C....................
7 0
2 years ago
1. PLCs were originally designed as replacements for: a) microcomputers. c) analog controllers. b) relay control panels. d) digi
timama [110]

Answer:

PLCs (Programmable logic controller) were original designed as replacement for relay control panels.  Relay is another word for a switch. Relay control panels were made for the control of electronic instrumentents or devices. Later on PLCs were made to replace these timers and relay control panels. PLCs are more reliable, flexible and can work better in the harsh environmental situations then the relay control panels.

3 0
2 years ago
RADIAC instruments that operate on the ionization principle are broken down into three main categories based on what?
mash [69]

Answer:

Electrical potential.

Explanation:

RADIAC Meter or instruments ( also known as radiation monitoring instruments) are measuring instruments that uses the principles of gaseous ionisation to conduct electricity flow internally to deflect the pointer for its Meter readings. These instruments can be analogue or digital.

They are used in industries to monitor the operation of certain equipments and processes. The level of electrical potential flow in the system determines the state or category of the instrument. Out of six, there are three main categories of electrical potential level.

6 0
2 years ago
Other questions:
  • Which process is used to protect transmitted data in a vpn?
    12·1 answer
  • Nick won a $1,000 lottery prize. He can't decide what he should spend the money on. For some time now, he has been planning to b
    5·1 answer
  • Richard uses Microsoft outlook as his email client. He wants to check whether he has received any new mail. Identify which key R
    12·1 answer
  • If a street has a central lane bordered by solid yellow and broken yellow lines, you ________________.
    6·1 answer
  • Peter accumulated many photos from his visit to Wisconsin. He wants to upload these photos to a social networking site. Which fi
    12·1 answer
  • Prompt: Which references and reference formats are you most likely to use? Why?<br><br><br> ED2020
    13·2 answers
  • Which of the following is not true of how computers represent complex information
    5·2 answers
  • Explain the emerging trends in microcomputer technology in relation to size​
    11·1 answer
  • A record company is using blockchain to manage the ownership of their copyrighted content. The company requires that every time
    9·1 answer
  • Even though Wordpress is basically free, what is the company trying to accomplish?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!