-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.py
More file actions
40 lines (29 loc) · 1.03 KB
/
Copy pathFunctions.py
File metadata and controls
40 lines (29 loc) · 1.03 KB
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
'''
Created on Nov 27, 2021
@author: Prasanga Fernando
'''
def printName(name):
print(name)
def welcomeNote():
print("Hello.. welcome to test run")
welcomeNote()
printName("Prasanga")
printName("Supun")
printName("Kaveesh")
#Function with return values
def addTwoNumbers(x,y):
return (x+y)
sum = addTwoNumbers(10,21)
print(sum)
#default parameters
def studentDetails(name="Supun", marks=70):
print(name, "scored", marks)
studentDetails() #This will print the default value
studentDetails("Kamal", 20) #This will override the default values
studentDetails("Janith") #This will override only the name
studentDetails(marks=60) #This will override only the marks (If we are calling the second parameter, we have to specify that within the brackets. Otherwise it will override the first parameter
#Passing multiple parameters with Python functions
def studentMarks(name, *marks):
print(name)
print(marks)
studentMarks("Sudath", 43,23,56,73) #This will print as a tuple. We cannot add or remove data from tuple