-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions1.py
More file actions
66 lines (45 loc) · 968 Bytes
/
functions1.py
File metadata and controls
66 lines (45 loc) · 968 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#concatinate word using function
def display(s):
return s + 'd'
print(display('xyz'))
print("-----------------")
#print the square of a number
def square(sq):
return sq*sq
print(square(5))
#print the maximum number in a list
print("-----------------")
def max_num(a,b,c):
if a>b and a>c:
return a
elif b>c:
return b
else:
return c
print(max_num(1,2,3))
######################################################
# print the max number form the list
print(">>>>>>>>>>>>>>>>>>>>>")
def max_lis(a):
i=0
maxi=0
temp=0
while i<= len(a)-1:
if a[i]>maxi:
maxi = a[i]
print("greater is", a[i])
else:
temp=a[i]
a[i] = a[i+1]
i=i+1
return maxi
list = [34,58,8, 70]
print("maximum number is", max_lis(list))
#factorial question
print("factorial question")
def fact_num(num):
fact = 1
for i in range(1,num+1):
fact = fact*i
return fact
print(fact_num(5))