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
Nataly_w [17]
2 years ago
6

Find the number of times a value appears in a list, and create a new list that contains the index positions where the value occu

rs in the list argument.
Computers and Technology
1 answer:
Maru [420]2 years ago
3 0

Answer:

Program :

list_1=[]#take the empty list.

size=int(input("Enter the size of the list: "))#take the size of the list from the user

for x in range(size): #for loop which insert the elemnt on the list.

   list_1.append(int(input("Enter the "+str(x+1)+" element of the list: ")))#take the user input and insert the element.

element=int(input("Enter the element to be searched: "))#it take the elemnt to search.

loc=1#intialize the location value.

count=0

for x in list_1:#for loop to check the element.

   if(x==element): #check the element.

       print(loc,end=", ")#print the location of the element.

       count=count+1

   loc=loc+1

if(count==0):

   print("The element is not present on the list")#print when elemnt are not present.

Output:

  • If the user input 5 for the size and 1,2,3,4,5 for the list and 5 for the element, then it will print 5.

Explanation:

  • The above code is in python language which is used to take the size for the list, then take the value to add on the list.
  • Then the element is entered from the user to search on the list.
  • Then the element is searched on the list with the help of for loop.
  • It prints the location when the element is matched.

You might be interested in
Which of the following class definition defines a legal abstract class Group of answer choices public class Rectangle abstract {
valkas [14]
<h2>Question</h2>

Which of the following class definition defines a legal abstract class Group of answer choices

(a)

public class Rectangle abstract {

   public abstract double findArea ( );

   

}

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

   

}

(c)

public class Rectangle {

   public abstract double findArea ( );

   

}

(d)

public class abstract Rectangle {

   public abstract double findArea ( );

   

}

<h2>Answer:</h2>

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

}

<h2>Explanation:</h2>

When a class is declared with the abstract keyword, the class is called an abstract class. Abstract classes cannot be instantiated and may include one or more abstract methods. If a class contains an abstract method, then it (the class) must be declared abstract.

In Java, abstract classes are defined using the following format:

<em>[access_modifier]</em> abstract class <em>[name_of_class]</em>

[access_modifier] specifies the access modifier of the class which could be public, private, e.t.c

abstract is the keyword that specifies that the class is an abstract class.

class is a keyword used for defining classes

name_of_class specifies the name of the class.

The only option that fulfils this format is <em>option b</em> where;

(i) The access modifier is public

(ii) The name of the class is Rectangle

Option a is not correct because the <em>abstract</em> keyword is supposed to come before the <em>class</em> keyword.

Option c is not correct because the keyword <em>abstract</em> is missing. In other words, the class must be declared abstract since it contains abstract method findArea();

Option d is not correct because the <em>abstract</em> keyword is supposed to come before the <em>class</em> keyword.

7 0
2 years ago
Crystal detected a problem in a computer network, due to which she could not send or receive data within the network. She pings
babymother [125]
<span>Conflict of IP address in the computers. when computer are networked each computer is given a unique IP address. If two computers have the same IP there will be conflict which lead to failure in sending and receiving data within the network. It can be resolved by checking the IP addresses of each computer and correcting it.</span>
3 0
3 years ago
Read 2 more answers
Design a class named Employee. The class should keep the following information in member variables:
Paha777 [63]

Answer:

Here is the code.

Explanation:

#include <iostream>

#include <cstdlib>

#include <string>

#include <iomanip>

using namespace std;

class Employee

{

private:

string employeeName;

int employeeNumber;

int hireDate;

public:

void setemployeeName(string employeeName);

void setemployeeNumber(int);

void sethireDate(int);

string getemployeeName() const;

int getemployeeNumber() const;

int gethireDate() const;

Employee();

};

void Employee::setemployeeName(string employeeName)

{

employeeName = employeeName;

}

void Employee::setemployeeNumber(int b)

{

employeeNumber = b;

}

void Employee::sethireDate(int d)

{

hireDate = d;

}

string Employee::getemployeeName() const

{

return employeeName;

}

int Employee::getemployeeNumber() const

{

return employeeNumber;

}

int Employee::gethireDate() const

{

return hireDate;

}

Employee::Employee()

{

cout << "Please answer some questions about your employees, ";

}

class ProductionWorker :public Employee

{

private:

int Shift;

double hourlyPay;

public:

void setShift(int);

void sethourlyPay(double);

int getShift() const;

double gethourlyPay() const;

ProductionWorker();

};

void ProductionWorker::setShift(int s)

{

Shift = s;

}

void ProductionWorker::sethourlyPay(double p)

{

hourlyPay = p;

}

int ProductionWorker::getShift() const

{

return Shift;

}

double ProductionWorker::gethourlyPay() const

{

return hourlyPay;

}

ProductionWorker::ProductionWorker()

{

cout << "Your responses will be displayed after all data has been received. "<<endl;

}

int main()

{

ProductionWorker info;

string name;

int num;

int date;

int shift;

double pay;

cout << "Please enter employee name: ";

cin >> name;

cout << "Please enter employee number: ";

cin >> num;

cout << "Please enter employee hire date using the format \n";

cout << "2 digit month, 2 digit day, 4 digit year as one number: \n";

cout << "(Example August 12 1981 = 08121981)";

cin >> date;

cout << "Which shift does the employee work: \n";

cout << "Enter 1, 2, or 3";

cin >> shift;

cout << "Please enter the employee's rate of pay: ";

cin >> pay;

info.setemployeeName(name);

info.setemployeeNumber(num);

info.sethireDate(date);

info.setShift(shift);

info.sethourlyPay(pay);

cout << "The data you entered for this employee is as follows: \n";

cout << "Name: " << info.getemployeeName() << endl;

cout << "Number: " << info.getemployeeNumber() << endl;

cout << "Hire Date: " << info.gethireDate() << endl;

cout << "Shift: " << info.getShift() << endl;

cout << setprecision(2) << fixed;

cout << "Pay Rate: " << info.gethourlyPay() << endl;

system("pause");

return 0;

}

7 0
2 years ago
Which is the best response to receiving a threating text from a classmate
Yuri [45]

Answer:

send a threatening text in reply, then block the phone number block the phone number, then contact his phone service provider immediately delete the text, then report the incident to authorities ignore the message, then get a new cell phone number.

Explanation:

5 0
2 years ago
Read 2 more answers
What is astronaut favourite key on keyboard? ​
Dennis_Churaev [7]

Answer:

The space bar is an astronauts favorite key

5 0
2 years ago
Read 2 more answers
Other questions:
  • "which part of an information system consists of the rules or guidelines for people to follow?"
    9·1 answer
  • You are asked to install a device that will combine several connections to the Internet and provide the sum of the available net
    8·2 answers
  • Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeopl
    6·1 answer
  • Review the two e-mail messages below for their adherence to the guidelines for professional e-mail correspondence you have learn
    6·1 answer
  • A newly opened law firm in Kirkland decides to create a small website that provides a brief introduction of the firm, its missio
    8·1 answer
  • List the gcc command-line options for each of the following: Generate a .o file rather than an executable. Generate a .s (assemb
    6·1 answer
  • Community gardens are public gardens where local residents can grow plants in a plot. They are very popular, so there are often
    7·1 answer
  • To obtain the desired speedup, make sure your new function recursively calls itself no more than once in the body of the method.
    8·1 answer
  • Hey, how is everyone????????????????????????????????
    8·2 answers
  • Question 1 (1 point)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!