Ask Your Question

Faisal's profile - activity

2020-04-07 17:18:23 +0200 received badge  Famous Question (source)
2019-04-18 19:49:02 +0200 received badge  Popular Question (source)
2019-04-18 19:49:02 +0200 received badge  Notable Question (source)
2018-04-13 09:06:17 +0200 commented answer 'int' object has no attribute 'is_prime'

Thank you @slelievre so much for your detailed answer..

2018-04-11 16:29:08 +0200 received badge  Nice Question (source)
2018-04-10 15:53:32 +0200 received badge  Student (source)
2018-04-09 16:43:39 +0200 asked a question 'int' object has no attribute 'is_prime'

Hi ... I am wondering why this code is not working

for number in range(20,30):
  if number.is_prime():
    print number

I got this error in Cocalc

Error in lines 1-3
Traceback (most recent call last):
  File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 2, in <module>
AttributeError: 'int' object has no attribute 'is_prime'

However, it works when I change the code to

for number in range(20,30):
    if is_prime(number):
        print number
2018-01-30 21:06:20 +0200 commented question Sagetex doesn't compile tex file with figures

Thanks, but I dont think it is a memory issue. I have enough memory in my PC.

2018-01-30 04:20:57 +0200 received badge  Editor (source)
2018-01-29 21:47:23 +0200 asked a question Sagetex doesn't compile tex file with figures

Hi.. I am using Sagetex in Windows 10. I have a problem that arises when the number of plots in my tex file increases than four.

Here is the code I used

\documentclass{article}

\title{Examples of embedding Sage in \LaTeX{} with \textsf{Sage\TeX}}

\author{Dan Drake and others}

\usepackage{hyperref}

\usepackage{sagetex}

\setlength{\sagetexindent}{10ex}

\begin{document}

\maketitle

\section{Inline Sage, code blocks}

This is an example $2+2=\sage{2+2}$. If you raise the current year mod
$100$ (which equals $\sage{mod(\the\year, 100)}$) to the power of the
current day ($\the\day$), you get $\sage{Integer(mod(\the\year,
100))^\the\day}$. Also, $\the\year$ modulo $42$ is $\sage{\the\year
\percent 42}$.

Code block which uses a variable \texttt{s} to store the solutions:
\begin{sageblock}
 1+1
 var('a,b,c')
 eqn = [a+b*c==20, b-a*c==-12, a+b==5]
 s = solve(eqn, a,b,c)
\end{sageblock}

Solutions of $\mbox{eqn}=\sage{eqn}$:
\[
\sage{s[0]}
\]
\[
\sage{s[1]}
\]

\begin{sageblock}
 eqn = [a+b*c==0, b-a*c==-2, a+b==5]
 s = solve(eqn, a,b,c)
\end{sageblock}

Solutions of $\mbox{eqn}=\sage{eqn}$:
\[
\sage{s[0]}
\]
\[
\sage{s[1]}
\]


You can use variables to hold plot objects and do stuff with them.
\begin{sageblock}
  p = plot(tan(x), x, -5, 5)
\end{sageblock}

Here's a small plot of $f$ from $-5$ to $5$, which I've centered:

\begin{center} \sageplot[scale=.2]{p} \end{center}

\begin{sageblock}
  p = plot(tan(x), x, -5, 5)
\end{sageblock}

Here's a small plot of $f$ from $-5$ to $5$, which I've centered:

\begin{center} \sageplot[scale=.2]{p} \end{center}

\begin{sageblock}
  p = plot(tan(x), x, -5, 5)
\end{sageblock}

Here's a small plot of $f$ from $-5$ to $5$, which I've centered:

\begin{center} \sageplot[scale=.2]{p} \end{center}

\begin{sageblock}
  p = plot(tan(x), x, -5, 5)
\end{sageblock}

Here's a small plot of $f$ from $-5$ to $5$, which I've centered:

\begin{center} \sageplot[scale=.2]{p} \end{center}

\begin{sageblock}
  p = plot(tan(x), x, -5, 5)
\end{sageblock}

Here's a small plot of $f$ from $-5$ to $5$, which I've centered:

\begin{center} \sageplot[scale=.2]{p} \end{center}


\end{document}

Sagetex can compile without any problem if I omit the last \sageplot. If it is there the shell will stop suddenly without giving any error message.

I appreciate your help