1.1. Introduction to Problem Types¶
Please read the following and try to solve the problems.
1.1.1. Solving Mixed-up Code Puzzles¶
If you see a puzzle 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.
Try to solve the following mixed-up code problem. This problem provides 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 provides 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.
1.1.2. Solving Write Code Problems¶
If you see a problem like the one below, you will need to write 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.
Write a function called sum_list that takes a list of numbers and returns the sum of all the numbers in the list. For example, sum_list([1, 2, 3]) should return 6, sum_list([10, 20]) should return 30, and sum_list([]) should return 0.
1.1.3. Practice Python Problems with LadderPuzzles - How LadderPuzzle Works¶
After reading the problem, write your initial plan in the text box — just your rough idea of how you’d approach it. Then click “Get Ladder Puzzle” to receive a mixed-up code puzzle personalized to your written plan.
Please drag and arrange the steps into the correct order to come up with a full plan.
Once you’re done, you can start writing your solution in the code editor.
- Finish a function,
phrase(person, thing): It has
personandthingas input.First verify whether
personandthingare strings. If not, returnFalse.If
personandthingare two strings, return one string with the characters inperson, followed by an empty space, and then followed bythingMake sure the first letter in
personis capitalized and all the characters inthingare lowercase.
Here is an example plan (some steps may be missing, and the order may be wrong): Capitalize the first letter of the first string, lowercase the first letter of the second string, and concatenate them together. Then check if the two inputs are strings.
You might also see a planning question that asks you to write out your plan in text. You can write out your plan in the text box.
phrase(person, thing):- It has
personandthingas input. - First verify whether
personandthingare strings. If not, returnFalse. - If
personandthingare two strings, return one string with the characters inperson, followed by an empty space, and then followed bything. - Make sure the first letter in
personis capitalized and all the characters inthingare lowercase.
Before you write code, what steps will you take to approach this problem? You can write your plan in the space below.
In this practice, you will work through 5 programming problems.
Depending on the version assigned to you, the problems will be the same but in a different order, alternating between LadderPuzzle and a planning question, with a write-code-only problem in the middle.
two problems with LadderPuzzle, one write-code-only problem, two problems with a planning question
two problems with a planning question, one write-code-only problem, two problems with LadderPuzzle