Program 30
Write a Python class to implement pow(x, n).
class Pow1:
def poe(self,x,n):
k=x**n
print("pow({},{})={}".format(x,n,k))
p=Pow1()
x=int(input("Enter the X value:"))
n=int(input("Enter the Y value:"))
p.poe(x,n)
Program 30
Write a Python class to implement pow(x, n).
class Pow1:
def poe(self,x,n):
k=x**n
print("pow({},{})={}".format(x,n,k))
p=Pow1()
x=int(input("Enter the X value:"))
n=int(input("Enter the Y value:"))
p.poe(x,n)
Program 31
Write a Python class to reverse a string word by word.
class Sa:
def display(self,s):
words = s.split(' ')
reverse_sentence = ' '.join(reversed(words))
print("The reverse words of string:",reverse_sentence)
k=Sa()
s = input("enter the string:")
k.display(s)
OUTPUT:
=== RESTART: C:/Users/crrcse/Desktop/30.py =======
enter the string:welcome to python
The reverse words of string: python to welcome
>>>
Program 30 Write a Python class to implement pow(x, n). class Pow1:...