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
Aleks [24]
2 years ago
14

10. Write a function called replace_elem that takes an array and two values and uses the simple search

Computers and Technology
1 answer:
zalisa [80]2 years ago
8 0

The function that replaces the values in an array is as follows:

def replace_elem(a, integer1, integer2):

    for i in range(len(a)):

         if a[i] == integer1:

              a[i] = integer2

    return a

print(replace_elem([7, 4, 10, 3, 7, 2, 4, 5], 4, 6))

<h3>Code explanation.</h3>

The code is written in python.

  • We defined a function named "replace_elem". The function accepts an array a, and integers integer1 and integer2.
  • Then, we used a loop to loop the index of the array.
  • If any of the index value is equals to the integer1, we replace it with integer2.
  • Then return the new values of the array a.
  • Finally, we call the function with its parameters.

learn more on function here: brainly.com/question/15691123

You might be interested in
When a user runs an application, what transfers from a storage device to memory?
jolli1 [7]
It is:
b. instructions


6 0
3 years ago
Amy would like to find all records that were delivered on August 8, 2008. Her database has a field that tracks when the items we
denpristay [2]
Conduct a query and set the criteria as = August 8, 2008. I'm not sure if this is the right answer, but that's what I think it is.
7 0
3 years ago
Read 2 more answers
What type of servers are used to store recently accessed DNS records from other domains to avoid incurring the performance overh
Kruka [31]

The correct answer is B. Primary DNS Server.

DNS records are type of data that is equivalent to IP address where the website or domain is located.  DNS records are normally stored in DNS server in a raw or flat file. A host, using port number 53 will send a DNS request to the server. If the computer has stored it's data or record in it's database, it will automatically reply to the requesting host. Example: You typed in www.website.com, if you have a matching DNS record in your server, using an IP address, your server will reply and display the website.

8 0
3 years ago
How to connect to the internet through another computer?
Yuri [45]
You go to settings , go to wifi, click on your wifi server, type in password, and your in! or if you mean like going on google, you just click an icon named google, Yahoo, msn, ect...
6 0
3 years ago
A small company is moving all its employee data to a computer. To make a smooth transition, a software program will permit the d
Llana [10]

Answer:

Explanation:

This program should hold three functions for easy usage. The first will be a main function, the second will be a check function, the third will be a write function.

Main function:

First task should be to create the file using different functions which ae different for every language, like in java the function FileOutputStream will be used to make the file and PrintWriter can be used to enter data into the aforementioned file.

FileOutputStream fout=new FileOutputStream("employees.dat");

PrintWriter pw=new PrintWriter(fout);

or

PrintWriter pw=new PrintWirter(new FileOutputStream(“employees.dat”));

What we will do next is to run a do while loop which asks for the employee ID. Then it checks whether the ID is valid or not using the check function. If is comes out to be valid, then we will send the id to the write function where the further details of the employee will be asked. If it comes out to be invalid, an error message is to be printed stating that the input is wrong. Finally, we will ask the number that whether they want to enter more data. This condition will be put in the while and it will terminate the loop once the user says no more data.

Check function:

We will take a flag variable throughout the function which will keep track whether the number is valid or not.

Firstly, we will check that the entered id is less than 10 characters long. If no, then change the flag variable to invalid.

There are 5 valid id numbers that an entered id number must contain. These 5 can be entered into the system as an array.

Then in a loop we will check that whether one of these exists as a substring of the entered number.

boolean check=false;  

//here check is the flag variable. If it remains false, it means that the entered ID is not valid.

if(length<=10)

           {

               String chch[]={"RE49762358","PR156125","OF45461","RE68566547","PR156984"};

               for(int i=0;(i<5)&&(!check);i++)

               {

                   int len1=chch[i].length();

                   for(int j=0;(j<=len-len1)&&(!check);j++)

                   {

                       String check12;

                       if(j+len+1==len)

                       check12=str.substring(j);

                       else

                       check12=str.substring(j,j+len1);

                       if(check12.equals(chch[i])){check=true;}

                   }

               }

           }

After the completion of loop, we can check return the flag variable to the main function.

Write function:

The print writer function written before shows it work here. First, we input the employee first name, last name and the employee hourly wage from the user. Do have a check statement for the hourly wage to be less than $45.50. If all conditions are fulfilled, then print all the details to the file.

pw.println(first_name);

pw.println(last_name);

pw.println(employee_id);

pw.println(hourly_wage);

pw.flush();            

7 0
3 years ago
Other questions:
  • You work in a customer call center. Martin is on the phone asking about the difference between solid-state drives (SSDs), hybrid
    6·1 answer
  • Which organization developed a network called CSNET to provide a network free to all American research and educational instituti
    15·1 answer
  • Order the following routine maintenance tasks from most to least important when securing a computer. a. Verify anti-malware sett
    15·1 answer
  • Different methods of developing useful information from large data bases are dealt with under
    13·1 answer
  • I want pizzzzzzzaaaaaaaaaaa
    9·1 answer
  • Name at least TWO kinds of gaming experiences that are possible with these new control devices but were not possible on original
    7·1 answer
  • My brainly is no hello friend , i need you can you help me, please okay
    13·2 answers
  • Need the answer ASAP!!! I’ll mark brainliest if correct
    5·1 answer
  • Compare the graphs. Find the value of h, k, or a.
    7·1 answer
  • What is the name of the device protected by a digital certificate?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!