ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 07 Oct 2021 12:34:38 +0200other way of creating a list of perfect squareshttps://ask.sagemath.org/question/59269/other-way-of-creating-a-list-of-perfect-squares/ Hi there! I am currently explaining a certain exercise to my buddy and part of it consists in creating a list of perfect squares up to root of 64 (included) therefore the list has to look like this [0, 1, 4, 9, 16, 25, 36, 49, 64]
My first idea was this
squares=[i*i for i in range(sqrt(64)+1)]
which works but I am now trying to do it in a way so that is not compressed such us
for i in range(sqrt(64)+1)
squares=[i*i]
print(squares)
But I keep getting this error
for i in range(sqrt(Integer(64))+Integer(1))
^
SyntaxError: invalid syntax
Any ideas of what I am doing wrong?
jhonvi2Thu, 07 Oct 2021 12:34:38 +0200https://ask.sagemath.org/question/59269/How can I get Sage to go over all possible maps between two sets?https://ask.sagemath.org/question/26705/how-can-i-get-sage-to-go-over-all-possible-maps-between-two-sets/ What I want to do is this : Say I take a graph $K_{n,n}$ and choose an ordering for each edge arbitrarily - say denote each edge as $(i,j)$ where $i$ is in the left partition and $j$ is in the right partition. I have a set of matrices $A = { A_1, A_2,...,A_k \}$. I want to iterate over all possible ways in which one could have assigned an A matrix to an edge of this graph.
- How does one do that? (..apart from writing a massive sequence of nested loops!..)
phoenixSun, 03 May 2015 00:25:28 +0200https://ask.sagemath.org/question/26705/