Questions
Write a Python program that performs the following list operations. Part A Define a list called...

Write a Python program that performs the following list operations.

Part A

  1. Define a list called numList with elements.

84, 94, 27, 74, 19, 90, 16, 21, 56, 50, 77, 59, 41, 63, 18, 26, 80, 74, 57, 30, 40, 93, 70, 28, 14, 11, 43,65, 91, 83, 22, 53, 74, 44, 73, 55, 47, 74, 81

  1. Display the followings:
    • All the numbers in numList
    • The number of elements in numList
    • The smallest number in numList
    • The largest number in numList
    • The sum of all the numbers in numList
    • The number of times 74 appears in numList

Part B

  1. Define an empty list called dogNames and display it.

  2. Add the following names to dogNames and display all the names in the dogNames list.

Max, Lola, Buddy, Coco, Teddy

  1. Display all the names in the dogNames list after each of the following updates.

    • Add the name ‘Benji’ at the end of the dogNames list.
    • Add the name ‘Chico’ at the beginning of the dogNames list (as the first element).
    • Add the name ‘Nala’ after the name ‘Coco’.
    • Add the name ‘Mimi’ before the name ‘Buddy’.
  2. Define another list called catNames with elements and display all the names in catNames list.

Kitty, Simba, Shadow, Coco, Pepper, Tiger

  1. Create a new list called petNames by joining the dogNames and catName list. Note that in petNames list, all the dog names come before the cat names. Display all the names in petNames list.

  2. Display the followings using petNames list.

    • The total number of names in petNames.
    • The number of times the name ‘Coco’ appears in petNames.
    • The index of the pet name ‘Coco’ in petNames.
    • The first pet name that appears in chronological order based on Unicode. Hint:Use min function.
    • The last pet name that appears in chronological order based on Unicode. Hint: Use max function.
  3. Delete the last name in petNames list and display both the deleted name and the updated petName list.

  4. Delete the first name in petNames list and display both the deleted name and the updated petName list.

  5. Delete the first occurrence of the pet name ‘Coco’ using the remove() method and the deleted name and the updated petName list.

  6. In a comment, explain the reason to get None as the deleted name in your output for part 9.

In: Computer Science

In a program, write a function that accepts two arguments: a list, and a number n....

In a program, write a function that accepts two arguments: a list, and a number n. Assume

that the list contains numbers. The function should display all of the numbers in the list that

are greater than the number n.

The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or c).

In: Computer Science

1) List 5 items excluded from Gross Income. 2) List 5 items included in Gross Income....

1) List 5 items excluded from Gross Income.

2) List 5 items included in Gross Income.

3) List the five filing statuses taxpayers may use when filing a return.

4) List the requirements to meet the Head-of-Household filing status.

