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
For each problem listed below, use the drop-down menu to select the field of the professional who can help solve the issue.
Paul [167]

Answer:

  • Interactive media
  • Information services and support
  • Programming and software development
  • Network systems administration

Explanation:

The company has finished designing a software program, but users aren’t sure how to use it. <u>interactive media</u>

Several people in the human resources department need new software installed. <u>information services and support</u>

An employee has an idea for a software program that can save the company time, but doesn’t know how to write it. <u> programming and software development</u>

A new branch of the company is opening soon, and the computers there need to be connected to the Internet. <u>network systems administration</u>

<u>OAmalOHopeO</u>

3 0
3 years ago
What changes the size of a video when played?
Leni [432]

Answer:

D. the browser

Explanation:

it adjusts to the size of your device, including the browser.

hope i helped

8 0
2 years ago
Read 2 more answers
Which of the following tasks is least effective at preventing a computer virus A. Anti-virus's software up to date
MaRussiya [10]
C is your answer
hope that helps
4 0
3 years ago
Read 2 more answers
Drag each tile to the correct box. Shawn has been assigned to create a storyboard for an online grocery website. Organize the st
defon

Answer:  I believe the correct order is:

    Create a box and title it as the “Home Page”  →   Branch out pages and specify navigation flow  →  Gather information such as text and images   →   Determine the title, heading, and content for each page  →   Draw a layout of each web page with its elements.

Explanation:  It makes sense, you start with your "Home Page", then you follow the steps of planning to map out your site's navigation. You have to gather information about it before you have enough knowledge about it to determine the title, heading, and content.  You also need to know the content to create a clean and workable layout for the page.

6 0
3 years ago
Read 2 more answers
True or False? To reduce hazards, flexible cords must connect to devices and fittings in ways that prevent tension at joints and
anastassius [24]
<span>It can be true and is really necessary for this type of things when fittings in ways that prevent tension at joints and terminal screws. So, Flexible cords are finely stranded for flexibility, so straining a cord can cause the strands of one conductor to loosen from under the many joints.</span>
5 0
3 years ago
Other questions:
  • Use the drop-down menus to complete the statements about using section breaks in a document
    9·1 answer
  • A storyboard is an example of an implementation tool.<br><br> A.<br> True<br><br> B.<br> False
    8·2 answers
  • In your own words, explain the role of scientific investigation in the development of the Theory of Evolution.
    6·1 answer
  • For the questions below, consider a class called ChessPiece. This class has two instance data, String type and int player. The v
    13·1 answer
  • Implement a recursive program that takes in a number and finds the square of that number through addition. For example if the nu
    5·1 answer
  • If, when asked for a date of birth, the user enters a future date, this error should be caught by a ________ check.
    8·1 answer
  • Modify class Time2 of fig 8.5, (which is split into four pictures) to include a tick method that increments the time stored in a
    8·1 answer
  • What dd command would you use to copy the contents of a partition named /dev/drive1 to another partition, called /dev/backup?
    6·1 answer
  • Which feature is not in ms PowerPoint​
    12·1 answer
  • When you connect to an Access database, which entities are shown in the Navigator window?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!