The Responsive Web Design projects rely on the test-suite to test and validate your code. The projects are not validated when submitted.
Most other projects are validated, upon submission. The main idea is encapsulated in the Academic Honesty Policy, visible on the settings page: https://www.freecodecamp.org/settings
“I pledge that I did not plagiarize any of my freeCodeCamp.org work. I understand that freeCodeCamp\.org’s team will audit my projects to confirm this.”
In the situations where we discover instances of unambiguous plagiarism, we will replace the person in question’s certification with a message that “Upon review, this account has been flagged for academic dishonesty.”
import copy
import random
# Consider using the modules imported above.
class Hat:
contents = []
def __init__(self,**balls):
for ball in balls:
for i in range(0,balls[ball]):
self.contents.append(ball)
def draw(self,k):
if k > len(self.contents):
return self.contents
else:
return random.sample(self.contents,k)
def experiment(hat, expected_balls, num_balls_drawn, num_experiments):
count = 0
for i in range(0,num_experiments):
drawn_balls = {}
list_of_drawns = hat.draw(num_balls_drawn)
for ball in list_of_drawns:
try:
drawn_balls[ball] += 1
except:
drawn_balls[ball] = 1
ok = True
for ball in expected_balls:
if not (ball in drawn_balls and drawn_balls[ball] >= expected_balls[ball]):
ok = False
if ok:
count += 1
return count/num_experiments