5) List the components of the Individual Tax Formula (Hint: Starts with Income and ends with Tax Due (or refund)

In: Accounting

Write an algorithm for a function named finder that recursively goes through a list and returns...

Write an algorithm for a function named finder that recursively goes through a list and returns the index of the first occurrence of an item of interest. The function takes three parameters: 1. The first position in the list (or 0) 2. The list we want to iterate over 3. The item we want to find. If the item is not there in the list and we have iterated over the whole list, then the function should return 0.

In: Computer Science

The intersection of two lists L1 and L2, L1 ∩ L2, is defined as the list...

The intersection of two lists L1 and L2, L1 ∩ L2, is defined as the list containing elements in both L1 and L2 only. Given two sorted lists L1 and L2, write a function, called intersection, to compute L1 ∩ L2 using only the basic list operations. The intersection function is defined as follows template list intersection( const list & L1, const list & L2);

C++

In: Computer Science

C++ (With main to test) 2.2 Task 1 You are going to implement a variant of...

C++ (With main to test)

2.2
Task 1
You are going to implement a variant of the standard linked list, the doubly linked list.
Doubly linked lists are because they enable a backwards and forwards traversal of the
list through the addition of more pointers. By increasing the memory cost of the list, it
enables a better access since the list does not need to be traversed in only one direction.
This will consist of implementing two classes: dLL and item.


2.2.1
dLL
The class is described according to the simple UML diagram below:
2dLL<T>
-head: item<T>*
-tail: item<T>*
-size: int
----------------------------
+dLL()
+~dLL()
+getHead(): item<T>*
+getTail(): item<T>*
+push(newItem:item<T>*):void
+pop():item<T>*
+peek():item<T>*
+getItem(i:):item<T> *
+maxNode():T
+getSize():int
+printList():void
The class variables are as follows:
• head: The head pointer of the doubly linked list.
• tail: The tail pointer of the doubly linked list.
• size: The current size of the doubly linked list. This starts at 0 and increases as the
list grows in size.
The class methods are as follows:
• dLL: The class constructor. It starts by setting the variables to null and 0 respec-
tively.
• ∼dLL: The class destructor. It will deallocate all of the memory in the class.
• getHead: This returns the head pointer of the doubly linked list.
• getTail: This returns the tail pointer of the doubly linked list.
• push: This adds a new item to the doubly linked list, by adding it to the front of
the list. The push should add to the front, which refers to the head pointer.
• pop: This returns the top item of the linked list. The item is returned and removed
from the list.
• peek: This returns the top item of the linked list but without removing it from the
list.
• getItem: This returns the item of the linked list at the index specified by the
argument but without removing it from the list. If the index is out of bounds,
return null. Use 0-indexing for the get item. That is, indices start at 0.
• maxNode: This returns the value of the item that has the highest value in the linked
list.
3• getSize: This returns the current size of the linked list.
• printList: This prints out the entire list in order, from head to tail. Each item’s
data value is separate by a comma. For example: 3.1,5,26.6,17.3. Afterwards, print
out a newline.
2.2.2
item
The class is described according to the simple UML diagram below:
item <T>
-data:T
-------------------
+item(t:T)
+~item()
+next: item*
+prev: item*
+getData():T
The class has the following variables:
• data: A template variable that stores some piece of information.
• next: A pointer of item type to the next item in the linked list.
• prev: A pointer of item type to the previous item in the linked list.
The class has the following methods:
• item: This constructor receives an argument and instantiates the data variable with
it.
• ∼item: This is the destructor for the item class. It prints out ”Item Deleted” with
no quotation marks and a new line at the end.
• getData: This returns the data element stored in the item.


You will be allowed to use the following libraries: cstdlib,string,iostream.

In: Computer Science

programming in python Design a program that initializes a list of 5 items to zero (use...

programming in python

Design a program that initializes a list of 5 items to zero (use repetition operator). It then updates that list with a series of 5 random numbers. The program should find and display the following data:

-The lowest number in the list

- Average of the numbers stored in the list

In: Computer Science

In python: implement a singly linked list with following functions: - add_head(e) - add_tail(e) - find_3rd_to_last()...

In python:

implement a singly linked list with following functions:

- add_head(e)

- add_tail(e)

- find_3rd_to_last() - returns element located at third-to-last in the list

- reverse() - reveres the linked list, note, this is not just printing elements in reverse order, this is actually reversing the list

In: Computer Science

What are the “weapons of competition” that rival companies in ride-sharing industry can use to gain...

What are the “weapons of competition” that rival companies in ride-sharing industry can use to gain sales and market share? See Table 3.2 to help you identify the various competitive factors. (the company is UBER)

Types of Competitive Weapons

Primary Effects


Discounting prices, holding clearance sales


Lowers price (P), increases total sales volume and market share, lowers profits if price cuts are not offset by large increases in sales volume

Offering coupons, advertising items on sale


Increases sales volume and total revenues, lowers price (P), increases unit costs (C), may lower profit margins per unit sold (P − C)

Advertising product or service characteristics, using ads to enhance a company’s image


Boosts buyer demand, increases product differentiation and perceived value (V), increases total sales volume and market share, but may increase unit costs (C) and lower profit margins per unit sold

Innovating to improve product performance and quality



Increases product differentiation and value (V), boosts buyer demand, boosts total sales volume, likely to increase unit costs (C)

Introducing new or improved features, increasing the number of styles to provide greater product selection


Increases product differentiation and value (V), strengthens buyer demand, boosts total sales volume and market share, likely to increase unit costs (C)

Increasing customization of product or service


Increases product differentiation and value (V), increases buyer switching costs, boosts total sales volume, often increases unit costs (C)

Building a bigger, better dealer network


Broadens access to buyers, boosts total sales volume and market share, may increase unit costs (C)

Improving warranties, offering low-interest financing


Increases product differentiation and value (V), increases unit costs (C), increases buyer switching costs, boosts total sales volume and market share

In: Economics

For a school, the principal expected that a student takes 45 minutes to travel to school...

For a school, the principal expected that a student takes 45 minutes to travel to school on average. Suppose the time taken to travel to school by a student follows a normal distribution. 100 students are randomly selected from the school for interview and they took on average 44 minutes to travel to school with a standard deviation of 15 minutes. 6 of the selected students had lateness record in the last month.

  1. How large a sample is required to ensure the estimate of p is accurate within 2% with a confidence level of 97%?
  2. By using critical value approach to perform a hypothesis testing for the principal’s claim that under (10 of all students had lateness record in the last month at level of significant α = 0.01. Correct the test statistics to 2 decimal places.

In: Statistics and Probability