1. tmp = "Good Day"; print( tmp[2:4]) tmp = "John Doe"; print( tmp[5: ] ) Exact Output: 2. sentence = "Hi Bye" tmp = list(sentence); print(tmp) Exact Output: 3.Use a string method to PRINT True if a string cost contains only numbers. Use a string method to PRINT True if a string name contains only letters. Use a string method to PRINT True if a string tmp contains only numbers or letters. Use a string method to PRINT True if a string tmp contains only whitespace.
This is a python programming class
1. tmp = "Good Day"; print( tmp[2:4])
tmp = "John Doe"; print( tmp[5: ] )
Exact Output:
2. sentence = "Hi Bye"
tmp = list(sentence); print(tmp)
Exact Output:
3.Use a string method to PRINT True if a string cost contains only numbers.
Use a string method to PRINT True if a string name contains only letters.
Use a string method to PRINT True if a string tmp contains only numbers or letters.
Use a string method to PRINT True if a string tmp contains only whitespace.
4. Use a string method to PRINT how many times the letter 'e' appears in a string called sentence
print( )
5. Use a string method to PRINT the number of characters in a string tmp
print( )
6. Use a string method to PRINT the location of the LAST period in a string tmp
Use a string method to PRINT the location of the FIRST period in a string tmp
print( )
print( )
7. Use a string method to change all of the periods in tmp to commas
print( )
8. Use a string method to print True if a string url has the word 'edu' at the end
Use a string method to print True if a string phone has the area code '218'
9. Use a string method to get rid of all leading and trailing spaces in a string tmp
10. sentence = "Hi Bye";
tmp = sentence.split(" "); print(tmp)
sentence = "hello!"
tmp = sentence.split(" "); print(tmp)
Exact Output:
11.
stuNames = ("John", "Peter", "Vicky")
x = "#".join(myTuple)
print(x)
phEls=['218','477','2339'];phoneNum="-"
phoneNum.join(phEls); print(phoneNum)
myList = ['a','e','i','o','u']; print("".join(myList))
Exact Output:
Short Coding:
1. For a name which will always begin with Mr. or Mrs., or Ms., use a PYTHON string method to determine if the person is male or female.
2. For an email address use a PYTHON string method to PRINT "education" if it is an educational site (.edu) , "government" if it is a government site (.gov), "business" if it is a business (.com), or a "Non-Profit" if it is a non-profit (.org).
3. Suppose tmp contains a string that indicates cost of an item, and it contains a leading $ and may contain commas and one period. Example: tmp = "$5,234.
Write Python code to remove the dollar sign and comma from tmp, change it to a number and double it.
4. Write Python to print the number of vowels in a sentence entered by the user.
5. Write function called myFind which accepts a 2 strings as parameters (tmp and strToFind) and returns the location of the first occurrence of strToFind in tmp . You may NOT use Python's built-in find OR rfind OR index functions.
6. Write function called myIsDigit which accepts a single parameter (a string) and returns True if every character in the string is a digit and False otherwise. You may NOT use Python's isdigit method.

Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images









