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
algol [13]
3 years ago
12

9.12 LAB: The Caesar cipher In cryptography, Caesar's cipher is one of the simplest and most widely known encryption techniques.

The method is named after Julius Caesar, who used it in his private communication. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. We wish to implement Caesar's encryption scheme by substituting each alphabet in the string with another alphabet that occurs three shifts to its left. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. Note that that the code wraps around in that A would be replaced by X, B would be replaced by Y, and C would be replaced by Z. Write a function called encrypt that takes two input arguments: the plaintext and the number of left shifts to use when constructing the cipher, and returns the encrypted string. For example, if the user enters plaintext = "I CAME I SAW I CONQUERED" and shift = 3, then

Engineering
2 answers:
Nat2105 [25]3 years ago
8 0

Answer:

# the function is defined with two parameters: message and shift key

def encryptMessage(message, shift):

translated = ''

ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

message = message.upper()

for letter in message:

if letter in ALPHABET:

num = ALPHABET.find(letter)

num = num - shift

if num >= len(ALPHABET):

num = num - len(ALPHABET)

elif num < 0:

num = num + len(ALPHABET)

translated += ALPHABET[num]

else:

translated += letter

print(translated)

plaintext = str(input("Enter your plain text: "))

shift = int(input("Enter your key: "))

encryptMessage(plaintext, key)

encryptMessage('I CAME I SAW I CONQUERED', 3)

Explanation:

The code is written in Python. The logic goes below:

First translated is define as empty string to hold the encrypted text (ciphertext).

Next the entire alphabet is defined as a string constant.

Next, the received message is converted to upper case using message.upper().

Then a for-loop that goes through the entire string. Inside the for-loop is where the encryption happens. The if block check if a letter is in the ALPHABET, then it encrypt else it will just append the character to the translated (maybe space).

In the if block for encryption, we first find the index of the letter in the ALPHABET and assign it to num. Then shift is subtracted from num. If num > 26, we subtract 26 from num else if num < 0, we add 26 to num.

Next we find the letter of the alphabet with the index of num and append it to translated. Then 'translated' is displayed.

At the end of the function, we ask the user to enter a plaintext and also prompt the user to enter shift. Then the function is called using plaintext and shift as arguments.

Fantom [35]3 years ago
3 0

Answer:

The code for the given arguements is attached as images.

You might be interested in
A capillary tube is immersed vertically in a water container. Knowing that water starts to evaporate when the pressure drops bel
Anuta_ua [19.1K]

Answer:

d=0.414\times 10^{-4}\ m

Explanation:

Given that

P = 4 KPa

Contact angle = 6°

Surface tension = 1 N/m

Lets assume that atmospheric pressure = 100 KPa

Lets take that density of water =1000\ kg/m^3

So the capillarity rise h

h=\dfrac{\Delta P}{\rho g}

h=\dfrac{100\times 1000-4\times 1000}{1000\times 10}

h= 9.61 m

We know that for capillarity rise h

h=\dfrac{2\sigma cos\theta }{r\rho g}

r=\dfrac{2\sigma cos\theta }{h\rho g}

r=\dfrac{2\times 1 cos4^{\circ} }{9.61\times 1000\times 10}

r=0.207\times 10^{-4}\ m

d=0.414\times 10^{-4}\ m

3 0
3 years ago
Find the Rectangular form of the following phasors?
almond37 [142]

Answer:

The angles are missing in the question.

The angles are :

45,     30,    60,     90,    -34,     -56,      20,     -42,  -65,    -15

P=10, P=5,  P=25, P=54, P=65, P=95, P=250, P=8, P=35, P=150

Explanation:

1. P = 10,   θ = 45°  rectangular coordinates

x = r cosθ  ,   y = r sinθ

So, rectangular form is x + iy

x = P cosθ = 10 cos 45°

  = 7.07

y =P sinθ = 10 sin 45°

  = 7.07

Therefore, rectangular form

x + iy = 7.07 + i (7.07)

2. P = 5 , θ = 30°

x = 5 cos  30° = 4.33

y = 5 sin  30° = 2.5

So, (x+iy) = 4.33 + i (2.5)

3. P = 25 , θ = 60°

x = 25 cos  60° = 12.5

y = 25 sin  60° = 21.65

So, (x+iy) = 12.5 + i (21.65)

4. P = 54 , θ = 90°

x = 54 cos  90° = 0

y = 54 sin  90° = 54

So, (x+iy) = 0+ i (54)

5. P = 65 , θ = -34°

x = 65 cos  (-34°) = 53.88

y = 65 sin  (-34°) = -36.34

So, (x+iy) = 53.88 - i (36.34)

6. P = 95 , θ = -56°

x = 95 cos  (-56)° = 53.12

