-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.py
More file actions
34 lines (27 loc) · 936 Bytes
/
Copy pathFunctions.py
File metadata and controls
34 lines (27 loc) · 936 Bytes
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
# Creating functions in python
# Generally functions in Python have can return a value.
# If a function doesnot return anything it will cause effect than returning anything.
# Try to write python functions which return a value and value its returned value is used someehre else than just printing somewhere.
# Python functions are declared using 'def' keyword.
def squareNumbers(x):
if x is int:
return x*x
else:
return "Input is not an integer!"
print("This is square of numbers")
print(squareNumbers(10))
# Create a sentence former using functions.
def ordinal(value):
endRoot = str(value)
if endRoot.endswith('1'):
return "st"
elif endRoot.endswith('2'):
return "nd"
elif endRoot.endswith('3'):
return "rd"
else :
return "th"
def ordinalValue(value):
return str(value) + ordinal(value)
print("Enter the number here!")
print(ordinalValue(input()))