This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> from sympy import * | |
| >>> x = Symbol('x') | |
| >>> diff(sin(x**2), x) | |
| 2*x*cos(x**2) | |
| # Найдем вторую производную "в лоб" | |
| >>> diff(diff(sin(x**2), x),x) | |
| -4*x**2*sin(x**2) + 2*cos(x**2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> from sympy import * | |
| >>> limit(sin(x)/x, x, 0) | |
| 1 | |
| >>> limit(x/sin(x),x,0) | |
| 1 | |
| >>> limit(x/cos(x),x,0) | |
| 0 | |
| # Предел на бесконечности (Два символа 'o') | |
| >>> limit(x, x, oo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> from sympy import * | |
| # Разложим на простейшие | |
| >>> apart(1/( (x+3)*(x+6) ), x) | |
| -1/(3*(x + 6)) + 1/(3*(x + 3)) | |
| >>> apart((2*x+1)/(x-1), x) | |
| 2 + 3/(x - 1) | |
| # Перемножим дроби |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> from sympy import * | |
| # Объявляем символьные переменные | |
| >>> x = Symbol('x') | |
| >>> y = Symbol('y') | |
| # Теперь можно работать с символьными выражениями | |
| >>> x+x+x+y | |
| 3*x + y | |
| >>> x*x*y+x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Импорт библиотеки sympy | |
| >>> from sympy import * | |
| # Определяем переменную a, как дробь 1/3 | |
| >>> a = Rational(1,3) | |
| # Выведем a и проделаем некоторые математические действия | |
| >>> a | |
| 1/3 | |
| >>> a*3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type1 = "word" # word | |
| type2 = 'word' # word | |
| type3 = '''word''' # word |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Целочисленная переменная | |
| x = 2 | |
| # Десятичная дробь | |
| price = 2.5 | |
| # Строка или символ | |
| word = 'Hello' | |
| char = "s" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x = int(input("Print 4=")) | |
| if x == 4: | |
| print("Thank you") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Для ввода текстовой строки | |
| name = input("Enter a name: ") | |
| # Для ввода целого значения | |
| x = int(input("What is x? ")) | |
| # Для ввода десятичных дробей | |
| x = float(input("Write a number")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Вывод текстовой строки | |
| print("Hello World") | |
| # Для вывода нескольких строк можно использовать спецсимвол \n | |
| print("First Line\nSecond Line") | |
| # Вывод переменных | |
| x = 5 | |
| print(x) |