1 #!/usr/bin/env python2 #-*-coding:utf-8-*-3 #1-99 a few and a few equations4 #Start (start, transliteration: Think two) sum (total, transliteration: Kuwagi) Temp (temporary employee, transliteration: Shanwa)5 """6 Assign value to s to a blank string, start assignment is 1,sum assignment is 0,start less than 100 while loop is true,7 the assignment of temp equals the remainder of start and 2, if temp equals 1, if start equals 1,s the assignment equals start8 and converted to a string type, otherwise the assignment of s equals s Plus + (connector) plus string Plus + + String type start,9 sum is assigned equal to sum plus start, otherwise the assignment of s equals s Plus + + string minus + + String type start,Ten The assignment of sum equals sum minus Start,start is equal to start plus 1, which is added to the 99,while loop as false! One print S, print sum! A """ -s ="" -Start = 1 thesum =0 - whileStart < 100: -temp = start% 2 - ifTemp ==1: + ifStart ==1: -s =Str (START) + Else: As = s +"+"+Str (START) atsum = sum +Start - Else: -s = s +"-"+Str (START) -sum = Sum-Start -Start + = 1 - Print(s) in Print(sum)
Getting started with Python: 1-99 of the equations