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
ASHA 777 [7]
2 years ago
8

Program a substitution cipher in Python. Create 2 functions one for encryption and the other for decryption ( get the text as th

e parameter).
Computers and Technology
1 answer:
raketka [301]2 years ago
7 0

alphabet = "abcdefghijklmnopqrstuvwxyz"

def encrypt(txt):

   shift = int(input("Enter the shift: "))

   new_txt = ""

   for x in txt:

       if x in alphabet:

           if alphabet.index(x)+shift >= len(alphabet):

               new_txt += alphabet[(alphabet.index(x)+shift - len(alphabet))]

           else:

               new_txt += alphabet[alphabet.index(x)+shift]

       else:

           new_txt += x

   return new_txt

def decrpyt(txt):

   shift = int(input("Enter the known shift: "))

   new_txt = ""

   for x in txt:

       if x in alphabet:

           new_txt += alphabet[alphabet.index(x) - shift]

       else:

           new_txt += x

   return new_txt

print(encrypt("yellow dog."))

print(decrpyt("lryybj qbt."))

My code works with lowercase text only. If you need me to modify the code, I can do that. I tested my code with a shift of 13 in both the encryption and decryption. I hope this helps!

You might be interested in
What will allow you to purchase software without receiving full rights to the program?
mihalych1998 [28]

Answer:

i need free points cus i have zero sry

Explanation:

7 0
4 years ago
The Windows taskbar is generally found _____. at the top of the screen in the Start menu at the bottom of the screen at the righ
rjkz [21]
At the bottom of the screen.
4 0
3 years ago
Read 2 more answers
(Just wondering and for fun) What can humanity do to survive after the universe dies? Assuming we have advanced tech and there a
Troyanec [42]

Answer:

If this is for fun. then may I take points for free. If not, then I will post my answer :)

Explanation:

5 0
3 years ago
The transitions between slides in a presentation are one type of powerpoint ____.
slava [35]
The transitions between slides in a presentation are one of type of power point 
Animation.
Animation is a set of effects which can be applied to objects in power point  so that they will animate in the slideshow power point.motion paths allow objects to move around the slide show.
4 0
3 years ago
What is the maximum ream size on an agile project?
yarga [219]

Most Agile and Scrum training courses refer to a 7 +/- 2 rule, that is, agile or Scrum teams should be 5 to 9 members. Scrum enthusiasts may recall that the Scrum guide says Scrum teams should not be less than 3 or more than 9

Explanation:

6 0
3 years ago
Other questions:
  • What term refers to a piece of software that interfaces with the hardware on your computer?
    10·2 answers
  • Ken is moving to a new city and considering whether he should rent or buy an apartment. what factors should he consider in his d
    5·1 answer
  • Working at a ski resort in the mountains has its own unique security issues. Kenny is the chief information officer for Sundance
    10·1 answer
  • What is the best platform for a online meeting?
    10·2 answers
  • Consider the code below. When you run this program, what is the output if the temperature is 77.3 degrees Fahrenheit?
    6·1 answer
  • 1.
    9·1 answer
  • takes the perspective that a program describes what the solution to a problem is, not how that problem is solved. Select one: a.
    5·1 answer
  • A network consists of 75 workstations and three servers. The workstations are currently connected to the network with 100 Mbps s
    12·1 answer
  • What is the difference between the byte and short data types in Java?
    7·1 answer
  • What happens when the electrons flowing through the light bulb change direction?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!