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

Answers

Answer 1

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!


Related Questions

The library Wi-Fi kiosk requires a symmetric connection to the Internet. Which WAN technology would probably be the least expensive option if the kiosk is within 0.75 miles of the telephone distribution office?

Answers

Answer:

The answer is IP-sec.

Explanation:

0.75 miles of range is a low distance for a WAN (Wide Area Network) so a point-to-point WAN tehcnology such as IP-sec or SD-WAN can be preferred. But the least expensive option would be choosing IP-sec as specified in the question.

I hope this answer helps.

can someone answer me

Answers

Answer:

D. 5,184,000

Explanation:

3000*1728= 5184000

What are the options included in the Illustrations command group? Check all that apply O Pictures and Online Pictures Tables SmartArt Screenshot Tool Animations​

Answers

Answer:

A. Pictures and Online Pictures.

C. SmartArt.

D. Screenshot Tool

Explanation:

Microsoft Excel is a software application designed and developed by Microsoft Inc., for analyzing and visualizing spreadsheet documents.

A spreadsheet can be defined as a file or document which comprises of cells in a tabulated format (rows and columns) typically used for formatting, arranging, analyzing, storing, calculating and sorting data on computer systems.

There are five (5) options included in the Illustrations command group of the Microsoft Excel software application and these are;

I. Pictures: this command or button is used to add images from a document (file) saved on a local computer.

II. Online Pictures: it is used for adding images from an online source such as blogs, websites etc.

III. SmartArt: this button is used to add graphical diagrams to a spreadsheet using styles such as process, matrix, relationship, picture, pyramid, list etc.

IV. Screenshot Tool: this is used for taking a snapshot of any window open on the computer i.e screen clipping.

V. Shapes: this comprises of various shapes such as lines, basic shapes, rectangles, equation shapes, block arrows, and flowchart.

3. What is output by the following code?
str1 "awesome"
str2 "leopard";
int i = 3;
int j = str2.length() - 3;
while (i < str1.length() &8 j > 0)
System.out . print (strl.substring(i, i + 1));
System.out.print(str2.substring (j, j + 1);
1++;
j--;
a. saopmoee
b. saompoeel
C.
saerwd
aspoomee
Nothing is printed because there is an out of bounds error
e,

Answers

Answer:

B I think

Explanation:

If you choose a color for your text that is similar to your background color, you will not have a strong
A sans serif
B scheme
C spectrum
D contrast

Answers

Answer:

D

Explanation:

contrast means two different things and without contrast the words would blend in

Answer:

The answer you are looking for is contrast. You often want your text to pop out from the background. using coral on top of hot pink would bring out a terrible contrast, whereas Cornflower blue and tan would bring out a very vivid contrast.

Which two statements are true about an OS?

A- translates the user’s instructions into binary to get the desired output
B- needs to be compulsorily installed manually after purchasing the hardware
C- is responsible for memory and device management
D- delegates the booting process to other devices
is responsible for system security

Answers

Answer:

A AND C

Explanation:

Answer: C and D

Explanation: correct on Plato - A is not a function of an OS


Pls help! 7th grade pythin fyi

Answers

Answer:

There should be a colon at the end of the if statement, ie:

if x > 100:  print("...")

I WILL MAKE BRAINLIEST PLS HURRY
Give your own examples for how list and dictionary data structures could keep track of some common information you might need. Your examples should be different from the ones in the unit.

Answers

Examples

Lists:

- Keep track of how much water you drink per day

- Hours spent on studying per week

- The growth of a plant

Dictionaries:

- Keep track of overall grades for each subject

- Keep track of where money is mostly spent on

- Dates for upcoming assessments and tests

Hope these examples help :)

-goodLizard is right

--Please make him brainliest

[Thank you]

The span was so long, the height so great, and the enterprise likely to be so costly, that few thought of it as something begun in earnest. . . . But Science said, "It is possible," and Courage said, "It shall be!" . . . . And so this Bridge is a wonder of science.


—Opening Ceremonies of the

New York and Brooklyn Bridge,

Seth Low


Which phrase from the excerpt is a fact that supports the opinion that the bridge is “a wonder of science”?


“the span was so long, the height so great”

“Science said, ‘It is possible’”

“something begun in earnest”

Answers

Answer:

"the span was so long, the height so great"

Explanation:

