```python
def double(x):
    print(x*2)
```


```python
double(4)
```

    8



```python
def double(x):
    return x*2
```


```python
a = double(4)
print(a)
```

    8



```python
def yourFunction(x):
    for y in range(2,11):
        print(x*y)
yourFunction(5)
```

    10
    15
    20
    25
    30
    35
    40
    45
    50



```python
import sympy
p = sympy.Symbol("p")
```


```python
import sympy
import matplotlib.pyplot as plt
p = sympy.Symbol("p")
def Equilibrium(demandEquation,supplyEquation,priceStart,priceEnd):
    prices = []
    demandQ = []
    supplyQ = []
```


```python
import sympy
import matplotlib.pyplot as plt
p = sympy.Symbol("p")
def Equilibrium(demandEquation,supplyEquation,priceStart,priceEnd):
    prices = []
    demandQ = []
    supplyQ = []
    for price in range(priceStart,priceEnd+1):
        prices += [price]
        demandQ += [demandEquation.subs(p,price)]
        supplyQ += [supplyEquation.subs(p,price)]
    print(prices)
    print(demandQ)
    print(supplyQ)
```


```python
Equilibrium(10-p,p,0,10)
```

    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]



```python
import sympy
import matplotlib.pyplot as plt
p = sympy.Symbol("p")
def Equilibrium(demandEquation,supplyEquation,priceStart,priceEnd):
    prices = []
    demandQ = []
    supplyQ = []
    for price in range(priceStart,priceEnd+1):
        prices += [price]
        demandQ += [demandEquation.subs(p,price)]
        supplyQ += [supplyEquation.subs(p,price)]
    
    equilibriumP = sympy.solve(demandEquation-supplyEquation)[0]
    equilibriumQ = demandEquation.subs(p,equilibriumP)
    print(equilibriumP)
    print(equilibriumQ)
```


```python
Equilibrium(10-p,p,0,10)
```

    5
    5



```python
import sympy
import matplotlib.pyplot as plt
p = sympy.Symbol("p")
def Equilibrium(demandEquation,supplyEquation,priceStart,priceEnd):
    prices = []
    demandQ = []
    supplyQ = []
    for price in range(priceStart,priceEnd+1):
        prices += [price]
        demandQ += [demandEquation.subs(p,price)]
        supplyQ += [supplyEquation.subs(p,price)]
    
    equilibriumP = sympy.solve(demandEquation-supplyEquation)[0]
    equilibriumQ = demandEquation.subs(p,equilibriumP)
    
    plt.plot(demandQ,prices)
    plt.plot(supplyQ,prices)
    plt.legend(["Demand","Supply"])
    plt.plot(equilibriumQ,equilibriumP, 'ro')
    plt.xlabel("Supply and Demand Quantity")
    plt.ylabel("Price")
    plt.show()
    print("The equilibrium price is "+str(equilibriumP)+" and equilibrium quantity is "+str(equilibriumQ)+".")
```


```python
Equilibrium(10-p,p,0,10)
```


```python
import sympy as sy
import matplotlib.pyplot as plt
p = sy.Symbol("p")

def demandShift(demandEquation1,demandEquation2,supplyEquation,priceStart,priceEnd):
    prices = []
    demandQ1 = []
    demandQ2 = []
    supplyQ = []
    for price in range(priceStart,priceEnd+1):
        prices += [price]
        demandQ1 += [demandEquation1.subs(p,price)]
        demandQ2 += [demandEquation2.subs(p,price)]
        supplyQ += [supplyEquation.subs(p,price)]

    equilibriumP1 = sy.solve(demandEquation1-supplyEquation)[0]
    equilibriumQ1 = demandEquation1.subs(p,equilibriumP1)
    equilibriumP2 = sy.solve(demandEquation2-supplyEquation)[0]
    equilibriumQ2 = demandEquation2.subs(p,equilibriumP2)
    
    
    plt.plot(demandQ1,prices)
    plt.plot(demandQ2,prices)
    plt.plot(supplyQ,prices)
    plt.legend(["Old Demand","New Demand","Supply"])
    plt.plot(equilibriumQ1,equilibriumP1, 'ro')
    plt.plot(equilibriumQ2,equilibriumP2, 'ro')
    plt.xlabel("Supply and Demand Quantity")
    plt.ylabel("Price")
    plt.show()
    print("The old equilibrium price is "+str(equilibriumP1)+" and old equilibrium quantity is "+str(equilibriumQ1)+".")
    print("The new equilibrium price is "+str(equilibriumP2)+" and new equilibrium quantity is "+str(equilibriumQ2)+".")
    print("The price shifted "+str(equilibriumP2-equilibriumP1)+" and the quantity shifted "+str(equilibriumQ2-equilibriumQ1)+".")
```


