Introduction

Please read the following, watch the videos, and try to solve the problems.

Solving Write Code Problems

If you see a problem like the one below you will need to write Python code. The problem will have unit tests that you can run to check that your code is working correctly. Click on the “Run” button to compile and run your code. Look after the code area for compiler errors and/or unit test results.

See the video below for an example.

Try to finish writing the code for the following problem.

Write a function called double(num) that takes a number num and returns the number times 2. For example, double(2) should return 4. Look below the code to check for any compiler errors or the results from the test cases.

Write Code with Pop-Up Mixed-up Code

You may also see a write code problem that allows you to pop-up the equivalent mixed-up code problem. You can use this problem to help you solve the write code problem. To pop-up the mixed-up code problem click on the drop down near the top of problem.

Solving Mixed-up Code Problems

If you see a problem like the one below you will need to put the mixed-up code in the correct order on the right side. You may need to indent the blocks as well. There may also be extra blocks that are not needed in a correct solution that you can leave on the left side. Click the “Check” button to check your solution.

See the video below for an example.

Try to solve the following mixed-up code problem. This problem doesn’t require any indentation.

Drag the blocks from the left and put them in the correct order on the right. The text in each block defines the order.

Try to solve the following mixed-up code problem. This problem requires indentation.

Drag the blocks from the left and put them in the correct order on the right with the correct indentation. The text in each block defines the order and indentation.

Try to solve the following mixed-up code problem. This problem requires indentation and has extra blocks that are not needed in a correct solution.

Drag the blocks from the left and put them in the correct order on the right with the correct indentation. There is an extra block that is not needed in the correct solution.

The mixed-up code problems have a “Help me” button at the bottom of the problem. Once you have checked at least three incorrect solutions you can click the button for help. It will remove an incorrect code block, if you used one in your solution, or combine two blocks into one if there are more than three blocks left.

See the video below for an example.

Feedback

Q-9: Please provide feedback here. Please share any comments, problems, or suggestions.

What to do next

Click on the following link to learn how to solve different types of problems in this ebook : Introduction to Classes

You have attempted of activities on this page