Just did on Edge 2020 and got it right.

Answer:”the span was so long, the height so great”

Explanation:

Why is this python code giving me problems?
This is having the user input a decimal number and the code has to round it up to the 2nd decimal place. This code is giving me problems, please fix it.

num3 = int(input("Please input a decimal number:")

num3 = int(round(num3, 2))

print ("your decimal rounded to the 2nd decimal place is:", x)

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The given code in this program has syntax errors.

In the given code, at line 1, input will cast or convert to int. It will generate an error on the second line because integer numbers can't be rounded. In simple, integer numbers don't have decimals. So, to correct the line you must use float instead of int.

In the second line, you need also to emit the int casting, because you have already converted the input into the float. In line 3, the second parameter to print function is num3, not x.

So the correct lines of the python code are given below:

num3 = float(input("Please input a decimal number:"))

num3 = (round(num3, 2))

print ("your decimal rounded to the 2nd decimal place is:", num3)

When you will run the above bold lines of code, it will run the program successfully without giving you any syntax and semantic error.

Can anybody answer these please hurry

Answers

Answer:
All of the above

Explanation:
Their size was very HUGE; While the computers were very EXPENSIVE to operate and used a great proportion of ELECTRICITY it caused the computers to generate a lot of HEAT which would cause the MALFUNCTIONS.

ARGENT !!20 POINTS
А ________ translates commands from a computer to draw lines on paper.

Answers

Answer:

dye-sublimation printer.

Explanation:

Answer:

Printer

Explanation:

Lorraina is editing a novel. Which style guide is the publisher most likely going to ask her to use?

American Psychological Association (APA)
Associated Press (AP)
Chicago Manual of Style (CMoS)
Modern Language Association (MLA)

Answers

Answer:

C) Chicago Manual of Style (CMoS)

Explanation:

Edge showed me the right answer.

Answer:

C

Explanation:

Exam Review on edge 2022

the four levels of FBLA membership

Answers

Answer:

Future Business Leaders of America (FBLA) for high school students; FBLA-Middle Level for junior high, middle, and intermediate school students; Phi Beta Lambda (PBL) for post secondary students; and Professional Division for those not enrolled in school or post secondary school

Explanation:

Can anybody answer this please hurry

Answers

Answer:

Ada Lovelace

The first one!

Hope this helps!

Answer:
A. Ada Lovelace

Explanation:
She created it in the 1840s while Alan Turing created his software in 1935.

9.3 Code Practice
Write a program that creates a 4 x 5 grid called numbers. The elements in your array should all be random numbers between -30 and 30, inclusive. Then, print the array as a grid

Please help!!!

Answers

Answer:

import random

def grid_maker(x, y):

   return [ [str(random.randint(-30, 30)) for _ in range(x)]for _ in range(y) ]

print ('\n'.join(' '.join(row) for row in grid_maker(4, 5)))

Explanation:

We use a template function and we generate numbers between -30 and 30:

>>> [str(random.randint(-30, 30))]

We also use the str() method so we can later concatenate the integers with \n. If you do not specify the integers, it will cause a crash. Also, keep in mind if we use a variable to store the integers, it will come out more of like a seed than a random grid. For instance, output without the random integers in a variable:

-12 16 -18 -3

7 5 7 10

18 -21 -16 29

21 3 -4 10

12 9 6 -9

Vs with a variable:

-25 6 -25 -20

-25 6 -25 -20

-25 6 -25 -20

-25 6 -25 -20

-25 6 -25 -20

Next we specify the  x and the y:

>>> for _ in range(x)]for _ in range(y) ]

Next we just print it and create a new line every time a row is made

hope this helped :D

The program is an illustration of the random module

The program in python, where comments are used to explain each line is as follows:

#This imports the random module

import random

#This is repeated four times (the rows)

for i in range(4):

   #This is repeated five times (the columns)

   for j in range(5):

       #This prints a random number between -30 and 30

       print(random.randint(-30, 30),end = ' ')

   #This prints a new line

   print()

Read more about random modules at:

https://brainly.com/question/13664230

Paige is writing about the progress her team made in setting up a new software system. in one detail, she tells that the team completed the testing phase. in another detail, she tells a second accomplishment the training program has started. what word would it be the best transition to connect the sentences about these two accomplishments

Answers

Answer:

Also

Explanation:

Just checked it in the system

