python popular codes
python popular codes
3) tuple1= (50, )
print(tuple1)
a, b, c, d = tuple1
print(a)
print(b)
print(c)
print(d)
tuple2 = tuple1[3:-1]
print(tuple2)
print(tuple1)
res = 0
for i in range(len(s)) :
PYTHON ASSINGNMENT
if (s[i] == c):
res = res + 1
return res
str= "geeksforgeeks"
c = 'e'
print(count(str, c))
index = list1.index(20)
list1[index] = 200
print(list1)
s1 = "India"
s2 = "China"
mix_string(s1, s2)
lower.append(char)
else:
upper.append(char)
sorted_str = ''. join(lower + upper)
print('Result:', sorted_str)
sample_str = "P@yn2at&#i5ve"
print("total counts of chars, Digits, and symbols \n")
find_digits_chars_symbols(sample_str)
21) s1 = "Abc"
s2 = "Xyz"
s1_length = len(s1)
s2_length = len(s2)
length = s1_length if s1_length > s2_length else s2_length
result = ""
s2 = s2[::-1]
for i in range(length):
if i < s1_length:
result = result + s1[i]
if i < s2_length:
result = result + s2[i]
print(result)
22)
test_sub = "Geeks"
average = sum / n
start = start + 1
end -= 1
s = list(s)
start = 0
while True:
try:
start = end + 1
except ValueError:
break
s.reverse()
s = "".join(s)
PYTHON ASSINGNMENT
print(s)
str1 = ''.join(reversed(str1))
print("Reversed String is:", str1)
26) test_string = "GfG is best for CS and also best for Learning"
tar_word = "best"
res = test_string.rindex(tar_word)
splitted_text= text.split()
(splitted_text)
28)
while("" in test_list) :
test_list.remove("")
print(new_string)
30) import re
res = []
temp = test_str.split()
res.append(idx)