-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice8.py
More file actions
82 lines (58 loc) · 2.1 KB
/
Copy pathpractice8.py
File metadata and controls
82 lines (58 loc) · 2.1 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#write a program using fucntion to find greatest of three number
def maximum(num1,num2,num3):
if (num1 > num2):
if(num1>num3):
return num1
else:
return num3
else:
if(num2>num3):
return num2
else:
return num3
m = maximum(5,3000,324)
print("The maximum value is : " + str(m))
#write a python program using function to convert celcius to farenhide
def convert(cel):
return(cel*(9/5)) + 32
c = 70
f = convert(c)
print("FArenhide Teperature is : " + str(f))
#how do you prevent a python print() function to print a new line at the end
print("Hello", end = " ")##end = "" use kre
print("How", end = " ")
print("are", end = " ")
print("you?", end = " ")
#a recursive finction to calcualte the sum of first natural number
def calculate(n):
if (n == 0):
return n
else:
return n + calculate(n - 1)
print(calculate(4))
#write a python function to remove a given word from a string and strip it at the same time
def remove_split(string,word):
newStr = string.replace(word,"")#remove the word
return newStr.strip()
this = " Harry is a good boy "
n = remove_split(this,"Harry")
print(n)
###################################################################################################################################################################################################
this = "he is a boy"
x = this.split()
print(x)
# bracket er vitore ki kisu bosale jekhane jekhaneoi carracter ta pabe sekhane sekhane split korbe
#example:
text = 'geeks for geeks'
# Splits at space
print(text.split())
word = 'geeks, for, geeks'
# Splits at ','
print(word.split(','))
word = 'geeks:for:geeks'
# Splitting at ':'
print(word.split(':'))
word = 'CatBatSatFatOr'
# Splitting at t
print(word.split('t'))
##########################################################################################################################################################################################################