-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtemplate.py
executable file
·56 lines (46 loc) · 1.35 KB
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
<<<<<<< HEAD
=======
# Template for Isaac
>>>>>>> 26723bb9b43ae9671fb3fdacd4c5c1eb367a3cb3
import os, sys
def example_function(a,b,c=17.5,d=True):
"""
This is an example function
a: A number that must be handed to the function
b: A number that must be handed to the function
c: A value that can be handed to the function but if not
has a default value of 17.5
d: A value that can be handed to the function but if not
has a default value of True
NOTE: Variables with default values must be given after
variables that do not
"""
# Now just code in the function
sum = a+b+c
if d:
print 'd = True'
else:
print 'd != True'
return sum
def main():
"""
This is the main function.
"""
# A clean way to ask for user input
try:
# Attempt to retrieve required input from user
prog = sys.argv[0]
a = float(sys.argv[1])
b = float(sys.argv[1])
except IndexError:
# Tell the user what they need to give
print '\nusage: '+prog+' a b (where a & b are numbers)\n'
# Exit the program cleanly
sys.exit(0)
# Execute the function defined above
sum = example_function(a,b)
print 'sum =',sum
# This executes main() only if executed from shell
if __name__ == '__main__':
main()