Python 3
Example from real-life (translated to english). One of the python3 student tasks was writing a program that outputs string with user name to both screen and file. The student program was:
protocol_file = open("protocol.txt", "wt")
name = input("Enter your name: ")
print(protocol_file.write("Judge says: Do you admit your guilt, " + name + "?\n"))
protocol_file.close()
For testing purposes student inputs some two-letter garbage as name - "mg". ... and, got 42 printed in console.