CMPSC 206 Ch 9 Program Online shopping Cart Python Assignment

Programming

LAB

ACTIVITY

16.23.1: Ch 9 Program: Online shopping cart (continued) (Python 3)

1 / 29

main.py

Load default template…

class ItemToPurchase:

def __init__(self, item_name= ‘none’, item_price=0, item_quantity=0, item_description = ‘none’):

self.item_name = item_name

self.item_price = item_price

self.item_quantity = item_quantity

self.item_description = item_description

def print_item_cost(self):

string = ‘{} {} @ ${} = ${}’.format(self.item_name, self.item_quantity, self.item_price, (self.item_quantity

* self.item_price))

cost = self.item_quantity * self.item_price

return string, cost

def print_item_description(self):

string = ‘{}: {}’.format(self.item_name, self.item_description)

print(string, end=’ ‘)

return string

class ShoppingCart:

def __init__(self,customer_name= None ,current_date=’January 1,2016′,cart_items=[]):

self.customer_name = customer_name

self.current_date = current_date

self.cart_items = cart_items

def add_item(self,):

print(‘nADD ITEM TO CART’, end=’n’)

#prompt the name and description of item,price and Quentity

item_name = str(input(‘Enter the item name:’));

item_description = str(input(‘nEnter the item description:’));

item_price = int(input(‘nEnter the item price:’));

item_quantity = int(input(‘nEnter the item quantity:n’))

#Append the above values in to the list

self.cart_items.append(ItemToPurchase(item_name, item_price, item_quantity, item_description))

#Implement the method to delete the item in the cart

def remove_item(self):

print()

print(‘REMOVE ITEM FROM CART’, end=’n’)

#prompt the item to remove the list

string = str(input(‘Enter name of item to remove:n’))

i = 0

#Using for-loop to iterate every item

for item in self.cart_items:

#If item found delete in the list

if(item.item_name == string):

del self.cart_items[i]

i += 1

#set the flag value to true

#break from the list

flag=True

break

#Otherwiese set value to false

else:

flag=False

#IF the value not found

if(flag==False):

#print the message

print(‘Item not found in cart. Nothing removed.’)

def modify_item(self):

print(‘nCHANGE ITEM QUANTITY’, end=’n’)

#Prompt the input item

name = str(input(‘Enter the item name:’))

#Using for-loop to iterate every item

for item in self.cart_items:

#If item found update Quantity in the list

if(item.item_name == name):

quantity = int(input(‘Enter the new quantity:’))

item.item_quantity = quantity

#set the flag value to true

#break from the list

flag=True

break

#Otherwiese set value to false

else:

flag=False

#IF the value not found

if(flag==False):

#print the message

print(‘Item not found in cart. Nothing modified.’)

#implement method to compute total number of items in the cart

def get_num_items_in_cart(self):

num_items = 0

#Using for-loop to iterate the cart

for item in self.cart_items:

#ADD the Quantities

num_items += item.item_quantity

#return the num_Items

return num_items

#Implement the method

def get_cost_of_cart(self):

total_cost = 0

cost = 0

#Using for-loop to iterate the list

#mulitply the price and Quantity

#add value to the Total_Cost

for item in self.cart_items:

cost = (item.item_quantity * item.item_price)

total_cost += cost

#return the value

return total_cost

#Implement the method to print the total

def print_total():

total_cost = self.get_cost_of_cart()

if (total_cost == 0):

print(‘SHOPPING CART IS EMPTY’)

else:

output_cart()

#Implement the method to print_descriptions

def print_descriptions(self):

print(‘OUTPUT ITEMS’ DESCRIPTIONS’)

print(‘{}’s Shopping Cart – {}’.format(self.customer_name, self.current_date),end=’n’)

print(‘nItem Descriptions’, end=’n’)

for item in self.cart_items:

print(‘{}: {}’.format(item.item_name, item.item_description), end=’n’)

#Implement the method output_cart()

def output_cart(self):

new=ShoppingCart()

print(‘OUTPUT SHOPPING CART’, end=’n’)

print(‘{}’s Shopping Cart – {}’.format(self.customer_name, self.current_date),end=’n’)

