Python | sympy.bell() method Last Updated : 14 Jul, 2019 Comments Improve Suggest changes Like Article Like Report With the help of sympy.bell() method, we can find Bell number and Bell polynomials in SymPy. bell(n) - Syntax: bell(n) Parameter: n - It denotes the order of the bell number. Returns: Returns the nth bell number. Example #1: Python3 # import sympy from sympy import * n = 5 print("Value of n = {}".format(n)) # Use sympy.bell() method nth_bell = bell(n) print("Value of nth bell number : {}".format(nth_bell)) Output: Value of n = 5 Value of nth bell number : 52 bell(n, k) - Syntax: bell(n, k) Parameter: n - It denotes the order of the bell polynomial. k - It denotes the variable in the bell polynomial. Returns: Returns the expression of the bell polynomial or its value. Example #2: Python3 # import sympy from sympy import * n = 5 k = symbols('x') print("Value of n = {} and k = {}".format(n, k)) # Use sympy.bell() method nth_bell_poly = bell(n, k) print("The nth bell polynomial : {}".format(nth_bell_poly)) Output: Value of n = 5 and k = x The nth bell polynomial : x**5 + 10*x**4 + 25*x**3 + 15*x**2 + x Example #3: Python3 # import sympy from sympy import * n = 5 k = 3 print("Value of n = {} and k = {}".format(n, k)) # Use sympy.bell() method nth_bell_poly = bell(n, k) print("The nth bell polynomial value : {}".format(nth_bell_poly)) Output: Value of n = 5 and k = 3 The nth bell polynomial value : 1866 bell(n, k, (x1, x2, x3, ...)) - Syntax: bell(n, k, (x1, x2, x3, ...)) Parameter: n - It denotes the order of the bell polynomial of second kind. k - It is a parameter in the bell polynomial of second kind. (x1, x2, x3, ...) - It denotes the tuple of variable symbols. Returns: Returns the Bell polynomials of the second kind. Example #4: Python3 # import sympy from sympy import * n = 5 k = 3 variables = symbols('x:6')[1:] print("Value of n = {}, k = {} and variables = {}".format(n, k, variables)) # Use sympy.bell() method nth_bell_poly = bell(n, k, variables) print("The nth bell polynomial of second kind : {}".format(nth_bell_poly)) Output: Value of n = 5, k = 3 and variables = (x1, x2, x3, x4, x5) The nth bell polynomial of second kind : 10*x1**2*x3 + 15*x1*x2**2 Comment More infoAdvertise with us Next Article Must Do Coding Questions Company-wise rupesh_rao Follow Improve Article Tags : Python SymPy Practice Tags : python Similar Reads Interview Preparation Interview Preparation For Software Developers Must Coding Questions - Company-wise Must Do Coding Questions - Topic-wise Company-wise Practice Problems Company Preparation Competitive Programming Software Design-Patterns Company-wise Interview Experience Experienced - Interview Experiences Internship - Interview Experiences Practice @Geeksforgeeks Problem of the Day Topic-wise Practice Difficulty Level - School Difficulty Level - Basic Difficulty Level - Easy Difficulty Level - Medium Difficulty Level - Hard Leaderboard !! Explore More... Data Structures Arrays Linked List Stack Queue Binary Tree Binary Search Tree Heap Hashing Graph Advance Data Structures Matrix String All Data Structures Algorithms Analysis of Algorithms Searching Algorithms Sorting Algorithms Pattern Searching Geometric Algorithms Mathematical Algorithms Randomized Algorithms Greedy Algorithms Dynamic Programming Divide & Conquer Backtracking Branch & Bound All Algorithms Programming Languages C C++ Java Python C# Go Lang SQL PHP Scala Perl Kotlin Web Technologies HTML CSS JavaScript Bootstrap Tailwind CSS AngularJS ReactJS jQuery NodeJS PHP Web Design Web Browser File Formats Computer Science Subjects Operating Systems DBMS Computer Network Computer Organization & Architecture TOC Compiler Design Digital Elec. & Logic Design Software Engineering Engineering Mathematics Data Science & ML Complete Data Science Course Data Science Tutorial Machine Learning Tutorial Deep Learning Tutorial NLP Tutorial Machine Learning Projects Data Analysis Tutorial Tutorial Library Python Tutorial Django Tutorial Pandas Tutorial Kivy Tutorial Tkinter Tutorial OpenCV Tutorial Selenium Tutorial GATE CS GATE CS Notes Gate Corner Previous Year GATE Papers Last Minute Notes (LMNs) Important Topic For GATE CS GATE Course Previous Year Paper: CS exams Like