Third Practicum: Tuesday, December 13th

8:00 a.m. - 9:50 a.m. in Reid 401

Final's Week Office Hours

Practice Practicum Problems

Question 1

Conduct experiments with the Python code below until you can describe in simple English what is true of the variable answer after the while loop finishes.

answer = ""
while (not answer.isnumeric()):
    answer = input("Enter something: ")

Hint: Use the Python documentation to learn more about the isnumeric() method.

Question 2

Modify the recursive function below so that same size, smaller squares are drawn in both the upper left hand and lower right hand corners of larger squares.

import turtle

def square(aTurtle, upperX, upperY, width):
    aTurtle.goto(upperX, upperY)
    for side in range(4):

def recursive_squares(aTurtle, upperX, upperY, width, level):
    if (level > 0):
         square(aTurtle, upperX, upperY, width)
         recursive_squares(aTurtle, upperX, upperY, width / 3, level - 1)

squares = turtle.Turtle()
recursive_squares(squares, -200, 200, 400, 3)

Question 3

Write a function named eliminate_consonants that strips out all consonants from the word that it is given. For example, if eliminate_consonants is called with "mississippi", it should return "iiii".

result = eliminate_consonants("mississippi")
print(result)     # should print "iiii"

Question 4

A year is a leap year if it is divisible by 4 unless it is a century that is not divisible by 400. Write a function that takes a year as a parameter and returns True if the year is a leap year, False otherwise.

Fall 2015 Practicum

Valid XHTML 1.0!