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
Consider the given choices and determine which one establishes a conceptual framework for network connectivity.
Snezhnost [94]

Of the given choices, the option that establishes a conceptual framework for network connectivity is OSI model.

<h3>What is network connectivity?</h3>

Network connectivity is a term that tells more about the process of connecting different areas of a network to each other.

Conclusively, the OSI Model often called Open Systems Interconnection Model is known to be the conceptual framework that tells the functions or duties of a networking system.

Learn more about  network connectivity from

brainly.com/question/26956118

5 0
2 years ago
To ensure rapid recovery and security of data, backup data should be ________.
Nataly [62]

Answer:B kept at a secure location at the facility

Explanation:

8 0
3 years ago
System uses a 6-bit 2’s complement signed integer representation. What is the range of decimal values it can represent?
kap26 [50]

Answer:

-32 to +31

Explanation:

6 bit 2s complement representation will be of the form b1b2b3b4b5b6 where each bit is either 0 or 1.

The largest positive number that can be represented using this scheme is 011111

Translating this to decimal this is 1*2^4 + 1^2^3 + 1^2^2 + 1^2^1 + 1^2^0

=16 + 8 + 4 + 2 + 1 =31

The smallest negative number that can be represented using this scheme is 100000

Translating this to decimal = -1 * 2^5 = -32

So the range of decimal values that can be represented is -32 to +31.

6 0
4 years ago
What are the two types of modern wind turbines?
gulaghasi [49]
To be honest I'm not sure but I'd say B,C
7 0
3 years ago
Is this photo considered rim photography?
steposvetlana [31]

wheres the picture??

8 0
3 years ago
Other questions:
  • Lisa adds her co-worker Renald to a meeting and removes her secretary Olivia from the meeting. What will happen as a result?
    14·2 answers
  • When first created all charts always include___and a chart area
    8·2 answers
  • Is bit stuffing necessary in the control or address field in theHDLC protocol? why?
    13·1 answer
  • How do Hlookup and Vlookup differ?
    5·2 answers
  • If object B inherits from object A, then which of the following statements is true?
    15·1 answer
  • Como funciona la televisión
    7·1 answer
  • A company operates on two types of servers: 2 large servers (L) and 4 smaller servers (S), with a combined total of 64GB RAM. Th
    9·1 answer
  • Create a list with 5 numbers and find the smallest and largest number in the list and also the sum and product of the numbers in
    9·1 answer
  • If an OS is using paging with offsets needing 12 bits, give the offset (in decimal or hexadecimal) to: the third word on a page
    10·1 answer
  • Based on Microsoft's Component Object Model (COM), _____ is database middleware that adds object-oriented functionality for acce
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!