Facebook
From light, 1 Year ago, written in Python.
This paste is a reply to out of ur legue from light yagami - view diff
Embed
Download Paste or View Raw
Hits: 313
  1. Write a recursive function to print the factorial for a given number.
  2. def recur_factorial(n):
  3. if n==1:
  4. return
  5. n
  6. else:
  7. return n*recur_factorial(n-1)
  8. num=int(input("Enter Number"))
  9. if num<0:
  10. print("Enter valid number")
  11. elif num==0:
  12. print("factorial of 0 is 1")
  13. else:
  14. print("The factorial of",num,"is",recur_factorial(num))
  15. Enter Number 5
  16. The factorial of 5 is 120
  17.  
  18.  
  19. a. Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel,
  20. False otherwise.
  21. def isvowel(char):
  22. all_vowel='aeiou'
  23. return char in all_vowel
  24. print(isvowel('a"))
  25. print(isvowel('b'))
  26.  
  27.  
  28.  
  29. b. Define a function that computes the length of a given list or string
  30. def len(s):
  31. counter=0
  32. for i in S:
  33. counter+=1
  34. return counter
  35. s=input("enter string:")
  36. print(len(s))
  37.  
  38.  
  39. b. Define a function that computes the length of a given list or string
  40. def len(s):
  41. counter=0
  42. for i in S:
  43. counter+=1
  44. return counter
  45. s=input("enter string:")
  46. print(len(s))

Replies to Re: out of ur legue rss

Title Name Language When
op out of ur legue light kira python 1 Year ago.