Beispiel #1
0
import entering as en
import my_functions as func
from collections import defaultdict

values = defaultdict(list)
en.x, en.x2, en.h, en.a = float(en.x), float(en.x2), float(en.h), float(en.a)
while True:
    try:
        while en.x <= en.x2:
            try:
                values[1].append(func.g(en.x, en.a))
                values[2].append(func.f(en.x, en.a))
                values[3].append(func.y(en.x, en.a))
                en.x += en.h
            except ValueError:
                print('Error')
        with open('function_values.txt', 'w+') as f:
            for key in range(1, 4):
                f.write(';'.join(str(values[key])))
                values[1].append(f.read())
        print(values[1])
    except KeyboardInterrupt:
        print('bye')
    ex = input('Do you wanna repeat?(y or n)')
    if ex == 'y':
        pass
    else:
        raise SystemExit()
Beispiel #2
0
import my_functions

a = float(input('Please enter a'))
x = float(input('Please enter x'))
s = int(input('Also please select a function: [G-1];[F-2];[Y-3]'))

if s == 1:
    try:
        print(my_functions.g(x, a))
    except ValueError:
        print('error')
elif s == 2:
    try:
        print(my_functions.f(x, a))
    except ValueError:
        print('error')
elif s == 3:
    try:
        print(my_functions.y(x, a))
    except ValueError:
        print('error')
else:
    print('Sorry,you have wrote invalid number')
Beispiel #3
0
                    print(x, func.g(x, a))
                    x += h
                except ValueError:
                    print('Error')
            elif s == 2:
                try:
                    mas_x.append(x)
                    mas_y.append(func.f(x, a))
                    print(x, func.f(x, a))
                    x += h
                except ValueError:
                    print('Error')
            elif s == 3:
                try:
                    mas_x.append(x)
                    mas_y.append(func.y(x, a))
                    print(x, func.y(x, a))
                    x += h
                except ValueError:
                    print('Error')

        plt.plot(mas_x, mas_y)
        plt.title('График функции')
        plt.show()
    except KeyboardInterrupt:
        print('Bye')

    ex = input('Do you wanna repeat?(y or n)')
    if ex == 'y':
        pass
    else:
Beispiel #4
0
     while en.x <= en.x2:
         if en.s == 1:
             try:
                 func_values.append(func.g(en.x, en.a))
                 en.x += en.h
             except ValueError:
                 print('Error')
         elif en.s == 2:
             try:
                 func_values.append(func.f(en.x, en.a))
                 en.x += en.h
             except ValueError:
                 print('Error')
         elif en.s == 3:
             try:
                 func_values.append(func.y(en.x, en.a))
                 en.x += en.h
             except ValueError:
                 print('Error')
     print('; '.join(str(i) for i in func_values))
     for i in func_values:
         if str(i) == shablon:
             k += 1
     print(k)
 except KeyboardInterrupt:
     print('bye')
 ex = input('Do you wanna repeat?(y or n)')
 if ex == 'y':
     pass
 else:
     raise SystemExit()