Commit a8901416 authored by David Paul's avatar David Paul
Browse files

Fix some issues students have had with exercises

parent ef36af9b
......@@ -50,20 +50,20 @@ exercise.checks = [Check("You should use a for loop to loop over all keys in one
Check("For this exercise, you need to initialise the dicrionary when it is created", "\[[\"']pen[\"']\](\\s)*=", True),
Check("For this exercise, you need to initialise the dicrionary when it is created", "\[[\"']paper[\"']\](\\s)*=", True),
Check("For this exercise, you need to initialise the dicrionary when it is created", "\[[\"']eraser[\"']\](\\s)*=", True),
Check("You need to specify the correct weights in a dictionary", "[\"']pencil[\"'](\\s)*:(\\s)+10"),
Check("You need to specify the correct weights in a dictionary", "[\"']pen[\"'](\\s)*:(\\s)+20"),
Check("You need to specify the correct weights in a dictionary", "[\"']paper[\"'](\\s)*:(\\s)+4"),
Check("You need to specify the correct weights in a dictionary", "[\"']eraser[\"'](\\s)*:(\\s)+80"),
Check("You need to specify the correct availability in a dictionary", "[\"']pen[\"'](\\s)*:(\\s)+3"),
Check("You need to specify the correct availability in a dictionary", "[\"']pencil[\"'](\\s)*:(\\s)+5"),
Check("You need to specify the correct availability in a dictionary", "[\"']eraser[\"'](\\s)*:(\\s)+2"),
Check("You need to specify the correct availability in a dictionary", "[\"']paper[\"'](\\s)*:(\\s)+10")]
Check("You need to specify the correct weights in a dictionary", "[\"']pencil[\"'](\\s)*:(\\s)*10"),
Check("You need to specify the correct weights in a dictionary", "[\"']pen[\"'](\\s)*:(\\s)*20"),
Check("You need to specify the correct weights in a dictionary", "[\"']paper[\"'](\\s)*:(\\s)*4"),
Check("You need to specify the correct weights in a dictionary", "[\"']eraser[\"'](\\s)*:(\\s)*80"),
Check("You need to specify the correct availability in a dictionary", "[\"']pen[\"'](\\s)*:(\\s)*3"),
Check("You need to specify the correct availability in a dictionary", "[\"']pencil[\"'](\\s)*:(\\s)*5"),
Check("You need to specify the correct availability in a dictionary", "[\"']eraser[\"'](\\s)*:(\\s)*2"),
Check("You need to specify the correct availability in a dictionary", "[\"']paper[\"'](\\s)*:(\\s)*10")]
exercises.append(exercise)
# Exercise 5
exercise = Exercise("Bug Hunting")
exercise.instructions = "Debug the following program:"
exercise.code = "Def factorial(n):\n \"\"\"Calculate the factorial of the given value and return the result.\n\n The factorial of n is the product of all positive integers less than or equal to n.\n\n Keyword arguments:\n n -- A positive integer\n \"\"\"\n result = 1\n while n != 0:\n n = n - 1\n result = result * n\n return result\n\n# Calculate factorial for the first four integers\nfor i in range(-1, 5):\n print('Factorial of', i, 'is', factorial(i)"
exercise.code = "Def factorial(n):\n \"\"\"Calculate the factorial of the given value and return the result.\n\n The factorial of n is the product of all positive integers less than or equal to n. This function does not support negative values - if a negative value is given, this function just returns 1.\n\n Arguments:\n n -- A positive integer\n \"\"\"\n result = 1\n while n != 0:\n n = n - 1\n result = result * n\n return result\n\n# Calculate factorial for the first four integers\nfor i in range(-1, 5):\n print('Factorial of', i, 'is', factorial(i)"
exercise.tests = [Test("Expected output", "Factorial of 1 is 1\nFactorial of 2 is 2\nFactorial of 3 is 6\nFactorial of 4 is 24\n")]
exercise.checks = [Check("Ensure function begins with \"def\" (not \"Def\")", "def factorial"),
Check("Should you be testing for inequality only?", "!=", True),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment