1.
(a) A positive whole number n > 2 is prime if no number between 2 and (inclusive) evenly divides n. Write a program that accepts a value of n as input and determines if the value is prime. If n is not prime, your program should quit as soon as it finds a value that evenly divides n.
(b) Modify the previous program to find every prime number less than or equal to n.

2.
(a) Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points.
(b) College volleyball is now played using rally scoring. In this system, the team that wins a rally is awarded a point, even if they were not the serving team. Games are played to a score of 21. Design and implement a simulation of volleyball using rally scoring.
(c) Design and implement a system that compares regular volleyball games to those using rally scoring. Your program should be able to investigate whether rally scoring magnifies, reduces, or has no effect on the relative advantage enjoyed by the better team.

3.
(a) Write a set of classes corresponding to the geometric solids: cube, rectangular prism (brick), sphere and cylinder. Each class should have a constructor that allows for the creation of different sized objects (e.g., a cube is specified by the length of its side) and methods that return the surface area and volume of the solid.
(b) Extend the previous problem to include a method, inside, that determines whether a particular point lies within the solid. The method should accept three numbers representing the x, y and z coordinates of a point and return true if the point is inside the object and false otherwise. You may assume that the objects are always centered at (0, 0, 0).

4. Create and test a Set class to represent a classical set. Your sets should support the following methods:
 Set(elements): Create a set (elements is the initial list of items in the set).
 addElement(x): Adds x to the set.
 deleteElement(x): Removes x from the set.
 member(x): Returns true if x is in the set.
 intersection(set2): Returns a new set containing just those elements that are common to this set and set2.
 union(set2): Returns a new set containing all of elements that are in this set, set2, or both.
 subtract(set2): Returns a new set containing all the elements of this set that are not in set2.

5.
The Sieve of Eratosthenes is an elegant algorithm for finding all of the prime numbers up to some limit n. The basic idea is to first create a list of numbers from 2 to n. The first number is removed from the list, and announced as a prime number, and all multiples of this number up to n are removed from the list. This process continues until the list is empty.
For example, if we wished to find all the primes up to 10, the list would originally contain 2, 3, 4, 5, 6, 7, 8, 9, 10. The 2 is removed and announced to be prime. Then 4, 6, 8 and 10 are removed, since they are multiples of 2. That leaves 3, 5, 7, 9. Repeating the process, 3 is announced as prime and removed, and 9 is removed because it is a multiple of 3. That leaves 5 and 7. The algorithm continues by announcing that 5 is prime and removing it from the list. Finally, 7 is announced and removed, and we’re done.
Write a program that prompts a user for n and then uses the sieve algorithm to find all the primes less than or equal to n.

then can i ask other question??

regarding my question 4, i have try to solve,but still have little problem,can someone teaching me
??
class Set:

def __init__(self, list1=[]):
self.list1 = list1


def addElement(self, x):
if not x in self.list1:
self.list1.append(x)

def deleteElement(self, x):
if x in self.list1:
self.list1.remove(x)
return True

else:
return False

def member(self, x):
if x in self.list1:
return True
else:
return False

def intersection(self, aSet):
newSet = Set()
for i in aSet.list1:
if i in self.list1:
newSet.addElement(i)

return newSet

def union(self, aSet2):
newSetUnion = Set()
for i in self.list1:
newSetUnion.addElement(i)

for j in aSet2.list1:
if not j in self.list1:
newSetUnion.addElement(j)
return newSetUnion

def substract(self, aSet3):
newSetSubstract = Set()
for i in self.list1:
if not i in aSet3.list1:
newSetSubstract.addElement(i)

return newSetSubstract


def __str__(self):
return self.list1.__str__()

Couple of quick pointers, put your code inside code tags

[[/B]code[b]] code goes here [[/b]/code[b]]

also tell us what the problem is, see we now know you are having a little problem, But we don't know what that little problem is, but if you say, I get an error message while compiling saying 'bla' someone may say, well I have seen that one before take 2 of these and call me in the morning.

so what is the problem ?

This article has been dead for over six months. Start a new discussion instead.