How to compile Python return code

Source: Internet
Author: User

Some people may encounter many problems when writing code. Next, let's look at how to write the relevant code. I hope you will gain some benefits in future use. The use of the Python return programming language requires constant discussion.

 
 
  1. # Coding: UTF-8
  2. Def testReturn (x ):
  3. If x> 10000:
  4. Return
  5. Print "test return !! "# This sentence will never be executed
  6. El'if x> 1000:
  7. Return 100
  8. El'if x> 100:
  9. Return 10
  10. Elif x> 10:
  11. Return 1
  12. Else:
  13. Return 0
  14. Print testReturn (9999999) # result = None
  15. Print testReturn (9999) # return = 100
  16. Print testReturn (999) # return = 10
  17. Print testReturn (99) # return = 1
  18. Print testReturn (9) # return = 0
  19. # Return instructions:
  20. # (1) return the return value of the Function
  21. # (2) Terminate the program and exit early

The above is an introduction to problems related to the Python return language. I hope you will have some gains.

Related Article

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.