"Learning Notes" python100 example

Source: Internet
Author: User

#python3下进行实验

#第一例:

Title: There are four numbers: 1, 2, 3, 4, how many different and no repetition of the number of three digits? What's the number?
Program Analysis: Can be filled in hundreds, 10 digits, single digit numbers are 1, 2, 3, 4. Make all the permutations and then remove the permutations that do not meet the criteria.

1  for                           in range (1,5):  2for in      range (1,5):  3for in          range (1,5):4             ifand   and (b! = c):5                 print(a,b,c)
method One:
1num=[1,2,3,4]2I=03  forAinchNum:4      forBinchNum:5          forCinchNum:6             if(a!=b) and(B!=C) and(c!=a):7I+=18                 Print(a,b,c)9 Print('The total is:'I
Method Two

#第二例:

#待续

"Learning Notes" python100 example

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.