omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Print superscript characters in Python

    Pythonista
    5
    15
    3855
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • GiovaBici
      GiovaBici last edited by

      Thank you very much. How can I integrate it in here ( forgive me ignorance but I started recently). Thank you

      print("L'accellerazione é: " + str(accellerazione_finale) + " m/s**2")

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @GiovaBici last edited by cvp

        @GiovaBici said:

        print("L'accellerazione é: " + str(accellerazione_finale) + " m/s**2")

        accellerazione_finale = 7
        print(f"L'accellerazione é: {accellerazione_finale}  m/s\N{superscript TWO}")
        

        Gives

        L'accellerazione é: 7  m/s²
        
        GiovaBici 1 Reply Last reply Reply Quote 0
        • 7upser
          7upser last edited by

          You can also add Unicode superscripts to the characters: \u00B2
          for more information see here: Wikipedia

          Result is something like this:

          print(''.join('m/s' + '\u00B2'))
          print('m/s\u00B2')
          
          cvp 1 Reply Last reply Reply Quote 1
          • cvp
            cvp @7upser last edited by

            @7upser said:

            Unicode superscripts

            Still better...

            1 Reply Last reply Reply Quote 1
            • ccc
              ccc last edited by ccc

              accellerazione_finale = 7654
              print(f"L'accellerazione é: {accellerazione_finale:,} m/s\u00B2")
              

              L'accellerazione é: 7,654 m/s²

              1 Reply Last reply Reply Quote 1
              • GiovaBici
                GiovaBici last edited by

                Thank you very much for the answers !

                1 Reply Last reply Reply Quote 0
                • GiovaBici
                  GiovaBici last edited by

                  Hello everyone. Can you still help me: how do I write a calculation under the square root? Thanks to who will answer me

                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB last edited by

                    I don't think there is a unicode overline that does what you want. You could try U+0305

                    Really, this is a job for mathml or latex.
                    I don't think safari supports mathml.

                    1 Reply Last reply Reply Quote 0
                    • GiovaBici
                      GiovaBici last edited by

                      Thank you very much

                      1 Reply Last reply Reply Quote 0
                      • GiovaBici
                        GiovaBici @cvp last edited by

                        @cvp
                        Hi. In this case how can I put the two above m ?:

                        area_pressione = float(input("Inserisci l'area(m): "))

                        Thanks and sorry if I still don't understand ...
                        I still wanted to ask: Can I have certain print commands written in a different color than black?
                        Thank you

                        cvp 2 Replies Last reply Reply Quote 0
                        • cvp
                          cvp @GiovaBici last edited by

                          @GiovaBici

                          area_pressione = float(input("Inserisci l'area(m\u00B2): "))
                          
                          Inserisci l'area(m²): 
                          
                          1 Reply Last reply Reply Quote 0
                          • cvp
                            cvp @GiovaBici last edited by

                            @GiovaBici see here

                            1 Reply Last reply Reply Quote 0
                            • GiovaBici
                              GiovaBici last edited by

                              Thank you very much!

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Powered by NodeBB Forums | Contributors