Questions
Create a python program that will: prompt a user for a command Command get_data Level 1:...

Create a python program that will:

  • prompt a user for a command

  • Command

    • get_data

  • Level 1: Take one of the commands

    • my_max

    • my_min

    • my_range

    • my_sum

    • mean

    • median

    • mode
    • fib
    • factorize
    • prime

Requirements:

  • Your commands should be case-insensitive

  • You should use python lists to store data

  • You should NOT use built-in python math functions, or math libraries to compute these values

Tips:

  • Write one function that will convert a string with comma-separated numbers into a python list with the numbers. You can use this in multiple other functions.

  • Don't name any of your functions "min", "max", or "range" or "sum". These are built-in functions.




Details

Load command details

  • Get_data: prompts users for a list of numbers, separated by commas

    • (please also print the list, for testing)

Level 1 details (these functions work with the loaded data list)

  • my_max

  • my_min

  • my_range: Computes the range (difference of greatest value and least value)

  • my_sum

  • mean: Computes and prints the arithmetic mean (average)

Level 2

  • median: show the median (middle value, or average of two middle values)

  • mode: show the mode, or modes

Level 3 details (these functions should use the first number in the data list)

  • prime: determine if a number is prime

  • factorize: get the prime factors of a number

  • fib: get the nth number in the fibonacci sequence

Here is my code so far:

#hehe my sum and stuff
f = open("input.txt",'r')
def input(prompt=''):
print(prompt, end='')
return f.readline().strip()   

#get data
def get_data():
pass

line = input().strip().split(',')
  
nums=[]
for n in line:
nums.append(float(n))

  
return nums
  
#get sum
def my_sum(data):
  
s=0
for n in data:
s += n
return s
  
pass

#get max
def my_max(data):
  
m=0
for n in data:
m >= n
return m

pass

#get min
def my_min(data):
  
i=0
for n in data:
i < n
return i

pass

#get range
def my_range(data):
r=0
for n in data:
m - i
return r

pass

#get mean
def mean(data):
e=0
for n in data:
????????

#get median
def median(data):
d=0
for n in data:
??????
  
#get mode
def mode(data):
o=0
for n in data:
???
  
#get prime
def prime(data):
p=0
for n in data:
???

#get factorization
def factorization(data):
f=0
for n in data:
????
  
#get fib
def fib(data):
b=0
for n in data:
??
#run it
def run_cli():
  
while(1):
cmd = input()
  
if cmd=='exit':
break
  
elif cmd=='get_data':
data = get_data()
print(data)
  
  
elif cmd=='my_sum':
s = my_sum(data)
print(s)
  
elif cmd=='my_max':
m = my_max(data)
print(m)
  
elif cmd=='my_min':
i = my_min(data)
print(i)
  
elif cmd=='my_range':
r = my_range(data)
print(r)
  
elif cmd=='mean':
e = mean(data)
print(e)
  
elif cmd=='median':
d = median(data)
print(d)
  
elif cmd=='mode':
o = mode(data)
print(o)
  
elif cmd=='prime':
p = prime(data)
print(p)
  
elif cmd=='factorization':
f = factorization(data)
print(f)
  
elif cmd=='fib':
b = fib(data)
print(b)
  
pass

#ha ahsbas
def main():
run_cli()
  
main()

In: Computer Science

Introduction Introduction to Data Structures programming assignments can be completed either in C++ (preferred) or in...

Introduction

Introduction to Data Structures programming assignments can be completed either in C++ (preferred) or in Java. In both cases you cannot use libraries or packages that contain pre-built data structures, other than built-in support for objects, arrays, references, and pointers.

Classes in C++ and Java can represent anything in the real world. This assignment is to write a compiler for Z++ programming language.

The Z++ Programming Language

