SymPy can print Exponentiation base and exponent?











up vote
0
down vote

favorite












Thank you in advance and sorry for the bad english!



I want



1.x : how to Determination of Exponentiation , Determination possible?



2.print : base=b ,exponent=n



 WrongScript.py



from sympy import *
var('x y z a b n')
x=b**n
y=3**n
z=a
# output 1.---------------------------------
print("x=",x) # x= b**n,**
print("y=",y) # y= 3**n,**
print("z=",z) # z= a, not **
# output 2.---------------------------------
print(MyBaseOut(x),MyExponentOut(x)) # b,n
print(MyBaseOut(y),MyExponentOut(y)) # 3,n

def MyBaseOut(p):
# ans=?
return ans
def MyExponentOut(q):
# ans=?
return ans


2018-11-26------------------------------



FullScript.py



from sympy import *
var('b n')
def MyBaseOut(p):
return p.as_base_exp()[0]
def MyExponentOut(q):
return q.as_base_exp()[1]
x=b**n
y=3**n
print(MyBaseOut(x),MyExponentOut(x))
print(MyBaseOut(y),MyExponentOut(y))
# b n
# 3 n









share|improve this question




























    up vote
    0
    down vote

    favorite












    Thank you in advance and sorry for the bad english!



    I want



    1.x : how to Determination of Exponentiation , Determination possible?



    2.print : base=b ,exponent=n



     WrongScript.py



    from sympy import *
    var('x y z a b n')
    x=b**n
    y=3**n
    z=a
    # output 1.---------------------------------
    print("x=",x) # x= b**n,**
    print("y=",y) # y= 3**n,**
    print("z=",z) # z= a, not **
    # output 2.---------------------------------
    print(MyBaseOut(x),MyExponentOut(x)) # b,n
    print(MyBaseOut(y),MyExponentOut(y)) # 3,n

    def MyBaseOut(p):
    # ans=?
    return ans
    def MyExponentOut(q):
    # ans=?
    return ans


    2018-11-26------------------------------



    FullScript.py



    from sympy import *
    var('b n')
    def MyBaseOut(p):
    return p.as_base_exp()[0]
    def MyExponentOut(q):
    return q.as_base_exp()[1]
    x=b**n
    y=3**n
    print(MyBaseOut(x),MyExponentOut(x))
    print(MyBaseOut(y),MyExponentOut(y))
    # b n
    # 3 n









    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Thank you in advance and sorry for the bad english!



      I want



      1.x : how to Determination of Exponentiation , Determination possible?



      2.print : base=b ,exponent=n



       WrongScript.py



      from sympy import *
      var('x y z a b n')
      x=b**n
      y=3**n
      z=a
      # output 1.---------------------------------
      print("x=",x) # x= b**n,**
      print("y=",y) # y= 3**n,**
      print("z=",z) # z= a, not **
      # output 2.---------------------------------
      print(MyBaseOut(x),MyExponentOut(x)) # b,n
      print(MyBaseOut(y),MyExponentOut(y)) # 3,n

      def MyBaseOut(p):
      # ans=?
      return ans
      def MyExponentOut(q):
      # ans=?
      return ans


      2018-11-26------------------------------



      FullScript.py



      from sympy import *
      var('b n')
      def MyBaseOut(p):
      return p.as_base_exp()[0]
      def MyExponentOut(q):
      return q.as_base_exp()[1]
      x=b**n
      y=3**n
      print(MyBaseOut(x),MyExponentOut(x))
      print(MyBaseOut(y),MyExponentOut(y))
      # b n
      # 3 n









      share|improve this question















      Thank you in advance and sorry for the bad english!



      I want



      1.x : how to Determination of Exponentiation , Determination possible?



      2.print : base=b ,exponent=n



       WrongScript.py



      from sympy import *
      var('x y z a b n')
      x=b**n
      y=3**n
      z=a
      # output 1.---------------------------------
      print("x=",x) # x= b**n,**
      print("y=",y) # y= 3**n,**
      print("z=",z) # z= a, not **
      # output 2.---------------------------------
      print(MyBaseOut(x),MyExponentOut(x)) # b,n
      print(MyBaseOut(y),MyExponentOut(y)) # 3,n

      def MyBaseOut(p):
      # ans=?
      return ans
      def MyExponentOut(q):
      # ans=?
      return ans


      2018-11-26------------------------------



      FullScript.py



      from sympy import *
      var('b n')
      def MyBaseOut(p):
      return p.as_base_exp()[0]
      def MyExponentOut(q):
      return q.as_base_exp()[1]
      x=b**n
      y=3**n
      print(MyBaseOut(x),MyExponentOut(x))
      print(MyBaseOut(y),MyExponentOut(y))
      # b n
      # 3 n






      sympy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 at 12:05

























      asked Nov 22 at 12:59









      mrrclb48z

      356




      356
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The attribute is_Pow will tell you if it has an exponent other than 1 and the method as_base_exp() will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:



          >>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
          [(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431596%2fsympy-can-print-exponentiation-base-and-exponent%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            The attribute is_Pow will tell you if it has an exponent other than 1 and the method as_base_exp() will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:



            >>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
            [(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]





            share|improve this answer

























              up vote
              1
              down vote



              accepted










              The attribute is_Pow will tell you if it has an exponent other than 1 and the method as_base_exp() will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:



              >>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
              [(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]





              share|improve this answer























                up vote
                1
                down vote



                accepted







                up vote
                1
                down vote



                accepted






                The attribute is_Pow will tell you if it has an exponent other than 1 and the method as_base_exp() will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:



                >>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
                [(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]





                share|improve this answer












                The attribute is_Pow will tell you if it has an exponent other than 1 and the method as_base_exp() will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:



                >>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
                [(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 13:26









                smichr

                3,368810




                3,368810






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431596%2fsympy-can-print-exponentiation-base-and-exponent%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    What visual should I use to simply compare current year value vs last year in Power BI desktop

                    Alexandru Averescu

                    Trompette piccolo