Lab 03
Lab 03
Assignment Overview
This lab exercise provides practice with strings and methods in Python.
Download the Lab03 folder and unzip it to your computer. As before, we open the new project Lab03. Open
the file debug3.py in PyCharm by double-clicking.
Set a breakpoint at the first executable line of the program (string1) and start the debugger by pressing the
“bug” button (leftmost green button). Answer the following questions:
1) When line 14 is highlighted, which variables are held in memory and what are their values?
ANSWER: Variables values
2) List all values of i and ch observed until the completion of the for loop.
ANSWER:
i ch
0 R
1 T
2 S
Note: Please do not use print() statements during the debug exercise.
Additional Resources
https://www.jetbrains.com/help/pycharm/debugging-your-first-python-application.html#where-is-the-problem
Develop a Python program which will convert English words into their Pig Latin form, as described below.
You will work with partners on this exercise during your lab session. On-line students: you can do
it on your own or with a partner. Best place to find a partner is Piazza.
The program will repeatedly prompt the user to enter a word. First convert the word to lower case. The word
will be converted to Pig Latin using the following rules:
a) If the word begins with a vowel, append “way” to the end of the word.
b) If the word begins with a consonant, remove all consonants from the beginning of the word and
append them to the end of the word. Then, append “ay” to the end of the word.
For example:
The program will halt when the user enters “quit” (any combination of lower and upper case letters, such as
“QUIT”, “Quit” or “qUIt”).
Suggestions:
Demonstrate your completed program to your TA. On-line (Section 730) students should submit
the completed program (named “lab03.py”) for grading via the Codio system. You can also copy and
paste your code into the coding window.