Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

LinkedIN Community

Join our LinkedIN Community.

Saving names and birth dates to a file

Make an interactive program in Python that asks for the number of people to store, and from each one of them asks for the following data by keyboard: day, month and year of birth (integers) and name of the person (String). Then it must store it in a file called "dates.txt" with the following format:

12 03 1996 | Hira Sadler
    16 05 1997 | Roman Connelly
    08 10 1976 | Alexandre Bullock
    04 03 2010 | Tracy Kendall

The above file has resulted from the following interactive session:

>>> %Run 
    Number of people to store: 4
    
    Give the data for person 1:
    Day: 12
    Month: 3
    Year: 1996
    Name: Hira Sadler
    
    Give the data for person 2:
    Day: 16
    Month: 5
    Year: 1997
    Name: Roman Connelly
    
    Give the data for person 3:
    Day: 8
    Month: 10
    Year: 1976
    Name: Alexandre Bullock
    
    Give the data for person 4:
    Day: 4
    Month: 3
    Year: 2010
    Name: Tracy Kendall
    
    The file "dates.txt" has been generated.
>>>