print(‘Number of Items:’, new.get_num_items_in_cart(), end=’nn’)

self.total_cost = self.get_cost_of_cart()

if (self.total_cost == 0):

print(‘SHOPPING CART IS EMPTY’)

else:

pass

tc = 0

for item in self.cart_items:

print(‘{} {} @ ${} = ${}’.format(item.item_name, item.item_quantity,

item.item_price, (item.item_quantity * item.item_price)), end=’n’)

tc += (item.item_quantity * item.item_price)

print(‘nTotal: ${}’.format(tc), end=’n’)

#Implement the method print_menu

def print_menu(new_cart):

customer_Cart = newCart

string=”

#declare the string menu

menu = (‘nMENUn’

‘a – Add item to cartn’

‘r – Remove item from cartn’

‘c – Change item quantityn’

‘i – Output items’ descriptionsn’

‘o – Output shopping cartn’

‘q – Quitn’)

command = ”

#Using while loop

#to iterate until user enters q

while(command != ‘q’):

string=”

print(‘nMENUn’

‘a – Add item to cartn’

‘r – Remove item from cartn’

‘c – Change item quantityn’

‘i – Output items’ descriptionsn’

‘o – Output shopping cartn’

‘q – Quitn’, end=’n’)

#Prompt the Command

command = input(‘Choose an option:’)

print()

#repeat the loop until user enters a,i,r,c,q commands

while(command != ‘a’ and command != ‘o’ and command != ‘i’ and command != ‘r’ and command != ‘c’ and command != ‘q’):

command = input(‘Choose an option:n’)

#If the input command is a

if(command == ‘a’):

#call the method to the add elements to the cart

customer_Cart.add_item()

#If the input command is o

if(command == ‘o’):

#call the method to the display the elements in the cart

customer_Cart.output_cart()

#If the input command is i

if(command == ‘i’):

#call the method to the display the elements in the cart

customer_Cart.print_descriptions()

#If the input command is i

if(command == ‘r’):

customer_Cart.remove_item()

if(command == ‘c’):

customer_Cart.modify_item()

# Type main section of code here

if __name__ == “__main__”:

# Type main section of code here

customer_name = str(input(‘Enter customer’s name:’))

current_date = str(input(‘nEnter today’s date:’))

print()

print()

print(‘Customer name:’, customer_name, end=’n’)

print(‘Today’s date:’, current_date, end=’n’)

newCart = ShoppingCart(customer_name, current_date)

print_menu(newCart)

Develop modeSubmit mode

Run your program as often as you’d like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program’s output in the second box.

Enter program input (optional)

Paraphrase-this-paragraph-Put-it-in-your-own-words-

Paraphrase-this-paragraph-Put-it-in-your-own-words-

https://stats.stackexchange.com/questions/46185/qu…

Multiple regression can be obtained by sequential matching

Returning to the setting of the question, we have one target

y

y
and two matchers

x1

x 1
and

x2

x 2
. We seek numbers

b1

b 1
and

b2

b 2
for which

y

y
is approximated as closely as possible by

b1x1+b2x2

b 1 x 1 + b 2 x 2
, again in the least-distance sense. Arbitrarily beginning with

x1

x 1
, Mosteller & Tukey match the remaining variables

x2

x 2
and

y

y
to

x1

x 1
. Write the residuals for these matches as

x2â‹…1

x 2 â‹… 1
and

yâ‹…1

y â‹… 1
, respectively: the

â‹…1

â‹… 1
indicates that

x1

x 1
has been “taken out of” the variable.

We can write



y=λ1x1+y⋅1 and x2=λ2x1+x2⋅1.

y = λ 1 x 1 + y ⋅ 1 and x 2 = λ 2 x 1 + x 2 ⋅ 1 .

Having taken

x1

x 1
out of

x2

x 2
and

y

y
, we proceed to match the target residuals

yâ‹…1

y â‹… 1
to the matcher residuals

x2â‹…1

x 2 â‹… 1
. The final residuals are

yâ‹…12

y â‹… 12
. Algebraically, we have written