Your program will test if an expression entered by the application user is valid under the Z++ programming language. Therefore, you need to know a little bit about the Z++ programming language (which of course doesn't really exist, not yet anyway).

The Z++ programming language uses only 6 characters, left and right brackets, parentheses and curly braces: { [ ( } ] ). A left curly brace, bracket or parentheses is referred to as a left character. A right curly brace, bracket or parentheses is referred to as a right character.

A Z++ expression is valid if each left character in the expression "matches" with a corresponding right character in the expression. The test for a match requires going left to right through an expression, character by character. When a right character is encountered, then it is compared to the rightmost left character that was not previously compared to a right character. If the characters match, such as { and }, [and ], or ( and ), then you continue through the expression, comparing each right character to the rightmost left character that was not previously compared to a right character, until either the left and right characters don't match (which means the expression is not valid) or there are no more right characters. When there are no more right characters, if all of the left characters have previously been compared to a right character, the expression is valid. However, if there still are left characters that have not previously been compared to a right character, the expression is invalid.

Let's look at some examples. The following expressions are valid:

[]{}()

{([])}

()[{}]

[{}()]

Note that the matching may be by the right character immediately following the left character, by nesting, or by a combination of the two.

However, the expression [({})) is not valid as [ does not correspond to ). Additionally, the expression ([{}()] is not valid. Even though each right character is matched by a left character, the first left character is left over after you have run out of right characters.

Program Description

Your program, which will be written in C++, not Z++, will prompt the user to enter a string of not more than 20 characters. You may use a character array, a C-string or the C++ string class; the choice is up to you. You can assume the user enters no more than 20 characters (though the user may enter less than 20 characters) and the characters entered are limited to left and right brackets, parentheses and curly braces; you do not need to do any error-checking on this. After the user ends input, by the Enter key, the program checks if the string is a valid Z++ expression, and reports that it either is or isn't. Sample outputs:

Enter an expression: []{}()

It's a valid expression

Enter an expression: ()[{}]

It's a valid expression

Enter an expression: [({)}]

It's NOT a valid expression

Stack Class

Module #3 (http://www.agazaryan.com/csit836/stack.html), which accompanies this assignment, explains a stack and how it will be represented by a class having the member variables and member functions (including a constructor) appropriate for a stack.

Multiple Files

The class will be written using header and implementation files. Your program also will include a driver file, so your multi-file project will have three files:

File Name Purpose
cstack.h Header file for stack
cstack.cpp Implementation file for stack
test.cpp Driver file

Module #3 (http://www.agazaryan.com/csit836/stack.html) gives you the test.cpp file and all the information necessary to write the cstack.h file. Your job is to write the cstack.cpp file. All class members (variables and functions) must be private unless they need to be public.

In: Computer Science

Calculate the unit product cost under absorption costing using the following information.

Calculate the unit product cost under absorption costing using the following information.

Direct materials: $50/unit

Direct labor: $75/Unit

Variable manufacturing overhead:$27/Unit

Fixed manufacturing overhead: $30,000

Units produced: 10,000

Units sold: 6,000

In: Accounting

What is the profit maximizing level of output for a firm with the marginal cost function MC

What is the profit maximizing level of output for a firm with the marginal cost function MC = 1.6Q2-15Q+60 and a marginal revenue function MR = 280-20Q?

In: Economics

According to the Ending Inventory Report, how would you calculate the cost of Sales?

According to the Ending Inventory Report, how would you calculate the cost of Sales? 

Ending Inventory Report 

Administrative Salaries $100,000
Amortization Expense $20,000
Beginning Inventory $75,000
Ending Inventory $60,000
Office Supplies Expense $25,000
Purchases $125,000
Travel & Entertainment Expense $5,000

A.) $75,000 + 125,000 - $60,000

B.) $125,000 - $20,000

C.) $75,000 + 125,000 - $60,000 + $20,000

D.) $75,000 - $60,000

E.) $75,000 + 125,000 - $60,000 - $20,000

 

In: Accounting

Answer the following questions: a. In comparing a health care system to a cost center, Neel...

Answer the following questions: a. In comparing a health care system to a cost center, Neel says, “The way to protect our margins is to figure out where the waste is — and get rid of it.” b. What role do patients play in determining cost and quality in health care? c. What public policies can reduce overuse? d. How might you identify waste where you work? Describe a time when you witnessed medical care that you thought was unnecessary. What was done to mitigate it?

In: Nursing

1) A bank with a leverage ratio of 20 has a cost of debt of 1.5%pa...

1) A bank with a leverage ratio of 20 has a cost of debt of 1.5%pa and a portfolio of assets with an expected yield of 3.5%pa. What are the expected ROA net of debt funding costs and the expected ROE of the bank, using the approach to defining leverage taken in the lecture slides? Show your workings. (2 marks)

