String exercises in Python with solutions
#python #stringspython #stringexercises String exercises: ' This is the rat, that ate the malt that lay in the house that Jack built. ' 1. How many characters are there in the string? Count in two ways – using a function and using a for loop. 2. Check if there are the following characters in this string: , u j . d 3. How many letters a f i spaces are there in this string? 4. Print out the following words: malt house Jack 5. Replace all the words: that by the word sure the comma by an exclamation mark 6. Delete all the spaces from the beginning and the end of the string. 7. Check if after deleting the spaces the new string starts with the word This 8. Print out the new string in all upper case. 9. Print out the new string in all lower case. 10. Make only the first letter of the new string uppercase, all other letters stay lower case. 11a. Manage the following strings to get the output: Start to code right now! The strings: 'now' 'to' 'Start' 'right' '!' 'code' Feel free to add some strings or slightly modify the given strings. 11b. Manage the following variables to get the output 33 x = 4 y = '29' 12. Compare the following strings in two ways - with the len() function and without using the len() function: a) 'allosaurus' 'dimertodon' b) 'amargasaurus' 'minmi' c) '[@] 123/abc]' '[@] 123!abc]' d) 'If I rise on the wings of the dawn, if I settle on the far side of the sea’ 'If I rise on the wings of the dawn, if I settle on the far side of the Sea’ 5:40 - check your answers Python course #2 in English 12 Python programming language course in English #pythonexercises #pythonstringexercises #pythontasks #python程式設計語言 #python程式設 #程式設計語言 #程式設
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.