Strings Checklist

Try everything on this checklist and show your teacher when you are done.

  • Concatenate two strings together using “+”
  • Use str() function to convert a number to a string.
    Starter Code:

    number = 125
    text = 
    
  • concatenate a string with a number; use str() to make the number into a string first
    Starter Code:

    #Try this code, read the error, fix it
    x = 38
    z = "number of waffles eaten: "
    sentence = z + x
    print(sentence)
    
  • Store character number 3 from a string into a variable named m
    Starter Code:

    mytext = "spider monkey"
    m = 
    
  • Print the 2nd last character of a string (hint: negative numbers)
    Starter Code:

    activity = "climbing"
    
    
  • Store the first five characters of a string into a variable (hint: colon)
    Starter Code:

    word = "starting"
    root = 
    
  • Ask the user to type some text, then tell the user how many characters of text they typed. Use the len() function.
    Starter Code:

    response = input(
    
    
  • Print the last three characters of a string
    Starter Code:

    realword = "asdfghjkl"
    
    
  • Print all of the characters in a string from character #3 to the 4th last character (hint: colon and negative number)
    Starter Code:

    text = "badgoodbad"
    
    
  • Print the math problem in the starter code by printing an f-string.
    import random
    a = random.randint(10, 30)
    b = random.randint(5, 10)
    # The next line doesn't print the numbers.
    # Fix it by making it into an f-string.
    print("What is a + b"?)
    
  • Ask the user for a word. Check if it contains “E” or “e” and then tell the user whether or not the word contains that letter.(hint: if in)
    Starter Code:

    word = input('Type a word: ')
    
    
  • Print a new version of your name that moves the first two letters to the end (use index / slice / concatenate in combination)
    Starter Code:

    name = "yourname" #edit the string literal
    newname = 
    
  • Convert your name to all uppercase characters using upper() function and store this value into a variable
    Starter Code:

    name = "yourname" #edit the string literal
    loudname = 
    
  • Combine the variables’ data into a sentence that says “Your number is 42. Thanks for reading.” and store that data in a variable called sentence.
    Starter code:

    pre = "Your number is:"
    num = 42
    post = "Thanks for reading."
    
    
  • Create a program that asks the user to type a word in any combination of upper and lowercase. Then the program prints the word with the first letter capitalized and the rest in lowercase.
    Starter Code:

    #use input command, store into a variable
    #use slice / upper() / lower() to change the data
    #print the new version
    
  • Ask a user to create a password. Check if the password is at least 8 characters long, then tell them if it is a valid password or not.
    Starter Code:

    pw = input('Enter a new password: ')
    
    
  • Create a program that asks the user’s name and checks if the first letter of a name is a vowel. It should either print “Starts with a vowel” or “starts with a consonant.” (hint: all the vowels are in “aeiou”)
    Starter Code:
    name = input(‘What\’s your name?’)

    
    
  • Create a program that asks for a word, then inserts “42” into the middle of the word and prints the new string.

If you want to learn more:

Look up and experiment with some more string functions such as count(), index(), split(), strip(), and join(). They all do useful things.

You can find places that explain these functions; For example, here is the w3schools page for the join() function.

Here’s the w3Schools page listing all of the Python string functions.