Answer:

Also

Explanation:

What are the characteristics of using the Email Calendar command? Check all that apply.

a. it shows a specific date range
b. it shares a snapshot of the calendar
c. it is delivered as an attachment to an email
d. it grants read only access to the whole calendar
e. it is used to show dates without sharing the entire calendar.
f. it allows the user to add the calendar to their outlook client.


(question from edge)

Answers

Answer:

a b c e     are the correct ones

Explanation:

A, B, C, E

the correct answers are A, B, C, and E

A period in which unemployment is low, business produces many goods and services, and wages are good is called ______.

A. prosperity
B. productivity
C. personal income
D. business cycle

Answers

Answer:

A

Explanation:

How many dlcs in total were in each black ops game (including dlc weapons) answer for 25 whole points

Answers

Answer:

... ......................... ...............

you did the same<3<3

How is video compression accomplished?
O Video compression works by making the pixel size smaller.
O Video compression works by removing the sound.
O Video compression works by smoothing the pixels.
O Video compression works by removing unnecessary parts of frames.

Answers

Answer:

Video compression works by making the pixels smaller.

Explanation:

I went on a boring website that actually knows about this stuff and found the answer. R I P my brain cells.

Answer:

a

Explanation:

What does the primary Help icon look like in Access?

a square with a star
a diamond with an asterisk
a circle with a question mark
a triangle with an exclamation point

Answers

a circle with a question mark

Answer:

c

Explanation:

for (int j- 4; j > 0; j--)
for (int k 1; k < j; k+)
System.out.print (j +);
System.out . println() ;
What is output when the program runs?
a.
4444
b
4321
321
21
4444
333
22
1234
123
12
4321
432
43

Answers

Answer:

C is your awnser

Explanation:

i need help, thank you

Answers

Answer:

A

Explanation:

When astronauts aboard the International Space Station (ISS) exhale carbon dioxide (CO2), it's removed from the air and pumped into space.

please mark brainliest :D

why did the boy run from the pillow...... wrong answers only

Answers

He thinks there is a demon hiding innit thus, he runs and calls his mom. His mom says "Jimmy there's nothing in that pilow young man!" Jimmy walks back to his room scared if its still there. He hops into bed hoping that he can get a good nights rest. The next day, Jimmy asks if he can go buy another pillow. His mom says "As long as it makes you feel safe then ok." Young Jimmy, jumping in excitement, goes to the checkout zone to buy his new pillow. When they get home, Jimmy and his mom eat dinner and then head for bed. Jimmy hops into bed and knows that everything will be ok. The end.

Ivan wants to have code in a game that will make it possible to change the speed of a swimmer in the game. Which of these does Ivan need?

A.
a Boolean value

B.
output

C.
a variable

D.
a database

Answers

A) a Boolean value, because you can have two possible values which is intended to represent the two truth values of logic.

I NEED HELP PLEASE
Giving 10 points

Answers

Answer:

If you made this 10 points i would help but yolo

Explanation:

SOMEONE HELPPP PLEASE!!!ILL GIVE BRAINLIEST TO THE PERSON WHO ANSWERS THIS QUESTIONS :

- What are the four basic reasons why we get into conflicts? *
A.Wants, Foods, Love, Goals
B.Water, Needs, Hopes, Goats
C.Wants, Desire, Expectations, Anger
D.Wants, Needs, Values, Goals

- Select ALL that apply.What do you need in order to begin with the end in mind?
A.A plan to help you achieve your goal
B.A letter stating possible career options
C.A personal mission statement
D.A list of goals

- What are the four types/modes of communication?
A.Writing,seeing,hearing,interpreting
B.Evaluating,remembering,listening,hearing
C.Writing,reading,speaking,and listening
D.None of the above

- What is the fifth step in the listening process?
A.Responding
B.Remembering
C.Probing
D.Listening

- Which one of the following is NOT a component of genuine listening
A.Stand in the other person’s shoes
B.Listen with your ears,your eyes and your heart
C.Hearing someone’s most deepest secret
D.None of the above

- What is the definition of digital citizenship?
A.An online membership
B.Not giving credit to someone else’s work
C.Using digital media safely,responsibly,and ethically
D.Any information about you on the internet

- According to The Leader in Me program,when practicing synergy,1+1=___?
A.2
B.Whatever we want it to be
C.None of the above
D.All of the above

