Skip to main content

Python "yield" keyword to calculate

A bar shop has a ten-day promotion. During this period, the price of an beer drops 2010 percent each day. For example, a beer that costs 10$ on the first day costs $3$9 on the second day and $2$8.1 on the third day.

I want to write a functionpython function that uses keywordyield keyword to calculate beer price each day.

For instance if we give input 10, My expected output is:

Price is discounted to : 9

Price is discounted to : 8.1 

..etc

class DiscountCalc:
    def get_item_price(self):
        return input('Input a starting price (0 to quit): ')
    

    def discount(self, current_price, days):
        yield (current_price - (current_price*10)//100)


            
    def run(self):
        initial = self.get_item_price()
        for price in self.discount(initial, 10):
            print "Price is discounted to : " + str(price)

DiscountCalc().run()

Python calculate

A bar shop has a ten-day promotion. During this period, the price of an beer drops 20 percent each day. For example, a beer that costs 10$ on the first day costs $3 on the second day and $2.1 on the third day.

I want to write a function that uses keyword to calculate beer price each day.

Python "yield" keyword to calculate

A bar shop has a ten-day promotion. During this period, the price of an beer drops 10 percent each day. For example, a beer that costs 10$ on the first day costs $9 on the second day and $8.1 on the third day.

I want to write a python function that uses yield keyword to calculate beer price each day.

For instance if we give input 10, My expected output is:

Price is discounted to : 9

Price is discounted to : 8.1 

..etc

class DiscountCalc:
    def get_item_price(self):
        return input('Input a starting price (0 to quit): ')
    

    def discount(self, current_price, days):
        yield (current_price - (current_price*10)//100)


            
    def run(self):
        initial = self.get_item_price()
        for price in self.discount(initial, 10):
            print "Price is discounted to : " + str(price)

DiscountCalc().run()
deleted 641 characters in body
Source Link
Alice
  • 11
  • 4

Python "yield" keyword to calculate

A bar shop has a ten-day promotion. During this period, the price of an beer drops 1020 percent each day. For example, a beer that costs 10$ on the first day costs $9$3 on the second day and $8$2.1 on the third day.

I want to write a python function function that uses yield keyword keyword to calculate beer price each day.

For instance if we give input 10, My expected output is:

Price is discounted to : 9

Price is discounted to : 8.1 

..etc

class DiscountCalc:
    def get_item_price(self):
        return input('Input a starting price (0 to quit): ')
    

    def discount(self, current_price, days):
        yield (current_price - (current_price*10)//100)


            
    def run(self):
        initial = self.get_item_price()
        for price in self.discount(initial, 10):
            print "Price is discounted to : " + str(price)

DiscountCalc().run()

Python "yield" keyword to calculate

A bar shop has a ten-day promotion. During this period, the price of an beer drops 10 percent each day. For example, a beer that costs 10$ on the first day costs $9 on the second day and $8.1 on the third day.

I want to write a python function that uses yield keyword to calculate beer price each day.

For instance if we give input 10, My expected output is:

Price is discounted to : 9

Price is discounted to : 8.1 

..etc

class DiscountCalc:
    def get_item_price(self):
        return input('Input a starting price (0 to quit): ')
    

    def discount(self, current_price, days):
        yield (current_price - (current_price*10)//100)


            
    def run(self):
        initial = self.get_item_price()
        for price in self.discount(initial, 10):
            print "Price is discounted to : " + str(price)

DiscountCalc().run()

Python calculate

A bar shop has a ten-day promotion. During this period, the price of an beer drops 20 percent each day. For example, a beer that costs 10$ on the first day costs $3 on the second day and $2.1 on the third day.

I want to write a function that uses keyword to calculate beer price each day.

added 63 characters in body
Source Link
Alice
  • 11
  • 4

A bar shop has a ten-day promotion. During this period, the price of an beer drops 10 percent each day. For example, a beer that costs 10$ on the first day costs $9 on the second day and $8.1 on the third day.

I want to write a python function that uses yield keyword to calculate beer price each day.

For instance if we give input 10, My expected output is:

Price is discounted to : 9

Price is discounted to : 8.1 

..etc

class DiscountCalc:
    def get_item_price(self):
        return input('Input a starting price (0 to quit): ')
    

    def discount(self, current_price, days):
        yield (current_price - (current_price*10)//100)


            
    def run(self):
        initial = self.get_item_price()
        for price in self.discount(initial, 10):
            print "Price is discounted to : " + str(price)

DiscountCalc().run()

A bar shop has a ten-day promotion. During this period, the price of an beer drops 10 percent each day. For example, a beer that costs 10$ on the first day costs $9 on the second day and $8.1 on the third day.

I want to write a python function that uses yield keyword to calculate beer price each day.

For instance if we give input 10, My expected output is:

Price is discounted to : 9

Price is discounted to : 8.1 

..etc

class DiscountCalc:
    def get_item_price(self):
        return input('Input a starting price (0 to quit): ')
    

    def discount(self, current_price, days):

            
    def run(self):
        initial = self.get_item_price()
        for price in self.discount(initial, 10):
            print "Price is discounted to : " + str(price)

DiscountCalc().run()

A bar shop has a ten-day promotion. During this period, the price of an beer drops 10 percent each day. For example, a beer that costs 10$ on the first day costs $9 on the second day and $8.1 on the third day.

I want to write a python function that uses yield keyword to calculate beer price each day.

For instance if we give input 10, My expected output is:

Price is discounted to : 9

Price is discounted to : 8.1 

..etc

class DiscountCalc:
    def get_item_price(self):
        return input('Input a starting price (0 to quit): ')
    

    def discount(self, current_price, days):
        yield (current_price - (current_price*10)//100)


            
    def run(self):
        initial = self.get_item_price()
        for price in self.discount(initial, 10):
            print "Price is discounted to : " + str(price)

DiscountCalc().run()
Source Link
Alice
  • 11
  • 4
Loading