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
Carmen has met new people online that she enjoys talking to. One of these people has asked her to meet at the park in person and
slavikrds [6]

Answer:

Don't go to the park!!

Explanation:

You don't know the person personally and they could be acting and hurt you. Especially if they tell you not to tell someone. So don't go!

8 0
2 years ago
_______is a term which describes how the operating system will interrupt the execution of an application when an application of
a_sh-v [17]

Answer:

scheduling

Explanation:

Scheduling- it is referred to as assigning a task to complete the goal or work on time. he works can include data flow, processing of data, etc.

There are two main types of scheduling

1) Preemptive process

2) Non- preemptive process

Preemptive process -  in this process, priority is given to important tasks rather than less important tasks. the current task can be held for an important task

Non-preemptive process -  It is referred to that process when the predefined schedule follows. In this  process, next task executed only when current task finish

6 0
2 years ago
I am programming and i want to find the amount of move functions i need to complete the full square. the square is 65 by 70 circ
Ahat [919]
Not to be rude, but this is elementary school. How would anyone know this?
8 0
3 years ago
Write a function named ​isDivisible​ that takes two parameters
nirvana33 [79]

Answer:

def isdivisible():

   maxint=input("Enter the Max Int")

   int1=0

   int2=0

   int1=input("Enter the first Integer")

   int2=input("Enter the second Integer")

   tup1=(int1, int2)

   print(tup1)

   i = 1

   for i in range(1, int(maxint)-1):

       if int(tup1[0])%i==0 & int(tup1[1])%i==0:

           print(i)

       else:

           continue

       

   

isdivisible()    

1.2 Outputs

First test case:

Enter the Max Int6                                                                                                            

Enter the first Integer2                                                                                                      

Enter the second Integer8                                                                                                      

('2', '8')                                                                                                                    

1                                                                                                                              

2      

Second test case: returning empty list

Enter the Max Int2                                                                                                            

Enter the first Integer13                                                                                                      

Enter the second Integer27                                                                                                    

('13', '27')

Test case 3:

Enter the Max Int4                                                                                                            

Enter the first Integer8                                                                                                      

Enter the second Integer10                                                                                                    

('8', '10')                                                                                                                    

1                                                                                                                              

2        

Explanation:

The program is as above, and the three test cases are also mentioned. We have created a tuple out of two input integer, and performed the output as required.

3 0
3 years ago
An employee clicks on a link in an email from what looks like a fellow employee and is taken to a fraudulent web site which asks
Fittoniya [83]

Answer:

e. Phishing

Explanation:

Phishing is a type of fraudulent or social engineering attack used to lure unsuspecting individuals to click on a link that looks like that of a genuine website and then taken to a fraudulent web site which asks for personal information.

Attackers use it to steal sensitive user data or information.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Which one of the following oscilloscope controls is used to move the trace up and down the screen vertically? A. Focus B. Sweep
    9·2 answers
  • F a domain consists of dcs that are running verions of windows server earlier than windows server 2008, what replication method
    10·1 answer
  • Wap to input any multi digits number and display the sum of odd digits and even digits​
    5·1 answer
  • Write a function in Java that implements the following logic: Given a string and an int n, return a string made of n repetitions
    15·1 answer
  • Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
    10·1 answer
  • Sometimes news organizations have biasis because
    5·1 answer
  • A large software development company employs 100 computer programmers. Of them, 45 areproficient in Java, 30 in C, 20 in Python,
    9·1 answer
  • Vpn stands for _____. very precise settings virtual private network virtual public network vice prestigious setup
    5·1 answer
  • When a support agent does not know the answer to a question, a good incident management strategy is to tell the user ____.
    5·1 answer
  • You are creating a web page as part of a science project. Your role is to put your data on the webpage. You tracked the growth o
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!