Skip to content
Snippets Groups Projects
Commit 80604368 authored by tuhe's avatar tuhe
Browse files

Reorg for new version

parent 1e3343c7
No related branches found
No related tags found
No related merge requests found
Showing
with 43 additions and 66 deletions
####################
# Question 1. Write a function reverse_list which accepts a list, and returns a new list
# with the same elements but in opposite order.
####################
def reverse_list(mylist):
# TODO: Your solution here
result = []
for k in mylist:
result = [k] + result
def reverse_list(mylist): #!f
"""
Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g.
reverse_list([1,2,3]) should return [3,2,1] (as a list).
"""
return list(reversed(mylist))
return result
def simple_list_question():
print("The reverse list function can reverse a list")
l = [1, 2, 3, 4]
print("List was:", l, "reversed version", reverse_list(l))
def add(a,b):
def add(a,b): #!f
""" Given two numbers `a` and `b` this function should simply return their sum:
> add(a,b) = a+b """
return a+b
def my_sum(ls):
return sum(ls)
if __name__ == "__main__":
# Problem 1: Write a function which add two numbers
print(f"Your result of 2 + 2 = {add(2,2)}")
......
"""
Example student code. This file is automatically generated from the files in the instructor-directory
"""
####################
# Question 1. Write a function reverse_list which accepts a list, and returns a new list
# with the same elements but in opposite order.
####################
def reverse_list(mylist):
def reverse_list(mylist): #!f
# TODO: Your solution here
result = []
for k in mylist:
......@@ -13,17 +9,9 @@ def reverse_list(mylist):
return result
def simple_list_question():
print("The reverse list function can reverse a list")
l = [1, 2, 3, 4]
print("List was:", l, "reversed version", reverse_list(l))
def add(a,b):
def add(a,b): #!f
return a+b
def my_sum(ls):
return sum(ls)
if __name__ == "__main__":
# Problem 1: Write a function which add two numbers
print(f"Your result of 2 + 2 = {add(2,2)}")
......
def reverse_list(mylist): #!f
# TODO: Your solution here
result = []
for k in mylist:
result = [k] + result
return result
"""
Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g.
reverse_list([1,2,3]) should return [3,2,1] (as a list).
"""
return list(reversed(mylist))
def add(a,b): #!f
""" Given two numbers `a` and `b` this function should simply return their sum:
> add(a,b) = a+b """
return a+b
if __name__ == "__main__":
......
No preview for this file type
from report1 import Report1
from unitgrade_private2.hidden_create_files import setup_grade_file_report
from snipper import snip_dir
import shutil
# from unitgrade_private2.hidden_gather_upload import gather_upload_to_campusnet
if __name__ == "__main__":
......@@ -11,5 +12,8 @@ if __name__ == "__main__":
snip_dir.snip_dir(source_dir="../cs101", dest_dir="../../students/cs101", clean_destination_dir=True, exclude=['*.token', 'deploy.py'])
# For my own sake, copy the homework to the other examples.
for f in ['../../../example_framework/instructor/cs102/homework1.py', '../../../example_docker/instructor/cs103/homework1.py']:
shutil.copy('homework1.py', f)
from unitgrade2.unitgrade2 import Report
from unitgrade2.unitgrade_helpers2 import evaluate_report_student
from homework1 import reverse_list, my_sum, add
from homework1 import reverse_list, add
import unittest
class Week1(unittest.TestCase):
......
No preview for this file type
No preview for this file type
"""
Example student code. This file is automatically generated from the files in the instructor-directory
"""
import numpy as np
from sklearn.datasets import load_boston
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score
####################
# Question 1. Write a function reverse_list which accepts a list, and returns a new list
# with the same elements but in opposite order.
####################
def reverse_list(mylist):
# TODO: 6 lines missing.
raise NotImplementedError("Implement function body")
def simple_list_question():
# TODO: 3 lines missing.
raise NotImplementedError("Implement function body")
def add(a,b):
"""
Given a list 'mylist' returns a list consisting of the same elements in reverse order. E.g.
reverse_list([1,2,3]) should return [3,2,1] (as a list).
"""
# TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
def my_sum(ls):
def add(a,b):
""" Given two numbers `a` and `b` this function should simply return their sum:
> add(a,b) = a+b """
# TODO: 1 lines missing.
raise NotImplementedError("Implement function body")
......
......@@ -3,7 +3,7 @@ Example student code. This file is automatically generated from the files in the
"""
from unitgrade2.unitgrade2 import Report
from unitgrade2.unitgrade_helpers2 import evaluate_report_student
from homework1 import reverse_list, my_sum, add
from homework1 import reverse_list, add
import unittest
class Week1(unittest.TestCase):
......@@ -14,11 +14,11 @@ class Week1(unittest.TestCase):
def test_reverse(self):
self.assertEqual(reverse_list([1,2,3]), [3,2,1])
import homework1
import cs101
class Report1(Report):
title = "CS 101 Report 1"
questions = [(Week1, 10)] # Include a single question for 10 credits.
pack_imports = [homework1]
pack_imports = [cs101]
if __name__ == "__main__":
# Uncomment to simply run everything as a unittest:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment