Stacks and Palindromes

beginner python Homework

Lab 2 Answer Template Name : _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
First Last
Exercise 1: Stacks and Palindromes (2 points)
a. Adjust demo2() so the user can enter a putative palindrome at the keyboard using raw_input(“Enter a phase: “).upper()
Show the output of your program when the user enters: A nut for a can of tuna.
b. Show your completed code for the __eq__ magic method.

def __eq__(self, other):

# add code here.
Exercise 2: Some Magic Methods for Lists (2 points)
Paste in your output for examples 6 to 10. Your TA will randomly pick two to grade.
Exercise 3: Callable Objects (2 points)
a. Paste in your completed code for example 8.

def example8():

# add code here.
b. Paste in your completed code for example 9.

def example9():

# add code here.
Exercise 4. HanoiStacks
Complete the last two steps to solve the Tower of Hanoi with N=3.
a. Paste in your code for move #6.
b. Paste in your code for move #7.
Exercise 5. Towers of Hanoi
Paste in your completed main method. One point for detecting the half-way point and one point for printing out the number of moves.

def example9():

# add code here.
1

 

"Is this question part of your assignment? We Can Help!"