Questions
Add a new function that takes a phrase as an argument and counts each unique word...

Add a new function that takes a phrase as an argument and counts each unique word in the phrase. The function should return a list of lists, where each sub-list is a unique [word, count] pair. Hint: A well-written list comprehension can solve this in a single line of code, but this approach is not required.

In: Computer Science

Write a Python function that takes two parameters: the first a list of strings and the...

Write a Python function that takes two parameters: the first a list of strings and the second a single string. The function should return True or False depending on whether the string is in the list or not. For example, if the list contains eggs, milk, bananas, and the second parameter is pumpkin, the function should return False. Thank you.

In: Computer Science

Write a Python function that takes two parameters: the first a list of strings and the...

Write a Python function that takes two parameters: the first a list of strings and the second a single string. The function should return True or False depending on whether the string is in the list or not. For example, if the list contains eggs, milk, bananas, and the second parameter is pumpkin, the function should return False. Thank you.

In: Computer Science

PYTHON Modify the program in section Ask the user for a first name and a last...

PYTHON

Modify the program in section

Ask the user for a first name and a last name of several people.

 Use a loop to ask for user input of each person’s first and last names

 Each time through the loop, use a dictionary to store the first and last names of that person

 Add that dictionary to a list to create a master list of the names

 Example dictionary:

aDict = { "fname":"Douglas", "name":"Lee" }

 Example master list, each element in the list is a dictionary:

namesList = [

{ "fname":"Douglas", "lname":"Lee" },

{ "fname":"Neil", "lname": "Armstrong" },

{ "fname":"Buzz", "lname":"Aldrin" },

{ "fname":"Eugene", "lname":"Cernan"},

{ "fname":"Harrison", "lname": "Schmitt"}

]

Pseudocode:

1) Ask for first name

2) Ask for last name

3) Create a dictionary with first name and last name

4) Add that dictionary to the master list object

5) If more names, go to (1)

6) If no more names, print the master list in a visually pleasing manner

In: Computer Science

This task has the following elements that are relevant to the learning outcomes of this module:...

This task has the following elements that are relevant to the learning outcomes of this module: - use ArrayList to save, find, insert items - convert from an array to an ArrayList - shuffle a list using your own method, sort a list You should write a simple Java class that will perform some operations on an ArrayList Create an Integer array of ten objects that you initialize with values ​​1 to 10. Convert it to an ArrayList object. Add a number Remove one of the numbers in the list. Ask the ArrayList object if it contains added value and the value that was removed. Create a method (do not use built-in shuffle methods) to put the values ​​in a random order Arrange the array list in descending order and print it. Example of printing is:

Does list contain 42? Yes 
Does list contain 9? No 

4 2 5 1 0 3 8 7 6 42 
42 8 7 6 5 4 3 2 1 0

In: Computer Science

Question 1 Please, write a loop to print even members of an array a with pointers....

Question 1

Please, write a loop to print even members of an array a with pointers. You can use a variable “size” for array size Example Input: 1,2,5,6,8,9 Output : 2,6,8 Question 6 Please, write a loop to print odd numbers an array a with pointers backwards. You can use a variable “size” for array size Example Input: 1,2,5,6,8,9 Output : 9,5,

Question2

1 LINKED LIST QUESTIONS For the following two questions you need to provide a code in C 1. Build a double linked list with 5 in the first node following the instructions: Insert node with 3 at the top of the list Insert a node with 10 at the bottom of the list Insert a node with 7 between nodes with 5 and 10 2. Start deleting nodes from the list in the following order; Delete the node with 7 Delete the node with 3 Delete the node with 10 3. Print the resulting list forward and backwards.

In: Computer Science

In python please :) How to get the n th smallest even value of given array?...

In python please :)

How to get the n th smallest even value of given array? (Use for loop for this problem. Do not use existing codes. Use your own codes). For example, in given list [11,23,58,31,56,22,43,12,65,19], if n is defined as 3. The program will print 56. (By using for loop and obtain the set of evens. By using another for loop, from the set of evens remove (n-1) observations and break the loop and find the minimum observation of the updated list). You can use the remove function to remove the observations from a list. remove function can be used as in the below example: A=[12, 41 ,5, 16,32,54 ] # List a is given # If you want to remove number 16 from the list A , You can use below code A.remove(15) # Now A=[12, 41, 5, 32, 54] # if you also want to remove 5 from the list A A.remove(5) # Now A=[12, 41, 32, 54]

In: Computer Science

JAVA PLEASE In this project, we are going to build a tiny database organized as a...

JAVA PLEASE

In this project, we are going to build a tiny database organized as a singly linked list for storing and retrieving the information of a group of products on sale. The information of each product includes the following items: Product ID, Name, Seller, Quantity In Stock, Average Shipping Time, Original Price, Current Price. We assume that a node in the linked list should be defined by the following class.

