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
sasho [114]
3 years ago
6

Write a code block to encode strings from original messages, using our custom encoding. To do so: Initialize a variable called c

ustom_encoded as an empty string Use a for loop to loop across all characters of a presumed string variable called custom_message Inside the loop, check if the current character is in the custom_encodings dictionary If it is, use the current char to get the value from custom_encodings, and concatenate it to custom_encoded The line inside the if should look something like out = out + dictionary[char] Otherwise, concatenate the current character to custom_encoded
Computers and Technology
1 answer:
blondinia [14]3 years ago
3 0

Answer:

  1. custom_encoded = ""
  2. custom_message = "this is a pen"
  3. custom_encoding = {
  4.    "a": "1",
  5.    "e": "2",
  6.    "i": "3",
  7.    "o": "4",
  8.    "u": "5"
  9. }
  10. for c in custom_message:
  11.    if(c in custom_encoding):
  12.        custom_encoded = custom_encoded + custom_encoding[c]
  13.    else:
  14.        custom_encoded = custom_encoded + c
  15. print(custom_encoded)

Explanation:

The solution code is written in Python 3.

Let's define a variable custom_encoded with an empty string (Line 1).

Create another variable custom_message and set a sample string to it (Line 2).

Create one more variable custom_encoding to hold the mapping values between vowel and their respective encoded character (Line 3-9).

Create a for loop to loop through all the character in custom_message (Line 11) and in the loop check if the current character is found in custom_encoding dictionary, if so, use the current character to loop up the dictionary for the encoded value and add the encoded string to custom_encoded (Line 12-13). Otherwise, just add the current character to custom_encoded (Line 14-15).

At the end, print the custom_encoded to terminal and you shall get th3s 3s 1 p2n

You might be interested in
What does an operating system do?
Vinvika [58]
It uses a special 'language' or code to tell it what to do a what times, why, and how.  It gives the Computer an 'easier' Operating System (OS) to run on / off of.  The OS makes The Computer easier for us, to use and understand.
8 0
3 years ago
Which of the following situations is least likely fair use
kolezko [41]

Answer:

Is there more to the question or is that it?

8 0
3 years ago
Read 2 more answers
Assume that a kernel is launched with 1000 thread blocks each of which has 512 threads. If a variable is declared as a shared me
Alex

Answer:

The answer to this question is the option "B".  

Explanation:

In this question, the answer is option B which is 1,000 because the kernel is a central part of an operating system. kernel manages the computer and the hardware operations. most especially memory and CPU time. It also sheared a memory variable is allocated to thread blocks. That's why the answer to this question is 1,000.

7 0
3 years ago
What is the main idea of this article? Please someone help me. I will give brainliest answer
mart [117]
The main idea of this article is that theme parks are conducting scientific research that is benefiting the community. Hope this helps!
8 0
4 years ago
Which passage form the passage best contributes to elisa impatient tone
dusya [7]
You need to attach a document of where i would read it from
4 0
4 years ago
Other questions:
  • OSHA requires that employers pay for most required personal protective equipment (PPE), including: A. Hard hats B. Logging boots
    5·1 answer
  • Python
    14·1 answer
  • design the psuedocode for a program that allows a user to enter 10 numbers, then displays them in the reverse order of their ent
    6·1 answer
  • When is Hytale coming out?<br><br><br> P.S it might be Mine-craft 2.0<br><br><br> :)
    7·1 answer
  • Which note-taking method quickly captures and organizes information?
    9·2 answers
  • What form of communication are they using​
    6·1 answer
  • Persuasion is when Someone speaks to crowd about love <br>○True<br>○False​
    10·1 answer
  • Justify any FOUR significant factors to remember when installing your motherboard
    7·1 answer
  • If anyone gotta ps4, i'm a 15 yr old female n if u wanna b frens, hmu :))
    8·2 answers
  • Which of the following online creation tools will be used if a person wants to create a video presentation?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!