File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,17 +108,34 @@ See the video below for an example.
108108 :align: center
109109
110110Finish writing the code for the following problem.
111- .. writecode :: intro-sample-write-code-double-mooc_nested
112- :numbered: left
113- :adaptive:
114- :practice: T
115111
116- Write a function called ``double(num) `` that takes a number ``num `` and
117- returns the number times 3. For example, ``double(3) `` should return 6 and ``double(-4) `` should return -8.
118- -----
119- def double(num):
120- # Your code here
121- pass
112+ .. activecode :: intro-sample-write-code-double-mooc_nested
113+ :autograde: unittest
114+ :nocodelens:
115+
116+ Write a function called ``double(num) `` that takes a number ``num `` and
117+ returns the number times 2. For example, ``double(3) `` should return 6 and ``double(-4) `` should return -8.
118+ ~~~~
119+ def double(num):
120+ # Your code here
121+ pass
122+
123+ print(double(2))
124+ print(double(-1))
125+
126+ ====
127+ from unittest.gui import TestCaseGui
128+ class myTests(TestCaseGui):
129+
130+ def testOne(self):
131+ self.assertEqual(double(2),4,"double(2)")
132+ self.assertEqual(double(3),6,"double(3)")
133+ self.assertEqual(double(-1),-2,"double(-1)")
134+ self.assertEqual(double(0),0,"double(0)")
135+ self.assertEqual(double(11),22,"double(11)")
136+
137+ myTests().main()
138+
122139
123140
124141Solving Write Code Problems with an Adaptive Mixed-up Puzzle as Scaffolding
You can’t perform that action at this time.
0 commit comments