- Which time quadrant is categorized as important and urgent while putting things off until the LAST minute?
A.Q3
B.Q1
C.Q2
D.Q4

- Beginning without the end in mind is like...
A.trying to solve a jjgsaw puzzle without the picture
B.Never thinking about death
C.Not knowing the last words to a song
D.All of above

Answers

Answer:

the four types/modes of communication is

Explanation:

writing,speaking, reading,listening

What are the best ways to conduct research for a presentation? Check all that apply.


ask a friend

go to the library

talk to an expert

search the Internet

visit with a neighbor

Personally I think it is C and D,
but Edge probably has something
else to say. :P

Answers

Answer:

confident

Explanation:

and some more add-ons:

A short intro

Poster presentation

Practice your delivery

simple and strong convey

Eye contact

and

last but not least *keep smiling*

The best ways to conduct research for a presentation? is to

Go to the library.Talk to an expert Search the Internet.

Why is it vital to conduct a research presentation?

It is one that gives a person the ability to stand for their science. When a person stands for their field of interest, it helps researchers in other disciplines, to be more aware.

Note that by doing the above steps, such as Talking to an expert, one van be able to conduct research for a presentation.

Learn more about presentation from

https://brainly.com/question/24653274

#SPJ2

Which online note-taking device allows students to clip a page from a website and reuse it later?

web clipping tools
electronic sticky notes
offline data storage sites
online data storage sites

Answers

Answer:

The answer is A.) web clipping tools.

Explanation:

Cuz like yeah

Answer: WEB CLIPPING TOOLS

Explanation:

Other Questions
Anna is working at a fast food restaurant and made $45.00 for 6 hours. Allison is working at a retail store and made $50.75 for 7 hours. If both girls worked for 10 hours, which girl would make more money and how much would she make? find the quotient 24-6 Which of the following is the correct formula for calculating potential energy?PE = mass x gravityPE = mass/gravityPE = mass x gravity x heightPE = mass + gravity + height can you help me please What is the purpose of a non-governmental organization (NGO)? Name several ways that popular American media and culture have affected your understanding of marriage What was the name of the group of Protestants who were critical of the Church of England and wanted to purify it? A. Witches B. CatholicsC. Colonists D. Puritans The 1950s is considered a decade of social experimentation and a rising consumerism. True False Towards the end of a 400m race, Faisal and Edward are leading and are both running at 6m/s. While Faisal is 72m from the finish line Edward is 100m from the finish line. Realising this and to beat Faisal, Edward decides to accelerate uniformly at 0.2 m/s2 until the end of the race while Faisal keeps on the same constant speed. Does Edward succeed in beating Faisal 5 * .Write a text of at least 80 words. summarize all the information in the chartFavourite school subjects between boys and GirlsI need 80 words please When Rome divided, it split into two parts. What are they?A. Northern and Southern Empire B. New Rome and Ancient RomeC. Old and New RomeD. Eastern and Western Empire what numbers add up to 26 and when subtracted the difference is 24? the answer choices are-U.S. Constitution is writtenThe Civil Rights MovementTwo world wars take place mostly in EuropeThe American Revolution is fought What is the criticism of a nation-centered federalism system of government based upon?A.concern that it would soon lead to the coronation of a king rather than a presidentB.the belief that a national government could not act in the best interests of its citizensC.the fear that placing too much authority in a strong national government would limit the authority of the statesD.evidence that the foundation of national federalism lacked the funds necessary to survive True or False: The negative oxygen end of one water molecule is attractedto the positive hydrogen end of another water molecule to form ahydrogen bond. Dylan and his children went into a grocery store and where they sell peaches for $1 each and mangos for $0.50 each. Dylan has $15 to spend and must buy no less than 15 peaches and mangos altogether. If Dylan decided to buy 13 peaches, determine the maximum number of mangos that he could buy. If there are no possible solutions, submit an empty answer Amanda is trying to subtly sign about a classmate to Andi, who is Deaf. However, Andi is confused about who exactlyAmanda is referring to. What could have caused the confusion?too many indexes too few lexiconswrong classifierslack of spatial agreement If an unknown substance burns yellow, what metal ion is in the substance? What are two positive effects of using child labor during the Industrial Revolution? The picture looks flat they need more...1. lights and shadows2.lines3.pattern