class Product

{

     long ID;

     String name;

     String seller;

     long quantityInStock;

     int averageShippingTime; // number of days

     double originalPrice;

     double currentPrice;

     // implement the constructors and methods if necessary

}

Then please implement a class ProductList for the linked list according to the following requirements. Also, you need to appropriately define the constructors and methods in the class Product.

  1. (5 points) Implementing a constructor for ProductList which creates a product list using the information provided in a file. An example is given in the attachment by the file products.txt.
  2. (5 points) Implementing a constructor for ProductList which creates a new but identical product list based on the given list.
  3. (5 points) Implementing a method in ProductList which shows (displays) the products in the list in the ascending order of the current price.
  4. (5 points) Implementing a method in ProductList which shows (displays) the products in the list in the ascending order of the discount which is calculated as

(original price - current price)/original price

You need to decide the implementation and usage of any auxiliary methods. You may decide which sorting algorithm is used in sorting a product list. Please provide a main method to show the test cases for all above items and make sure that your source code can be successfully compiled and there is no exception in the run your program.

(20 points) In this project, we are going to build a tiny database organized as a singly linked list for storing and retrieving the information of a group of products on sale. The information of each product includes the following items: Product ID, Name, Seller, Quantity In Stock, Average Shipping Time, Original Price, Current Price. We assume that a node in the linked list should be defined by the following class.

class Product

{

     long ID;

     String name;

     String seller;

     long quantityInStock;

     int averageShippingTime; // number of days

     double originalPrice;

     double currentPrice;

     // implement the constructors and methods if necessary

}

Then please implement a class ProductList for the linked list according to the following requirements. Also, you need to appropriately define the constructors and methods in the class Product.

  1. (5 points) Implementing a constructor for ProductList which creates a product list using the information provided in a file. An example is given in the attachment by the file products.txt.
  2. (5 points) Implementing a constructor for ProductList which creates a new but identical product list based on the given list.
  3. (5 points) Implementing a method in ProductList which shows (displays) the products in the list in the ascending order of the current price.
  4. (5 points) Implementing a method in ProductList which shows (displays) the products in the list in the ascending order of the discount which is calculated as

(original price - current price)/original price

You need to decide the implementation and usage of any auxiliary methods. You may decide which sorting algorithm is used in sorting a product list. Please provide a main method to show the test cases for all above items and make sure that your source code can be successfully compiled and there is no exception in the run your program.

In: Computer Science

1. List the simple events of tossing a coin three times that includes one head. 2....

1. List the simple events of tossing a coin three times that includes one head.

2. In rolling a die once, A is the event of getting odd numbers outcome. Then define the complement of A.

3. Given P(A) = 0.7, find P(Ā).

4.In rolling a die once, A is the event of getting even numbers and B is the event of getting number 5. Then P(A or B) =

5. In rolling a die twice, A is the event of getting even numbers and B is the event of getting number 5.

a. P(A and B) =

b. P(A or B) =

c. P(A/B) =

d. P(B/A) =

e. Are A and B independent or dependent events?

6. If P(A) = 0.271 and P(B) = 0.34 and P(A and B) = 0, then P(A or B) =

7. If P(A) = 0.271 and P(B) = 0.34 and P(A and B) = 0.095, are A and B independent or dependent events?

8. What is the difference between P(A/B) and P(B/A)?

9. Find the number of different possible routes to select 5 different locations from 9 that are available.

10. Find the number of different ways to arrange the letters in Kooswinarsinindyah.

11. The chance of a student skip classes on 4th July weekend is 2 out of 10. What is the probability of asking 10 students and all of them skipping classes on 4th July weekend?

In: Statistics and Probability

1. A study was created to test which brand of tire lasts longest when driving on...

1. A study was created to test which brand of tire lasts longest when driving on rough surfaces. After 5000 miles in a lab machine, the tread was measured. What type of study would this be?

A.

Observational

B.

Experimental

2. You want to determine which degree leads to a higher starting salary, creative writing or art history. You track students with these majors for the next 5 years. What type of study would this be?

A.

Observational

B.

Experimental

3. Which is an example of a simple random sample?

Multiple draws from a deck of cards without replacement

Choosing names from a hat

Surveying your neighbors

Choosing every three names from an alphabetized list

4. _________ are used to infer about __________

A.

Population parameters; sample statistics

B.

Sample statistics; population parameters

C.

Population statistics; sample parameters

D.

Sample parameters; population statistics

5. Choose all that apply. Population parameters

Are rarely known

Are estimated from sample statistics

Are calculated from samples

Can be found by sampling a large portion of the population

6. We defined our population as this class, and then collected heights of all the people in this class, and took an average. This would be an example of a

A.

Parameter

B.

Statistic

In: Statistics and Probability