y⋅1y=λ3x2⋅1+y⋅12; whence=λ1x1+y⋅1=λ1x1+λ3x2⋅1+y⋅12=λ1x1+λ3(x2−λ2x1)+y⋅12=(λ1−λ3λ2)x1+λ3x2+y⋅12.

y ⋅ 1 = λ 3 x 2 ⋅ 1 + y ⋅ 12 ; whence y = λ 1 x 1 + y ⋅ 1 = λ 1 x 1 + λ 3 x 2 ⋅ 1 + y ⋅ 12 = λ 1 x 1 + λ 3 ( x 2 − λ 2 x 1 ) + y ⋅ 12 = ( λ 1 − λ 3 λ 2 ) x 1 + λ 3 x 2 + y ⋅ 12 .

This shows that the

λ3

λ 3
in the last step is the coefficient of

x2

x 2
in a matching of

x1

x 1
and

x2

x 2
to

y

y
.

We could just as well have proceeded by first taking

x2

x 2
out of

x1

x 1
and

y

y
, producing

x1â‹…2

x 1 â‹… 2
and

yâ‹…2

y â‹… 2
, and then taking

x1â‹…2

x 1 â‹… 2
out of

yâ‹…2

y â‹… 2
, yielding a different set of residuals

yâ‹…21

y â‹… 21
. This time, the coefficient of

x1

x 1
found in the last step–let’s call it

μ3

μ 3
–is the coefficient of

x1

x 1
in a matching of

x1

x 1
and

x2

x 2
to

y

y
.

Finally, for comparison, we might run a multiple (ordinary least squares regression) of

y

y
against

x1

x 1
and

x2

x 2
. Let those residuals be

yâ‹…lm

y â‹… l m
. It turns out that the coefficients in this multiple regression are precisely the coefficients

μ3

μ 3
and

λ3

λ 3
found previously and that all three sets of residuals,

yâ‹…12

y â‹… 12
,

yâ‹…21

y â‹… 21
, and

yâ‹…lm

y â‹… l m
, are identical.

GE-Healthcare-A-Innovating-for-Emerging-Markets

GE-Healthcare-A-Innovating-for-Emerging-Markets

Write a three to four (3-4) page paper in which you:

1.Determine two (2) emerging trends in the external environment that prompted General Electric (GE) Healthcare to develop a new strategy for the production and marketing of a low-cost Electroencephalography (EEG) machine in the bottom of the pyramid markets (BOP).

2.Examine two (2) internal barriers GE Healthcare faced when developing its BOP market in India, and determine the manner in which they hindered GE Healthcare’s growth in this market segment.

3.Analyze two (2) of the significant external barriers that GE Healthcare faced when trying to meet its marketing goals in the Indian market. Propose two (2) ways to address these barriers.

4.Analyze the specific steps GE took in developing its strategy to grow its BOP market. Determine the manner in which those actions apply to the principles of strategic thinking and strategic planning.

5.Determine the manner in which GE Healthcare’s strategy to improve its position in BOP markets contributed to the organization’s value chain in both emerging and developed markets.

What-is-the-role-of-history-in-understanding-the-military-profession-history-homework-help

What-is-the-role-of-history-in-understanding-the-military-profession-history-homework-help

  • The Course Paper will evaluate the student’s critical thought and ability to communicate clearly.
  • The paper will be typewritten as a Word document, double spaced, 12 point arial font, 1” margins
  • This is a research paper. You are encouraged to look beyond the textbook in drawing on historical sources for this paper. You must use and cite at least one primary source in your paper. In general you must use proper citation throughout the paper and include a bibliography.
  • Length: exclusive of any title pages and bibliography the paper must be no less than 5 pages.

Throughout this course we have emphasized the need to think critically and avoid the trap of using military history as a compilation of “lessons learned” that can be uniformly applied to current operations. Yet, as a military professional you will be called upon throughout your career to render opinions on current or future military topics and make some use of military history in support of your position.

Your paper will answer the question that you must resolve before offering those opinions: What is the role of history in understanding the military profession?

The answer must include at least three specific examples that invoke themes in this course (e.g. effect of technology, joint operations, limited/total war, etc.). It is acceptable, and maybe even necessary, to draw into your answer current and future events that are not covered in the text as needed to show how military history can influence understanding these issues.