Sep 13: Group Activity - Functions
Room: King Hall 260
Group Activity¶
-
- If you are absent today, complete this activity at home
- Don't forget to do the reflection for the rest of the points
-
First use of Python Tutor
Example Code¶
Model 1
def model_one():
word = input("Enter a word: ")
L = len(word)
ans = word * L
print(ans)
def main():
print("Starting main...")
model_one()
print("All done!")
main()
Model 2
def model_two(word):
ans = word * len(word)
print(ans)
def main():
print("Starting main...")
w = input("Enter a word: ")
model_two(w)
print("All done!")
main()
Model 3
def model_three(word):
ans = word * len(word)
return ans
def main():
print("Starting main...")
w = input("Enter a word: ")
result = model_three(w)
print(result)
print("All done!")
main()