```python
demandShift(10-p,15-p,p,0,10)
```


```python
def supplyShift(demandEquation,supplyEquation1,supplyEquation2,priceStart,priceEnd):
    prices = []
    demandQ = []
    supplyQ1 = []
    supplyQ2 = []
    for price in range(priceStart,priceEnd+1):
        prices += [price]
        demandQ += [demandEquation.subs(p,price)]
        supplyQ1 += [supplyEquation1.subs(p,price)]
        supplyQ2 += [supplyEquation2.subs(p,price)]

    equilibriumP1 = sy.solve(demandEquation-supplyEquation1)[0]
    equilibriumQ1 = demandEquation.subs(p,equilibriumP1)
    equilibriumP2 = sy.solve(demandEquation-supplyEquation2)[0]
    equilibriumQ2 = demandEquation.subs(p,equilibriumP2)
    
    
    plt.plot(demandQ,prices)
    plt.plot(supplyQ1,prices)
    plt.plot(supplyQ2,prices)
    plt.legend(["Old Demand","Old Supply","New Supply"])
    plt.plot(equilibriumQ1,equilibriumP1, 'ro')
    plt.plot(equilibriumQ2,equilibriumP2, 'ro')
    plt.xlabel("Supply and Demand Quantity")
    plt.ylabel("Price")
    plt.show()
    print("The old equilibrium price is "+str(equilibriumP1)+" and old equilibrium quantity is "+str(equilibriumQ1)+".")
    print("The new equilibrium price is "+str(equilibriumP2)+" and new equilibrium quantity is "+str(equilibriumQ2)+".")
    print("The price shifted "+str(equilibriumP2-equilibriumP1)+" and the quantity shifted "+str(equilibriumQ2-equilibriumQ1)+".")
```


```python
supplyShift(10-p,p,2*p,0,10)
```


```python
def dualShift(demandEquation1,demandEquation2,supplyEquation1,supplyEquation2,priceStart,priceEnd):
    prices = []
    demandQ1 = []
    demandQ2 = []
    supplyQ1 = []
    supplyQ2 = []
    for price in range(priceStart,priceEnd+1):
        prices += [price]
        demandQ1 += [demandEquation1.subs(p,price)]
        demandQ2 += [demandEquation2.subs(p,price)]
        supplyQ1 += [supplyEquation1.subs(p,price)]
        supplyQ2 += [supplyEquation2.subs(p,price)]

    equilibriumP1 = sy.solve(demandEquation1-supplyEquation1)[0]
    equilibriumQ1 = demandEquation1.subs(p,equilibriumP1)
    equilibriumP2 = sy.solve(demandEquation2-supplyEquation2)[0]
    equilibriumQ2 = demandEquation2.subs(p,equilibriumP2)
    
    
    plt.plot(demandQ1,prices)
    plt.plot(demandQ2,prices)
    plt.plot(supplyQ1,prices)
    plt.plot(supplyQ2,prices)
    plt.legend(["Old Demand","New Demand","Old Supply","New Supply"])
    plt.plot(equilibriumQ1,equilibriumP1, 'ro')
    plt.plot(equilibriumQ2,equilibriumP2, 'ro')
    plt.xlabel("Supply and Demand Quantity")
    plt.ylabel("Price")
    plt.show()
    print("The old equilibrium price is "+str(equilibriumP1)+" and old equilibrium quantity is "+str(equilibriumQ1)+".")
    print("The new equilibrium price is "+str(equilibriumP2)+" and new equilibrium quantity is "+str(equilibriumQ2)+".")
    print("The price shifted "+str(equilibriumP2-equilibriumP1)+" and the quantity shifted "+str(equilibriumQ2-equilibriumQ1)+".")
```


```python
dualShift(10-p,15-p,p,2*p,0,10)
```

fef5613d176e6fb29bc9586855ff734f0545c22b
ipynb
Jupyter Notebook
FinanceAndPython.com-EconomicFoundations-master/7 Curve Movements.ipynb
ds-modules/IAS-106
8fb0344c9dd112e79c535d86f12c1b0000be5041
MIT
FinanceAndPython.com-EconomicFoundations-master/7 Curve Movements.ipynb
ds-modules/IAS-106
8fb0344c9dd112e79c535d86f12c1b0000be5041
MIT
FinanceAndPython.com-EconomicFoundations-master/7 Curve Movements.ipynb
ds-modules/IAS-106
8fb0344c9dd112e79c535d86f12c1b0000be5041
MIT
2019-12-07T07:01:18.000Z
2022-02-05T01:46:45.000Z
Qwen/Qwen-72B
1. YES
2. YES