Skip to main content
Adding language title
Source Link
Victor Stafusa
  • 8.8k
  • 5
  • 40
  • 61

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.

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.

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.

Source Link

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.