There's a third grade question:
Big
Everyone
Hello everyone
Hello, everyone.
2 0 0 1
Everybody good + everybody good + everybody + big =2001 beg big =? Home =? Good =? Ah =?
Here's the code:
#!/usr/bin/env python
#coding: Utf-8
Import Os,sys
"""
Big
Everyone
Hello everyone
Hello, everyone.
2 0 0 1
"""
def sum (num):
#with Open Num.txt as F:
If Os.path.exists (' Num.txt '): # To determine if a file exists
If Os.path.getsize (' Num.txt '): # Determines if the file is empty
F=open (' Num.txt ', ' A + ') # Open file in Append mode
F.truncate () # Empty file contents
Else
Os.mknod (' Num.txt ')
F=open (' Num.txt ', ' A + ')
For d in range (10):
For j in Range (10):
For h in range (10):
For a in range (10):
Sum=d*1000+d*100+d*10+d+j*100+j*10+j+h*10+h+a
F.write ('%s,%s,%s,%s =%s \ n '% (d,j,h,a,sum))
if sum = = Int (num):
Print D,j,h,a
if d==j==h==a = = 9:
Print "%s is a last num"% sum
Print "Please input the num must less than%s"% sum
F.close ()
If __name__== ' __main__ ':
If Len (sys.argv) = = 1:
SUM (2001)
Elif len (sys.argv) = = 2:
Sum ("%s"% sys.argv[1])
Else
Print "Use:python%s%s"% (sys.argv[0], ' num ')
Hello, everyone. =2001 using Python to calculate