Getting started with Python: asking for all the 1-2+3-4+5...99 and (self-writing)

Source: Internet
Author: User

1 #!/usr/bin/env Pyhton2 #-*-coding:utf-8-*-3 #all numbers of 1-2+3-4+5...99 and (self-written)4 """5 give X a value of 0, assign Y to 0,while true, loop to start6 if the remainder of X and 2 equals 0, then X is an even number, and y assigns equal to Y minus x .7 Otherwise, x is an odd number, and Y's assignment equals y plus x.8 if x equals 100, break jumps out of the current loop, and X is assigned equal to X plus 11 straight loop to x equals to9 Print yTen """ Onex =0 Ay =0 -  whileTrue: -     if0 = = x% 2: they = y-x -     Else: -y = y +x -     ifX ==100: +          Break -x + = 1 +      A Print(y)

Getting started with Python: asking for all the 1-2+3-4+5...99 and (self-writing)

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.