Ask Your Question

pytonnoob's profile - activity

2024-02-06 07:02:54 +0200 received badge  Notable Question (source)
2022-02-27 07:43:17 +0200 received badge  Famous Question (source)
2021-11-23 13:53:15 +0200 received badge  Popular Question (source)
2020-11-15 21:23:25 +0200 received badge  Notable Question (source)
2020-01-10 22:14:06 +0200 received badge  Popular Question (source)
2018-01-29 19:05:32 +0200 asked a question Printing variable name

How would I return a variable name in a function. E.g. If I have the function:

def mul(a,b):
   return a*b

a = mul(1,2); a
b = mul(1,3); b
c = mul(1,4); c

This would return:

2
3
4

I would like it to return:

a = 2
b = 3
c = 4

How would I do this?

2018-01-29 15:58:55 +0200 received badge  Editor (source)
2018-01-29 15:58:25 +0200 asked a question Printing latex

I am using sage and would like to implement a function that prints a variable in latex, so I can copy and paste it directly into my latex file. However I am unsure how to do this. This is what I have attempted:

def printlatex(a):
    return '$', latex(a), '$'
a = 1*2
printlatex(a)

This returns the tuple ('$', 2, '$'), which I don't want.

How would I implement the function so it returns $2$

2018-01-26 11:30:03 +0200 commented question Output to latex

@dan_fulea Yes I would like a function that prints the following in latex:

e = mul(a,b)
f = mul(c,d)
g = mul(e,f)

If a variable was used twice e.g.

e = mul(a,b)
f = mul(c,d)
g = mul(e,f)
f = mul(b,d)

I would like it to print both variations.

2018-01-25 23:57:01 +0200 asked a question Output to latex

I am struggling on how I can implement my code so it outputs into latex. I have the follwing:

T = PolynomialRing(QQ, 'a,b,c,d'); T
T.inject_variables()

e = mul(a,b)
f = mul(c,d)
g = mul(e,f)

Now I would like to implement a function so when it is called it will print the operations below in latex:

 e = mul(a,b)
 f = mul(c,d)
 g = mul(e,f)

Does anyone know how I can do this?

2018-01-25 23:57:01 +0200 asked a question Testing if I can delete

Just testing something please ignore this