File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ line - gcd.py:11
1414-- 11 import sys
1515 11 -> import sys
1616Set stopping is off.
17- line - gcd.py:13
18- line - gcd.py:26
19- line - gcd.py:40
20- (gcd.py:40 ): <module>
21- -- 40 if __name__==' __main__' :
22- 40 -> if __name__==' __main__' :
17+ line - gcd.py:14
18+ line - gcd.py:27
19+ line - gcd.py:42
20+ (gcd.py:42 ): <module>
21+ -- 42 if __name__ == " __main__" :
22+ 42 -> if __name__ == " __main__" :
2323trepan3k: That's all, folks...
Original file line number Diff line number Diff line change 1010"""
1111import sys
1212
13+
1314def check_args ():
1415 if len (sys .argv ) != 3 :
1516 # Rather than use sys.exit let's just raise an error
1617 raise Exception (f"Need to give two numbers; got: { sys .argv } " )
1718 for i in range (2 ):
1819 try :
19- sys .argv [i + 1 ] = int (sys .argv [i + 1 ])
20+ sys .argv [i + 1 ] = int (sys .argv [i + 1 ])
2021 except ValueError :
21- print ("** Expecting an integer, got: %s" % repr (sys .argv [i ]))
22+ print (f "** Expecting an integer, got: { repr (sys .argv [i ])} " )
2223 sys .exit (2 )
23- pass
2424 pass
2525
26- def gcd (a ,b ):
27- """ GCD. We assume positive numbers"""
26+
27+ def gcd (a , b ):
28+ """GCD. We assume positive numbers"""
2829
2930 # Make: a <= b
3031 if a > b :
31- (a , b ) = (b , a )
32- pass
32+ (a , b ) = (b , a )
33+ pass
3334
3435 if a <= 0 :
3536 return None
36- if a == 1 or b - a == 0 :
37+ if a == 1 or b - a == 0 :
3738 return a
38- return gcd (b - a , a )
39+ return gcd (b - a , a )
40+
3941
40- if __name__ == ' __main__' :
42+ if __name__ == " __main__" :
4143 check_args ()
4244
4345 (a , b ) = sys .argv [1 :3 ]
44- print ("The GCD of %d and %d is %d" % ( a , b , gcd (a , b )) )
46+ print (f "The GCD of { a } and { b } is { gcd (a , b )} " )
4547 pass
You can’t perform that action at this time.
0 commit comments