A Python code statement takes three days of normal sleep (about code indentation)
Requirement: A University provides a course for students to take the qualification examination. After the examination, the school wants to know the performance of its students during the examination. If the passing rate is high, it will increase the tuition fee. Now, you need to write a program to summarize the test results. Assume that there are 10 students. 1 indicates that the student has passed the test, and 2 indicates that the student has not passed the test.
1. enter each exam result (1 or 2 ). Each time you request another test result, the message "Enter result" is displayed on the screen ".
2. count the number of two types of exam results (1 and 2 ).
3. display the examination result summary, indicating the number of students who pass and fail the examination respectively.
4. If more than 8 students pass the test, a message "raise tuition" will be printed (increasing the tuition fee ).
××××××××
1. The program must process 10 test results, so a counter control loop is required.
2. Each test result is a number, except that 1 is 2. If the number is not 1, it is assumed 2.
3. Use two counters: one to count the number of students who pass the exam, and the other to count the number of students who fail the exam.
4. After processing all the results, the program must determine whether more than 8 students have passed the examination. If yes, the school will raise the tuition fee.
××××××××
Passes = 0
Failures = 0
Studentcounter = 1
While passes <= 10:
Result = raw_input ("Enter Result :")
Result = int (result)
If result = 1:
Passes = passes + 1
Else:
Failures = failures + 1
Studentcounter = studentcounter + 1 # This sentence is important
Print passes
Print failures
If passes> 8:
Print "add"
The above is the implementation code. However, in Python, you must note the indentation. There is no strict language requirement, except python. And there is no error. It depends on your logic error .. Well, I can have a good night's sleep today.