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
The net force on a vehicle that is accelerating at a rate of 1.2 m/s2 is 1500 newtons. What is the mass of the vehicle to the ne
Rudiy27

Answer:

The mass of the vehicle is 1250kg

Explanation:

Given

Net\ Force = 1500N

Acceleration = 1.2m/s^2

Required

Determine the vehicle's mass

This question will be answered using Newton's second law which implies that:

Net\ Force (F) =  Mass (m) * Acceleration (a)

In other words:

F = ma

Substitute values for F and a

1500 = m * 1.2

Make m the subject

m = \frac{1500}{1.2}

m = 1250kg

<em>Hence, the mass of the vehicle is 1250kg</em>

6 0
3 years ago
Explain briefly why one should be very cautious when using a Wi-Fi hotspot.
soldi70 [24.7K]

Answer: Other people can access the same network and may have access to parts of your computer to try and steel your data.

Explanation:

6 0
3 years ago
Read 2 more answers
April 107 90 29 31 66 0.344
Misha Larkins [42]

Answer:

Check the explanation

Explanation:

with open('stats. txt', 'r') as   # open the file in read mode

   list1 = []   # initialize an empty list

   for i in  . readlines ():  # read every line of file

       for j in i. split ():  # split each line by a space and append it to the list1

           list1. append (j)

   months = [] # initialize required lists to empty list

plate_apperence = []

at_bats = []

runs = []

hits = []

total_bats = []

for i in range(0, len(list1)-1, 7): # use a for loop and give parameters as start,stop and step count

months. append(list1[i]) # append list1 elements to required lists

plate_apperence. append(int(list1[i+1]))

at_bats. append(int(list1[i+2]))

runs. append(int(list1[i+3]))

hits. append(int(list1[i+4]))

total_bats. append(int(list1[i+5]))

for i in range(len(months)): # for each element in months

print("Player's Average Batting and slugging percent for the month ", months[i], " is as shown below")

print("{:.2f}".format(hits[i]/at_bats[i])) # calculate Average batting and slugging percent and print them

print("{:.2f}". format(total_bats[i]/at_bats[i]))

print("\n")

Kindly check the attached images below to get the Code Screenshot and Code Output.

3 0
3 years ago
What command is used to generate an RSA key pair?
Leokris [45]

Answer:

D) crypto key generate rsa

Explanation:

In cryptography, the RSA refers to Rivest–Shamir–Adleman. This is an algorithm used for encrypting and decrypting messages in computers thereby ensuring secured transmission of data. In order to generate an RSA key pair, you will use the command crypto key generate rsa while in the global configuration mode. This command has the following syntax:

crypto key generate rsa [general-keys| usage-keys| signature| encryption] [<em>labelkey-label</em>] [exportable] [modulus <em>modulus-size</em>] [storage <em>name of device</em>:][redundancy][on <em>name of device</em>:],

with each parameter having its description

5 0
3 years ago
Write a Perl program to accomplish each of the following on the file solar.txt (see link at the class homepage) 1. Print all rec
ryzh [129]

Answer:

see explaination

Explanation:

use strict;

use warnings;

my $filename = 'data.txt';

open(my $fh, '<:encoding(UTF-8)', $filename)

or die "Could not open file '$filename' $!";

while (my $row = <$fh>) { //Q1

chomp $row;

atfields = split(/:/, $row);

if($fields[7] eq "?" || $fields[7] eq NULL)

print "$row\n";

}

while (my $row = <$fh>) { //Q2

chomp $row;

atfields = split(/:/, $row);

print '$fields: ' , replace($fields[1],"",$fields[1]) , "\n";}

}

while (my $row = <$fh>) { //Q3

chomp $row;

atfields = split(/:/, $row);

if (index($fields[2], "-") != -1) { //Looking out for negative sign in the field

print "$row\n";

}

while (my $row = <$fh>) { //Q4

chomp $row;

atfields = split(/:/, $row);

if($fields[7] eq "Voyager2")

print "$row\n";

}

Note: replace at anywhere in the program with the at symbol

8 0
3 years ago
Other questions:
  • Alicia is a dietitian. She gives other people suggestions for nutrition. She wants to organize a large amount of data concerning
    8·2 answers
  • Complete the following statements by choosing the correct answer from the drop-down menus.
    14·1 answer
  • ________ refers to the ICT architecture, where users access software applications and information systems remotely over the Inte
    7·1 answer
  • The letters LAN stand for Area Network.
    9·2 answers
  • ELO 3.6 Which type of iSCSI name requires a registered domain name to generate a unique iSCSI identifier?
    12·1 answer
  • give the difference between functional and functional tools in the middle of to the circle give importance​
    10·1 answer
  • Difference between private and confidential data?​
    5·1 answer
  • How do I delete my Brainly account?
    6·2 answers
  • Write a program that calculates pay for either an hourly paid worker or a salaried worker Hourly paid workers are paid their hou
    8·1 answer
  • Which instructions are used to change the sequence of instruction execution? group of answer choices data movement operate contr
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!