# Student Name
# Start the Conversation
name = input("What is your name? ")
print("Hi " + name + ", nice to meet you. I am Chatbot-1024.")
# ask about a favorite sport
sport = input("What is your favorite sport? ")
if sport == "football":
# respond to football with a question
yards = int(input("I like football too. Can you tell me the length of a football field in yards? "))
# verify and comment on the answer
if yards < 100:
print("No, too short.")
elif yards > 100:
print("No, too long.")
else:
print("That's right!")
print("Invalid input. Please enter a valid integer for the length of a football field.")
elif sport == "baseball":
# respond to baseball with a question
strikes = int(input("I play baseball every summer. How many 'strikes' does it take to get a batter out? "))
# verify and comment on the answer
if strikes == 3:
print("Yes, 1, 2, 3 strikes you're out...")
else:
print("Actually, 3 strikes will get a batter out.")
elif sport == "basketball":
# respond to basketball with a question
team = input("The Harlem Globetrotters are the best. Do you know the name of the team they always beat? ")
# verify and comment on the answer (check for either version with or without capitals)
if team == "Washington Generals":
print("Yes, those Generals can never catch a break.")
else:
print("I think it's the Washington Generals.")
else:
# user entered a sport we don't recognize, so just display a standard comment
print("That sounds cool; I've never played " + sport + ".")
print("Great chatting with you.")
PASSED: Source Test 1: Syntax Error #1 Fixed (+8.0)
PASSED: Source Test 2: Syntax Error #2 Fixed (+8.0)
PASSED: Source Test 5: Run-Time Exception #1 Fixed (+8.0)
PASSED: Output Test 6: Test Input #1 (Matt, football, 100) (+8.0)
PASSED: Output Test 7: Test Input #2 (Matt, football, 75) (+8.0)
PASSED: Output Test 8: Test Input #3 (Matt, football, 125) (+8.0)
PASSED: Output Test 9: Test Input #4 (Monica, baseball, 3) (+8.0)
PASSED: Output Test 10: Test Input #5 (Monica, baseball, 4) (+7.0)
PASSED: Output Test 11: Test Input #6 (Camila, basketball, Washington Generals) (+7.0)
PASSED: Output Test 12: Test Input #7 (Camila, basketball, Patsies) (+7.0)
PASSED: Output Test 13: Test Input #8 (Frederick, lacrosse) (+7.0)
FAILED: Source Test 3: Run-Time Error #1 Fixed (-8.0)
FAILED: Source Test 4: Run-Time Error #2 Fixed (-8.0)
2 answers