2) What will the ROA and ROE actually be if the yield on assets turns out to be 3%? Show your workings. (1 mark)

3) What will the ROA and ROE actually be if the yield on assets turns out to be 1%? Show your workings. (2 marks)

In: Finance

McNabb Construction Company is trying to calculate its cost ofcapital for use in making a...

McNabb Construction Company is trying to calculate its cost of capital for use in making a capital budgeting decision. Mr. Reid, the vice-president of finance, has given you the following information and has asked you to compute the weighted average cost of capital.

The company currently has an outstanding bond with a 9.5 percent coupon rate and another bond with a 7.8 percent rate. The firm has been informed by its investment dealer that bonds of equal risk and credit ratings are now selling to yield 10.5 percent. The common stock has a price of $98.44 and an expected dividend(D1) of $3.15 per share. The historical growth pattern (g) for dividends is as follows:

   




$2.00

2.24

2.51

2.81

The preferred stock is selling at $90 per share and pays a dividend of $8.50 per share. The corporate tax rate is 30 percent. The flotation cost is 2 percent of the selling price for preferred stock. The optimum capital structure for the firm is 30 percent debt, 10 percent preferred stock, and 60 percent common equity in the form of retained earnings.

a. Compute the historical growth rate.(Round your intermediate calculations to 2 decimal places. Round the final to 2 decimal places.)

b. Compute the cost of capital for the individual components in the capital structure. (Round growth rate to nearest whole number. Round the final answers to 2 decimal places.)

Debt (Kd)7.35 7.35 Correct %
  Preferred stock (Kp)9.64 9.64 Correct    
  Common equity (Ke

c. Calculate the weighted cost of each source of capital and the weighted average cost of capital. (Round your intermediate calculations to 2 decimal places. Round the final answers to 2 decimal places.)

Debt (Kd)2.21 2.21 Correct %
  Preferred stock (Kp)0.96 0.96 Correct    
  Common equity (Ke)7.32 7.32 Incorrect  


  Weighted average cost of capital(Ka)10.49 10.49 Incorrect %

In: Finance

An unlevered firm has a cost of capital of 13.6 percent and earnings before interest and...

An unlevered firm has a cost of capital of 13.6 percent and earnings before interest and taxes of $138,000. A levered firm with the same operations and assets has both a book value and a face value of debt of $520,000 with an annual coupon of 7 percent. The applicable tax rate is 21 percent. What is the value of the levered firm? Multiple Choice

$996,421

$907,679

$1,184,929

$910,818

$1,191,506

In: Finance

A-Rod Manufacturing Company is trying to calculate its cost ofcapital for use in making a...

A-Rod Manufacturing Company is trying to calculate its cost of capital for use in making a capital budgeting decision. Mr. Jeter, the vice-president of finance, has given you the following information and has asked you to compute the weighted average cost of capital.

The company currently has outstanding a bond with a 11.0 percent coupon rate and another bond with an 8.6 percent rate. The firm has been informed by its investment banker that bonds of equal risk and credit rating are now selling to yield 11.9 percent. The common stock has a price of $64 and an expected dividend (D1) of $1.84 per share. The historical growth pattern (g) for dividends is as follows:



$1.39

1.53

1.68

1.84


The preferred stock is selling at $84 per share and pays a dividend of $8.00 per share. The corporate tax rate is 30 percent. The flotation cost is 3.0 percent of the selling price for preferred stock. The optimum capital structure for the firm is 25 percent debt, 20 percent preferred stock, and 55 percent common equity in the form of retained earnings.


a. Compute the average historical growth rate.(Do not round intermediate calculations. Round your answer to the nearest whole percent and use this value as g. Input your answer as a whole percent.)

b. Compute the cost of capital for the individual components in the capital structure. (Use the rounded whole percent computed in part a for g. Do not round any other intermediate calculations. Input your answers as a percent rounded to 2 decimal places.)

c. Calculate the weighted cost of each source of capital and the weighted average cost of capital. (Do not round intermediate calculations. Input your answers as a percent rounded to 2 decimal places.)

In: Finance