Facebook
From Monkey d liffy, 6 Months ago, written in Python.
This paste is a reply to Re: op out of ur legue from monkey d luffy - go back
Embed
Viewing differences between Re: op out of ur legue and op out of ur legue op
Write a recursive function to print the factorial for a given number.
def recur_factorial(n):
if n==1:
return
n
else:
return n*recur_factorial(n-1)
num=int(input("Enter Number"))
if num<0:
print("Enter valid number")
elif num==0:
print("factorial of 0 is 1")
else:
print("The factorial of",num,"is",recur_factorial(num))
Enter Number 5
The factorial of 5 is 120


a. Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel,
False otherwise.
def isvowel(char):
all_vowel='aeiou'
return char in all_vowel
print(isvowel('a"))
print(isvowel('b'))



b. Define a function that computes the length of a given list or string
def len(s):
counter=0
for i in S:
counter+=1
return counter
s=input("enter string:")
print(len(s))


b. Define a function that computes the length of a given list or string
def len(s):
counter=0
for i in S:
counter+=1
return counter
s=input("enter string:")
print(len(s))



C.
example, histogram ([4, 9, 9, 7]) 7]) should print the following:
****
def histogram(items):
for n in items:
output=''
times=n
while times>0:
output+='*'
times=times-1
þprintCoutput)
histogram([4,9,7])



Design a class that store the information of student and display the same
class student:
def info(self,name,city):
name=input("Enter name:")
city=input("Enter city:")
print("Name:",name,"City:",city)
1/4
:::
obj=student()
obj.info('Name','City')
Enter name:Bob
Enter city:Atlanta
Name: Bob City: Atlanta




b. Implement the concept of inheritance using python
Note: Create polygon.py, rectangle.py and inherit.py file in same project run the inherit project
class polygon:
width=0
height=0
def set_values(self,width,height):
polygon.width=width
polygon.height=height
Python Programming Practical
S.Y.B.Sc (IT)
from polygon import*
class rectangle(polygon)
def area(self):
return self.width*self.height
from Rectangle import*
rect=rectangle()
rect.set_values(10,10)
print("Area of Rectangle:",rect.area())
Area of Rectangle: 100
  
  enjoy

Replies to op out of ur legue op rss

Title Name Language When
Re: op out of ur legue op Rajubhai python 6 Months ago.
Re: op out of ur legue op Suraj python 6 Months ago.