y = 95 sin  (-56)° = -78.75

So, (x+iy) = 53.12 - i (78.75)

7. P = 250 , θ = 20°

x = 250 cos  20° = 234.92

y = 250 sin 20° = 85.5

So, (x+iy) = 234.92 + i (85.5)

8. P = 8 , θ = (-42)°

x = 8 cos  (-42)° = 5.94

y = 8 sin  (-42)° = -5.353

So, (x+iy) = 5.94 - i (5.353)

9. P = 35 , θ = (-65)°

x = 35 cos  (-65)° = 14.79

y = 35 sin  (-65)° = -31.72

So, (x+iy) = 14.79 - i (31.72)

10. P = 150 , θ = (-15)°

x = 150 cos  (-15)° = 144.88

y = 150 sin  (-15)° = -38.82

So, (x+iy) = 144.88 - i (38.82)

6 0
3 years ago
Show that y = '(t - s)f(s)ds is a solution to my" + ky = f(t). Use g' (0) = 1/m and mg" + kg = 0. 6.1) Derive y' 6.2) Using g(0)
Gre4nikov [31]

Answer:

Explanation:

Given that:

y = \int^t_og'(t-s) f(s) ds \  \text{is  solution to } \ my"ky= f(t)

where;

g'(0) = \dfrac{1}{m}     and mg"+kg = 0

\text{Using Leibniz Formula to prove the above equation:}

\dfrac{d}{dt} \int ^{b(t)}_{a(t)} \ f (t,s) \ ds = f(t,b(t) ) * \dfrac{d}{dt}b(t) - f(t,a(t)) *\dfrac{d}{dt}a(t) + \int ^{b(t)}_{a(t)}\dfrac{\partial}{\partial t} f(t,s) \ dt

So, y = \int ^t_0  g' (t-s) f(s) \ ds

\text{By differentiation with respect to t;}

y' = g'(o) f(t) \dfrac{d}{dt}t- 0 + \int^{t}_{0}g'' (t-s) f(s) ds \\ \\  y' = \dfrac{1}{m}f(t) + \int ^t_0 g'' (ts) f(s) \ ds

y'' = \dfrac{1}{m} f'(t) + g"(0) f(t) + \int^t_o g"'(t-s) f(s)ds --- (1)

Since \ \ mg" (t) +kg (t) = 0  \\ \\  \implies g" (t) = -\dfrac{k}{m} g(t) --- (111) \\ \\  put \  t \  =0 \  we  \ get;\\g" (0) = - \dfrac{k}{m } g(0)  \\ \\  g"(0) = 0 \ \ \ \   ( because \  g(0) =0) \\ \\

Now \ differentiating \ equation (111) \ with \ respect \ to \ t  \\ \\  g"'(t) = -\dfrac{k}{m}g(t)  \\ \\  replacing  \ it \ into  \ equation \ (1) \\ \\ y" = \dfrac{1}{m}f' (t) + 0 + \int ^t_o  \dfrac{-k}{m}g' (t-s) f(s) \ ds \\ \\ y" = \dfrac{1}{m}f' (t) - \dfrac{k}{m} \int ^t_o g' (t-s) \ f(s) \ ds \\ \\  y" = \dfrac{1}{m}f'(t) - \dfrac{k}{m}y \\ \\  my" = f'(t)-ky \\ \\ \implies \mathbf{ my" +ky = f'(t)}

7 0
3 years ago
Para uma dada velocidade do vento, o gerador de turbina mostrado na figura produz 22 kW de potência elétrica. Como um sistema co
____ [38]

Answer:

b

Explanation:

4 0
3 years ago
A 0.25in diameter copper rod BC is securely attached between two identical 1in diameter steel rods (AB and CD).
sashaice [31]

Explanation:

Below is an attachment containing the complete question and solution

5 0
3 years ago
Other questions:
  • Design a half-wave recti er which provides a peak voltage of 15 V, and anaverage voltage of 3.8 V when driven by a 120 V (rms) a
    10·1 answer
  • Using the background information provided and your answers to questions 1 &amp; 2, look at the hex packet below and identify the
    10·1 answer
  • The contractor was awarded a contract to construct a parking lot for a small shopping center. The contractor plans to use single
    13·1 answer
  • Give me some examples of fragile structures.
    5·1 answer
  • What regulates labeling of food, drugs, and cosmetics?
    10·2 answers
  • An apple, potato, and onion all taste the same if you eat them with your nose plugged
    8·2 answers
  • When did michael faraday invent wind powered electrical generation?
    11·1 answer
  • Schrodinger equation is a ........... Equation
    10·1 answer
  • What is working fluid and mention five example of working fluid.​
    14·2 answers
  • What car is this? I thinks its a nissan 240sx but i dont know
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!