I'm doing a maths revision program and I want to print out a question with y to the power of x(like xⁿ
). I can't find a way to print it out as this form. Has anyone got any ideas?
Asked
Active
Viewed 73 times
1

Dima Kozhevin
- 3,602
- 9
- 39
- 52

tegan.joy
- 23
- 3
-
Print to terminal? – iGian Dec 31 '18 at 21:32
-
You mean like this? `xⁿ` – Robert Harvey Dec 31 '18 at 21:33
-
Yes that is exactly what I want. – tegan.joy Dec 31 '18 at 21:35
1 Answers
0
One possible option using ANSI escape sequences, it is not possible to control font size:
base = "x"
exponent = "n"
print('\033[1BFormula = %s\033[1A%s\033[1B etcetera'%(exponent, base))
In terminal you get:
# x
#Formula = n etcetera

iGian
- 11,023
- 3
- 21
- 36
-
-
@tegan.joy try `print('{}\033[1A{}\033[1B'.format(base, exponent))` – Dillon Davis Jan 01 '19 at 21:53