Categories:Viewed: 8 - Published at: a few seconds ago

Write a python program to sum the set of unqiue elements

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))