0

I am writing a code which is supposed to print a series in the form:

x - (x^2)/2! + (x^3)/3! - (x^4)/4! ... (x^n)/n!

where x and n are input from the user end.

For now my code looks like this

x = int(input('Enter number: '))
n = int(input('Till which term? '))

#for series
for i in range(1,n+1,1):
    if i == n:
        print('('+str(x)+'^'+str(i)+')'+'/'+str(i)+'!')
    elif i == 1:
        print(str(x),end = ' - ')
    else:
        if i%2 != 0:
            print('('+str(x)+'^'+str(i)+')'+'/'+str(i)+'!',end = ' - ')
        else:
            print('('+str(x)+'^'+str(i)+')'+'/'+str(i)+'!',end = ' + ')

but the output is:

================= RESTART: E:/Python/Files/special series 4.py =================
Enter number: 3
Till which term? 6
3 - (3^2)/2! + (3^3)/3! - (3^4)/4! + (3^5)/5! - (3^6)/6!

is there any function to write in superscript to avoid the arrow-head sign?

  • There are superscript numbers in the Unicode table: https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts – Klaus D. Mar 26 '21 at 05:43

1 Answers1

0

As the output of Python and pretty much any language is usually in unicode or ASCII, the answer is simply no.

1313e
  • 1,112
  • 9
  • 17