Skip to content

Latest commit

 

History

History
59 lines (58 loc) · 2.32 KB

File metadata and controls

59 lines (58 loc) · 2.32 KB

PYTHON STRINGS

Answer each question with a code solution.

  1. Create a string and print it.
  2. Take a string input and print it's length.
  3. Print the last word of the string Python is great using slices.
  4. Print the each word in different line of string python is everywhere.
  5. Print the string Hello World! in reverse.
  6. Convert the string How are you? in uppercase.
  7. Convert the string How Is It Going? in lowercase.
  8. Join the following list by spaces( ) and print the result.
    words = ['Python', 'is', 'easy', 'to', 'learn']
  9. Print a multiline string using a single print
  10. Print this string to move to newline '\n' is used. (results should look exactly like the provided string)
  11. Print a variable with some text using a single print function, output should look like following.
    the variable is 15
    
  12. concatenate the following strings and print the result
    s1 = 'python '
    s2 = 'is '
    s3 = 'great.'
  13. Print # 20 times without using a loop
  14. Print numbers from 1 to 9, each on a seperate line, followed by a dot, output should look like the following-
    1.
    2.
    3.
    
    
  15. Ask user to input a sentence and print each word on a different line.
  16. Ask user to input a string and check if the string ends with '?'
  17. Ask user to input a string and print how many times e appeared in the string
  18. Check if the user input is a number.
  19. Remove the extra spaces in beginning and in the end of the following string-
    text = '   this is not a good string           '
  20. Ask user to input string, print found if any of the character is upper case.
  21. Extract names from the following string and store them in a list.
    names = 'Joe, David, Mark, Tom, Chris, Robert'
  22. In the following string, add aye in the end of every word and print the results.
    text = 'this is some text'
  23. ask user to enter a string and check if the string contains fyi
  24. Remove all the special characters and numbers from the following string
    text = '%p34@y!*-*!t68h#&on404'
  25. calculate the average word length of the following paragraph.
    this is a paragraph which is written just for the purpose of providing content to let the average word length be calculated