Ask Your Question

Revision history [back]

Some comments:

  • Parentheses are not balanced in the first line of code in the question. Remove an extraneous opening parenthesis (or add a closing parenthesis).

  • The Python built-in function input can be used to ask for user input. This function does not work in SageCell.

  • The function sage_input is very different. It helps finding what Sage input would give some object. See the documentation for sage_input.

  • Sage has a built-in function for finding the next prime.

    sage: 12.next_prime()
    13
    sage: next_prime(12)
    13
    
  • Sage has a function for listing primes in a given range.

    sage: prime_range(12, 30)
    [13, 17, 19, 23, 29]
    
  • You can use "interacts" in Sage, see https://wiki.sagemath.org/interact.