text
stringlengths
0
312
a={5,6,7}
print(sum(a,5))
#write a python program to implement try catch code
try:
s={5,6}
s*3
except Exception as e:
print(e)
#write a python program to count the len of unique elements
nums = set([1,1,2,3,3,3,4,4])
print(len(nums))
#write a python program to split in python
print('abcdefcdghcd'.split('cd', 2))
# write a python program to add title to string
print('ab cd-ef'.title())
# write a python program to print equal lenght of string
print('ab'.zfill(5))
# write a python program to use string replace
print('abcdef12'.replace('cd', '12'))
# write a python program to check string istitle
str1 = 'Hello!2@#World'
if str1.istitle():
print('Yes string is title')
# write a python program to do lstrip on string
print('xyyzxxyxyy'.lstrip('xyy'))
# write a python program to check identifier/keyword
print('for'.isidentifier())
# write a python program to check is an num/int
print('11'.isnumeric())
# write a python program to check is an variable is printable
print('1@ a'.isprintable())
# write a python program to check it contains any space
print(''''''.isspace())
# write a python program to check is an title
print('HelloWorld'.istitle())
# write a python program to check is all are num/int
print('ab,12'.isalnum())
# write a python program to check is all are alphanumeric
print('ab'.isalpha())
# write a python program to check is all are digit
print('0xa'.isdigit())
# write a python program to use f string
var1 = 'python language'
print(f'f-string is an good feature in {var1}')
# write a python program to iterate an dict and concatenate
D=dict(p='san', q='foundry')
print('{p}{q}'.format(**D))
# write a python program to replace blank space to 1
a='1 0 0 1'
print(a.replace(' ', '1'))
# write a python program to explain the generator
def f11(x):
yield x+1
g=f11(8)
print(next(g))
# write a python program to replace blank space to 1
def f12(x):
yield x+1
print("test")
yield x+2
g=f12(9)
print(next(g))
# write a python program to replace blank space to 1
a = re.compile('[0-9]')
z= a.findall('3 trees')
print(z)
# write a python program to print current working directory
import os
print(os.getcwd())