Need help on school exercise!!!pls come in and try to solve for me ,thank

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2008
Posts: 6
Reputation: renabada is an unknown quantity at this point 
Solved Threads: 0
renabada renabada is offline Offline
Newbie Poster

Need help on school exercise!!!pls come in and try to solve for me ,thank

 
0
  #1
Apr 6th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 6
Reputation: renabada is an unknown quantity at this point 
Solved Threads: 0
renabada renabada is offline Offline
Newbie Poster

Re: Need help on school exercise!!!pls come in and try to solve for me ,thank

 
0
  #2
Apr 6th, 2008
please help me ....thk
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 6
Reputation: renabada is an unknown quantity at this point 
Solved Threads: 0
renabada renabada is offline Offline
Newbie Poster

Re: Need help on school exercise!!!pls come in and try to solve for me ,thank

 
0
  #3
Apr 6th, 2008
no one know????
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,292
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 177
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Re: Need help on school exercise!!!pls come in and try to solve for me ,thank

 
2
  #4
Apr 6th, 2008
We all know, but we don't do your homework! Read the DaniWeb rules.
No one died when Clinton lied.
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 6
Reputation: renabada is an unknown quantity at this point 
Solved Threads: 0
renabada renabada is offline Offline
Newbie Poster

Re: Need help on school exercise!!!pls come in and try to solve for me ,thank

 
0
  #5
Apr 7th, 2008
ok...thk
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 6
Reputation: renabada is an unknown quantity at this point 
Solved Threads: 0
renabada renabada is offline Offline
Newbie Poster

Re: Need help on school exercise!!!pls come in and try to solve for me ,thank

 
0
  #6
Apr 7th, 2008
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__()
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 6
Reputation: renabada is an unknown quantity at this point 
Solved Threads: 0
renabada renabada is offline Offline
Newbie Poster

Re: Need help on school exercise!!!pls come in and try to solve for me ,thank

 
0
  #7
Apr 7th, 2008
wrong???can someone please reply??
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 181
Reputation: Paul.Esson is an unknown quantity at this point 
Solved Threads: 10
Paul.Esson's Avatar
Paul.Esson Paul.Esson is offline Offline
Junior Poster

Re: Need help on school exercise!!!pls come in and try to solve for me ,thank

 
0
  #8
Apr 8th, 2008
Couple of quick pointers, put your code inside code tags

[code] code goes here [/code]

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 ?
Last edited by Paul.Esson; Apr 8th, 2008 at 9:59 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC