-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions logic.py
More file actions
137 lines (98 loc) · 2.86 KB
/
functions logic.py
File metadata and controls
137 lines (98 loc) · 2.86 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
### Questions:###
# Q.1: STRING concept:
# Question 1: Basic String Tools
# Sawal: Ek string ko ulta (reverse) print karein, uski length batayein, use bade aur chhote letters mein badlein aur dusri string mein copy karein.
'''
s = "Python"
# 1. Reverse (Slicing use karein)
print("Reverce = " , s[::-1])
# 2. Length
print("kitne letters hai =" , len(s))
# 3. Uppercase & Lowercase
print(s.upper())
# 4. Copy (Sirf assignment se ho jata hai)
s2 = s
print(s2)
'''
# Question 2: Arrange by Case
# Sawal: String ke characters ko aise set karein ki saare chhote (lowercase) letters pehle aayein aur bade (uppercase) baad mein.
'''
a = "mY namE IS ramSHA"
b = ''
#lower case show
for i in a:
if i.islower():
b = b + i
print(b)
#upper case show
for i in a:
if i.isupper():
b = b + i
print(b)
#apni jgh pr rehte hoe ulte hojae positions unki
a = "mY namE IS ramSHA"
b = a.split()
print(b)
#reverse case show
print(b, a[::-1])'''
#Question 3: Count Chars, Digits, and Symbols
#Sawal: Di gayi string str1 = "P@#yn26at^&i5ve" mein letters, numbers aur symbols ki ginti karein.
'''
str = "P@#yn26at^&i5ve"
char = 0
digit = 0
symbols = 0
for i in str:
if i.isalpha(): #Alphabets check krne k lye
char = char + 1
elif i.isdigit(): #digit check krne k liye
digit = digit + 1
else: #symbols chech krne k liye koi method nh
symbols = symbols + 1
print(f"chars are: {char},\n digits are: {digit},\n symbols are: {symbols} ")
'''
#Question 4: Count Vowels
#Sawal: Kisi bhi string mein vowels (a, e, i, o, u) ki ginti karein.
'''
a = "hello this is me ramsha, i am learning python from start"
vowel = 0
const = 0
for i in a:
if i in "aeiouAEIOU":
vowel = vowel + 1
elif i == ' ': # spaces ko hatane k liye continue use kya
continue
else:
const = const + 1
print(f'your total vowel used in this sentence: {vowel}\n and Constants are {const}')'''
# isi poori question ka function bnana hai
'''def vowelcounter(x):
vowel=0
const=0
for i in x:
if i in "aeiouAEIOU":
vowel = vowel + 1
elif i == " ":
continue
else:
const = const + 1
return f'your total vowel used in this sentence: {vowel}\n and Constants are {const}'
a = "hello this is me ramsha, i am learning python from start"
b = "hello this is me Ammar, i am learning python from start"
print(vowelcounter(a))
print(vowelcounter(b))'''
#Question 5: Count Vowels
#Sawal: Check karein ki kya string "Palindrome" hai (matlab seedha aur ulta ek jaisa).
'''word = "Ramsha"
b = ' '
for i in range(len(word)-1,-1,-1):
b = b + word[i]
# if word == word [::-1]: #direct wdout loop
# print("this is palindrome")
# else:
# print("not a palindrome")
if word == b: #with loop ye hoga process
print("this is palindrome")
else:
print("not a palindrome")
'''