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
Write a definition in your own words for Raster Graphic. Do not copy and paste please.
Vlada [557]

Answer:

Raster Graphic is a bitmap. They are basically a grid of small pixels that make an image.

6 0
2 years ago
What is the keyboard shortcut for opening the edit hyperlink dialog box
Mademuasel [1]

That would be CTRL+K


https://quizlet.com/122913134/keyboard-shortcuts-flash-cards/


hope this helps!

7 0
2 years ago
The variables xp and yp have both been declared as pointers to integers, and have been assigned values. Write the code to exchan
shepuryov [24]
The question is asking us to swap the values of xp and yp while not changing where they point to. Setting xp equal to yp would not work because then we couldn't change yp since the value for xp was overwritten. We can use a third variable to swap them.

int zp = xp;
xp = yp;
yp= zp;
6 0
3 years ago
How drone technology can impact recreation and entertainment​
Maurinko [17]

Drones are become more advanced than ever before. Are now, they are starting to impact recreation. They are small, light, and can maneuver incredibly fast. They are being used in movies, skits, short films, and even high-end videos. Here are some ways drones are changing entertainment:

- Providing high-quality filming, even from 200 feet in the air.

- Reaching spaces where bulky helicopters cannot fit into safely

- Laser shows, where drones shine lights and lasers.

Right now, if you tried to hold your phone still to capture a video, you would not be able to do it. Upon checking the footage, you would see the camera shaking, even if it's just tiny bit. While you can lean it on a surface to fix this, it simply cannot be done in the air to capture. Not to worry, though, you've got drones. They can shoot a steady shot 200 feet in the air. The only thing that could rival drones are expensive, bulky choppers. The drones are cheaper and are mass produced.

However, drones are not only being used to filming movies and films. They are also being used for a different kind of entertainment: Shows. Drones move in formation and shine lights in the night sky, like we saw in the Winter Olympics. They are truly stunning(pics attached).

7 0
1 year ago
How is a high-level programming language compiled? (5 points)
choli [55]

Answer:

A high-level language is a programming language that uses English and mathematical symbols in its instructions. To execute a program in a high-level language, it can be compiled or interpreted. A compiler translates the entire program written in a high-level language to machine language prior to execution. After the compiler translates the code into machine language, it is typically executed line-by-line.

Explanation:

7 0
2 years ago
Other questions:
  • whats something that u want to do but ur parents wont allow it like having a phone or going to a college ​
    11·2 answers
  • List 3 ways that you can use excel and the features it includes and explain why a spreadsheet is the best choice for this task.
    5·1 answer
  • By default, which of these traffic source dimensions does google analytics capture for each user that visits your website?
    8·1 answer
  • A function operates on this, which may consist of a constant, a cell reference, or another function.
    7·1 answer
  • The variety of theatre introduced in the 1960s that denotes semi-professional or even amateur theatre in the New York/Manhattan
    11·1 answer
  • When does information become a liability for an organization
    6·1 answer
  • Alicia uses a software application to store the names, email addresses, and phone numbers of her friends in alphabetical order. 
    11·1 answer
  • To display “ hello ” message on the screen
    14·1 answer
  • How do I use files and functions in programming?
    10·1 answer
  • I need help with humans need not apply for codeing
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!