Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The earlier comments I believe we made to you in Question 195 still hold! This isn't a homework tutorial. So, once again, I'll give you some hints as to where to find this information, and what the issues are, but no more.

Your syntax is not quite right. You may wish to check out a Python tutorial, such as the official one, Dive into Python (for more experienced programmers), or Think Python, which is truly excellent and truly for beginners, and truly free in that form :)

More specifically, since you haven't defined b, you can't say anything about it. Second, the for statement needs some sort of iterable as its object. The prime_range function, which you can learn more about with

sage: prime_range?

would be useful for getting a set of primes to iterate over; you can use [1..5] to get the set of integers from 1 to 5. Third, you probably want some kind of conditional statement if you are testing whether an element is a square; usually this has the syntax

if b>25:
    print 'yay!'
    print 'boo!'

This would be if you were checking whether b was greater than 25.

Incidentally, the statement of the problem also looks strange; see if you can figure out what seems wrong mathematically with what you wrote.