Little Turtle Python Video sixth lecture (after-school exercise)

Source: Internet
Author: User
Tags floor division

1.floor Division (this is only about division, others do not mention)

In Python3, there are two kinds of division operations, one is true, the other is floor division, and the two are separate, as shown in the code:

2. Use of power (* *)

A = 2**2**32= (2 **2) **32

3. For an even and odd number within 100, pay attention to the difference between the code.

# for an even number within 100 (inclusive)num = when num            :     if num% 2        :Print  ()    Else:        print(num)    = num-1
 #   ask for an even number within 100 (not included)  num = 100while   Num:num  = num-1 if  num% 2:  print           ()  else  :  print   (num)  
# for an odd num = 100 or less num :    = num-1    if num% 2:        print
    (num)    Else:        print()    

4, find factorial

i = 1x= 7Flag=0 whileI < 100: I= i + 1if(x%2==1) and(x%3==2) and(x%5==4) and(x%6==5): Flag= 1Else: x= 7*IifFlag ==1:    Print("the number of steps is:", X)Else:    Print("please expand the range! ")

Elementary Turtle Source Code:

x = 7I= 1Flag=0 whileI <= 100:    if(x%2 = = 1) and(x%3 = = 2) and(x%5 = = 4) and(x%6==5): Flag= 1Else: x= 7 * (i+1)#according to test instructions, x must be an integer multiple of 7, so multiply by 7 each time .i + = 1ifFlag = = 1:    Print('the number of steps is:', X)Else:    Print('can't find the answer within the limits of the program! ')

Little Turtle Python Video sixth lecture (after-school exercise)

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.