A Python code statement takes three days of normal sleep (about code indentation)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.