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

write a python program to make use of modulo operator

print(f'modulo 15 % 4: Sol->{15 % 4}')

write a python program to explain enclosing and global scope

x = 'global'

def f():
    x = 'enclosing'
    def g():
        print(x)
    g()
    return x
obj1 = f()
print('explain global scope:',obj1)

write a python program to expain local and global scope

def f1():
    x = 'enclosing'
    def g():
        x = 'local'
        return x
    x=g()
    return x
obj2 = f1()
print('explain local scope:',obj2)

write a python program to make use of regular expression for matching

import re
print('Find the characters in the given string:',re.findall(r'[a-z]+', '123FOO456', flags=re.IGNORECASE))

write a python program to make use of regular expression for matching

s = 'foo123bar'
m = re.findall('123', s)
print('find the number position:',m)

write a python program to convert lower string to UPPERCASE

a = 'string'
print(f'convert lowercase to uppercase:{a.upper()}')

write a python program to convert uppercase string to lower

a = 'STRING'
print(f'convert lowercase to uppercase:{a.lower()}')

write a Python Program to Find the Square Root

num = 8 

num_sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))