-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
85 lines (58 loc) · 1.42 KB
/
functions.py
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
"""
Write a Python function to sum all the numbers in a list.
Sample List : (8, 2, 3, 0, 7)
Expected Output : 20
Explanation:
Summation should like 8+2+3+0+7 = 20
"""
def sums(*list1):
tot = 0
for i in list1:
tot +=i
return tot
print(sums(2,3,5,5))
"""
Write a Python program to reverse a string.
Sample String : "1234abcd"
Expected Output : "dcba4321"
"""
def sums(*list1):
tot = 0
for i in list1:
tot +=i
return tot
print(sums(2,3,5,5))
#Output
#Enter the string68tgylo,
#Here is the reverse of the given string: ,olygt86
"""
Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters.
Sample String : 'The quick Brow Fox'
Expected Output :
No. of Upper case characters : 3
No. of Lower case Characters : 12
"""
def uplo(string):
LowCase = 0
UpCase = 0
other = 0
for x in string:
if x.isupper():
UpCase += 1
elif x.islower():
LowCase += 1
else:
other += 1
print("No.of Lowercase is ",LowCase)
print("No.of UpperCase is", UpCase)
print("No.of Otherkeys is", other)
return ""
Str = input("Let's check how many Lowercase and Uppercase in this string")
print(uplo(Str))
#Output
"""
Let's check how many Lowercase and Uppercase in this stringdfhu78erwhfqwehiofDFS
No.of Lowercase is 16
No.of UpperCase is 3
No.of Otherkeys is 2
"""