2. Funkcja liniowa przykłady

[2]:
from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
[4]:
def slow_function(i):
    print(int(i),list(x for x in range(int(i)) if
                str(x)==str(x)[::-1] and
                str(x**2)==str(x**2)[::-1]))
    return
[5]:
from ipywidgets import FloatSlider
interact(slow_function,i=FloatSlider(min=1e5, max=1e7, step=1e5));
[2]:
import numpy as np

from matplotlib import pyplot as plt
[3]:
def lin_func(a, x, b):
    return a * x + b

fig = plt.figure()

x = np.linspace(0, 10, 1000)

# Poniżej funkcja y = 2x + 3
plt.plot(x, lin_func(2, x, 3 ));

# Alternatywna postać - użycie lambdy
# plt.plot(x, (lambda x: 2 * x + 3)(x));


../_images/basic_fliniowa_przyklady_5_0.png
[10]:
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
[11]:
def f(x):
    return x
interact(f, x=10);
[12]:
@interact(x=True, y=1.0)
def g(x, y):
    return (x, y)
[ ]: