Advertisement
ZEdKasat

Strings Practice Assignments

Sep 8th, 2021
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1.  
  2. ### Strings Q1
  3. # text = input("Enter a long sentence: ")
  4. # print(text.count("the") + text.count("The"))
  5.  
  6.  
  7.  
  8. # par = '''On July 16, 1969, the Apollo 11 spacecraft launched from the Kennedy Space Center in Florida. Its mission was to go where no human being had gone before—the moon. The crew consisted of Neil Armstrong, Michael Collins, and Buzz Aldrin. The spacecraft landed on the moon in the Sea of Tranquility, a basaltic flood plain, on July 20, 1969. The moonwalk took place the following day. On July 21, 1969, at precisely 10:56 EDT, Commander Neil Armstrong emerged from the Lunar Module and took his famous first step onto the moon’s surface. He declared, That’s one small step for man, one giant leap for mankind. It was a monumental moment in human history.'''
  9.  
  10. ### Strings Q2
  11. # list_of_sentences = par.split(".")
  12. # print("\n".join(list_of_sentences))
  13.  
  14.  
  15. ### Strings Q3
  16. # word = input("Enter a word: ")
  17. # result = ""
  18. # for c in word:
  19. #   if c in "aeiouAEIOU":
  20. #       result += c.upper()
  21. #   else:
  22. #       result += c.lower()
  23. # print(result)
  24.  
  25. ### Strings 4
  26.  
  27. # resp = ""
  28. # while resp != "exit":
  29. #   resp = input("Enter your email address")
  30. #   resp = resp.lower()
  31. #   if resp.count("@") == 1 and resp.count(".") >= 1:
  32. #       print("Valid Email")
  33. #   else:
  34. #       print("Invalid Email")
  35.  
  36.  
  37. ### Strings Q5
  38. # resp = ""
  39. # while resp != "exit":
  40. #   resp = input("Hey, What do you want to do today?")
  41. #   resp = resp.lower()
  42. #   if resp == "movies":
  43. #       print("I will open Netflix")
  44. #   elif resp == "music":
  45. #       print("I'll open Spotify.!")
  46. #   elif resp == "shopping":
  47. #       print("I'll enter Amazon")
  48. #   else:
  49. #       print("Sorry I don't understand.")
  50.  
  51. ### Strings 4
  52.  
  53. # resp = ""
  54. # while resp != "exit":
  55. #   resp = input("Enter your email address")
  56. #   resp = resp.lower()
  57. #   if resp.count("@") == 1 and resp.count(".") >= 1:
  58. #       print("Valid Email")
  59. #   else:
  60. #       print("Invalid Email")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement