#!/usr/bin/python
import sys
for args in sys.argv:
print(args)
"""
If you were to call the program with subsequent arguments, the output
will be of the following
Call:
python3 sys.py homie no
Output:
sys.py
homie
no
"""
import sys
print ("the script has the name %s" % (sys.argv[0])
# Here we define the function with a parameter
def greet(lang):
if lang == 'spanish':
print('Hola!')
elif lang == 'french':
print('Bonjour!')
else:
print('Hello!')
# Now we can call or invoke the function with different parameters
greet('spanish') # Output - Hola!
greet('french') # Output - Bonjour!
greet('english') # Output - Hello!
def sum(a,b):
return a+b
def calculate(function,a,b):
return function(a,b)
calculate(sum,3,4)
#returns 7
def greet(name, msg):
"""This function greets to
the person with the provided message"""
print("Hello", name + ', ' + msg)
greet("Monica", "Good morning!")