Skip to Main Content
Blog

Read and Write Data in Console in Python

Read and Write Data in Console in Python

from datetime import date


def main():
	"""
	Demonstrates input/output from/to the console.
	"""

	name = input("Enter name: ")
	gender = input("Enter gender: ")[0]
	birthDate = date.fromisoformat(input("Enter birth date: "))
	weight = float(input("Enter weight: "))
	scores = list(map(int, input("Enter scores: ").split(",")))

	print()
	print(f"Name:       {name}")
	print(f"Gender:     {gender}")
	print(f"Birth Date: {birthDate}")
	print(f"Weight:     {weight:.2f}")
	print(f"Scores:     {scores}")


if __name__ == "__main__":
	main()