1answer.
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
lys-0071 [83]
3 years ago
11

Implement function easyCrypto() that takes as input a string and prints its encryption

Computers and Technology
1 answer:
jasenka [17]3 years ago
4 0

Answer:

The program written in python is as follows;

import string

def easyCrypto(inputstring):

      for i in range(len(inputstring)):

             try:

                    ind = string.ascii_lowercase.index(inputstring[i])

                    pos = ind+1

                    if pos%2 == 0:

                           print(string.ascii_lowercase[ind-1],end="")

                    else:

                           print(string.ascii_lowercase[ind+1],end="")

             except:

                    ind = string.ascii_uppercase.index(inputstring[i])

                    pos = ind+1

                    if pos%2 == 0:

                           print(string.ascii_uppercase[ind-1],end="")

                    else:

                           print(string.ascii_uppercase[ind+1],end="")

anystring = input("Enter a string: ")

easyCrypto(anystring)

Explanation:

The first line imports the string module into the program

import string

The functipn easyCrypto() starts here

def easyCrypto(inputstring):

This line iterates through each character in the input string

      for i in range(len(inputstring)):

The try except handles the error in the program

             try:

This line gets the index of the current character (lower case)

                    ind = string.ascii_lowercase.index(inputstring[i])

This line adds 1 to the index

                    pos = ind+1

This line checks if the character is at even position

                    if pos%2 == 0:

If yes, it returns the alphabet before it

                           print(string.ascii_lowercase[ind-1],end="")

                    else:

It returns the alphabet after it, if otherwise

                           print(string.ascii_lowercase[ind+1],end="")

The except block does the same thing as the try block, but it handles uppercase letters

<em>              except: </em>

<em>                     ind = string.ascii_uppercase.index(inputstring[i]) </em>

<em>                     pos = ind+1 </em>

<em>                     if pos%2 == 0: </em>

<em>                            print(string.ascii_uppercase[ind-1],end="") </em>

<em>                     else: </em>

<em>                            print(string.ascii_uppercase[ind+1],end="") </em>

<em />

The main starts here

This line prompts user for input

anystring = input("Enter a string: ")

This line calls the easyCrypto() function

easyCrypto(anystring)

You might be interested in
Which of these ia an example of gene flow?
GalinKa [24]

In population genetics, gene flow (also known as gene migration) is the transfer of alleles or genes from one population to another. Migration into or out of a population may be responsible for a marked change in allele frequencies (the proportion of members carrying a particular variant of a gene).

7 0
3 years ago
Explain why a document created by word processing software is stored as a binary file.​
Savatey [412]

Answer:

Refer below.

Explanation:

Binary DOC records regularly contain more content organizing data (just as contents and fix data) than some other document designs like Rich Text Format and Hypertext Markup Language, however are normally less broadly good.

The DOC documents made with Microsoft Word renditions contrast. Microsoft Word forms before Word 97 ("8.0") utilized an alternate organization from the OLE/CFBF-based Microsoft Word 97 – 2003.

In Microsoft Word 2007 and later, the binary document design was supplanted as the default position by the Office Open XML group, however Microsoft Word can in any case produce DOC records.

3 0
3 years ago
How can website illustrate cooperations and kidness?
Brilliant_brown [7]
It can illustrate cooperation's and kindness by allowing many different people and strangers to post their opinions and thoughts as long as they are being positive about it! Hope i helped
8 0
3 years ago
Chris is working with other employees on a worksheet. the other employees have made comments, but they are not visible.
andriy [413]

Answer:

a. select show all comments on the review tab

Explanation:

Please mark me brainliest if correct

7 0
2 years ago
The energy used by an appliance which operates at 240 volts at 15 amp for 4 hr. is A. 0.92 kwhr. B. 3.45 kwhr. C. 14.4 kwhr. D.
Tju [1.3M]

Answer:

C. 14.4 kwhr.

Explanation:

To calculate the energy used by appliance first calculate the power. The formulae for calculating power(<em>P</em>) is P= I \times V, where V stands for voltage and I stands for current.

In the given problem,  V = 240 volts and I = 15 amp. Therefore,

P=240 \times 15 =3600\ watt(w) = 3.6\ kw

Now, formulae for calculating energy used i.e. work(W) is W = P\times t, where <em>t</em> is the time.

In the given question time is 4 hr. Therefore energy used will be,

Energy used (W) = 3.6\times4 =14.4\ kwhr.

8 0
3 years ago
Other questions:
  • Which term describes the order of arrangement of files and folders on a computer?
    11·1 answer
  • is this website just for a bunch of lazy kids bumming off answers? Because if that were the case I'd be one of them.
    9·1 answer
  • What is the assignment operator?
    15·1 answer
  • What's a good app that solves trigonometry problems?
    8·1 answer
  • When using a presentation software you can change the size of the text to...? Increase Font size, Decrease font size, increase t
    15·2 answers
  • Divide 111001 by 1101​
    7·1 answer
  • Which function category is not in Excel 2016?
    12·2 answers
  • One student will be stationed near you in a coffee shop. The other student will be located two miles away from your school. You
    10·2 answers
  • Describe a NIC card and can you have more than one?
    13·1 answer
  • When troubleshooting a network issue where a single host is unable to connect to the network, what is the first thing you should
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!