Note: all topics are in one blog
hey 😎
Level 1: sequential structure
Task description
The most basic structure of the program is the sequential structure. The sequential structure is that the program executes each statement from top to bottom according to the statement order.
This level requires learners to understand the sequential structure and exchange the values of changeone and changewo for the three input numbers changeone, changewo and plus, and then calculate the value of changeone + plus.
Test description
The test file of this level is src/step1/inTurntest.py. The test process is as follows:
Learners complete the code supplement in src/step1/inTurn.py, and then click evaluation. The platform automatically compiles and runs inTurntest.py, and provides evaluation input in standard input mode;
The platform takes the output of the program and compares it with the expected output. If it is consistent, the test passes, otherwise the test fails.
The following is the sample test set of src/step1/inTurntest.py on the platform:
Test input:
2
5
10
Expected output:
15
changeOne = int(input()) changeTwo = int(input()) plus = int(input()) # Please add code here, exchange the values of changeOne and changeTwo, and then calculate the values of changeOne, plus and result ########## Begin ########## changeOne, changeTwo = changeTwo, changeOne result = changeOne + plus ########## End ########## print(result)
Level 2: select structure: if else
Task description
The second structure of the program is the selection structure. In this structure, the program determines which code block to run next by judging one or several code blocks. The following scenario restores the real scene of the selected structure:
A company determines the increase of employees' wages according to their length of service, as follows:
When the length of service is greater than or equal to 5 years and less than 10 years, the increase is 5% of the current salary;
When the length of service is greater than or equal to 10 years and less than 15 years, the increase is 10% of the current salary;
When the length of service is greater than or equal to 15 years, the salary increase is 15%.
The task of this level is to let learners understand the selection structure and learn to use the most basic selection statement: if else statement.
Test description
The test file of this paper is src/step2/choosetest.py. The specific test process is as follows:
Learners complete the code supplement in src/step2/choose.py, and then click evaluation. The platform automatically compiles and runs choosetest.py, and provides evaluation input in standard input mode;
The platform takes the output of the program and compares it with the expected output. If it is consistent, the test passes, otherwise the test fails.
The following is a sample test set of src/step2/choosetest.py on the platform:
Test input:
10
Expected output:
Wages rose by 10%
workYear = int(input()) # Please fill in the judgment statement if workyear < 5 below ########## Begin ########## if workYear < 5: ########## End ########## print("The wage increase was 0") # Please fill in the judgment statement if workyear > = 5 and workyear < 10 below ########## Begin ########## elif workYear >= 5 and workYear < 10: ########## End ########## print("Wages rose by 5%") # Please fill in the judgment statement if workyear > = 10 and workyear < 15 below ########## Begin ########## elif workYear >= 10 and workYear < 15: ########## End ########## print("Wages rose by 10%%") # Please fill in the judgment statement below when the above conditions are false ########## Begin ########## else: ########## End ########## print("Wages rose by 15%")
Level 3: selection structure: ternary operator
Task description
In addition to if else and elif, there is a ternary operator in the selection structure of the program. The ternary operator also judges which code block to execute according to conditions, but its biggest feature is that it does not need to write multiple lines of code like if else statements, but only one line of code.
This level requires learners to learn and use ternary operators to judge who is the winner of shooting competition.
Test description
The test file of this paper is src/step3/isWintest.py. The specific test process is as follows:
Learners complete the code supplement in src/step3/isWin.py, and then click evaluation. The platform automatically compiles and runs isWintest.py, and provides evaluation input in standard input mode;
The platform takes the output of the program and compares it with the expected output. If it is consistent, the test passes, otherwise the test fails.
The following is a sample test set of src/step3/isWintest.py on the platform:
Test input:
13
15
Expected output:
jerry
jimscore = int(input()) jerryscore = int(input()) # Please add code here to judge that if jim's score jimscore is higher, the winner is jim; if jerry's score jerryscore is higher, the winner is jerry, and output the winner's name ########## Begin ########## winner = 'jim' if jimscore > jerryscore else 'jerry' ########## End ########## print(winner)