Introduction to Computer Programming

Lab 6: string methods; working on REPL projects

Instructions

  1. Try these in the IDLE shell, in order, one at a time:

    >>> name = 'Ada Lovelace'
    >>> name
    
    >>> name.upper()
    >>> name.lower()
    >>> name.isupper()
    
    >>> upped = name.upper()
    >>> upped
    
    >>> upped == name
    >>> upped.lower() == name.lower()
    >>> upped.isupper()
    
    >>> help(name.islower)
    
    >>> name[0]
    >>> len(name)
    >>> name[len(name)-1]
    >>> name[-1]
    >>> name[12]
    >>> name[-12]
    >>> name[-13]
    
    >>> help(name.find)
    
    >>> name.find(' ')
    >>> name[0:3]
    >>> name[:3]
    >>> name[4:len(name)]
    >>> name[4:]
    >>> name[4:8].lower()
    
    >>> help(name.count)
    
    >>> name.count('')
    >>> name.count(' ')
    >>> name.count('a')
    >>> name.lower().count('a')
    
    >>> name.center(20)
    >>> name.center(20, '*')
  2. From IDLE, Open the file high_low_word_guess.py from the high_low_word_guess folder. Read over the file.

  3. Run the module in IDLE and then experiment with playing the game.

  4. In the shell, experiment with accessing the words file:

     >>> our_file = open('wordle-words.txt')
     >>> type(our_file)
    
     >>> lots = our_file.read()
     >>> len(lots)
     >>> our_file.close()
    
     >>> lots[285:321]