complex data types

86 views
Skip to first unread message

phalgun...@gmail.com

unread,
Oct 9, 2020, 7:09:47 AM10/9/20
to Discussion forum for Computational Thinking
when should i use class/ records and when should i use list?

Computational Thinking Support 2

unread,
Oct 9, 2020, 1:03:13 PM10/9/20
to Discussion forum for Computational Thinking, phalgun...@gmail.com
List

Whenever you want to maintain a collection of items, usually of the same datatype, you go for a list. For example, you want to keep a note of all holidays in a calendar year. How can you do that? One way would be to store them as a list of dates. What would this list look like? A typical list of holidays would look like the following:

[ 1st January, 26th January, 15th August, 2nd October ]

So this is just a collection or a list of dates.

Record

At a very basic level, you use a record when you wish to store diverse information related to some person or thing. Consider a typical report card. It has several fields. Some of them are: name, date of birth, subject marks, rank. Notice that the datatype of the fields are not uniform. Some of them are strings, while the others are integers. At the same time, the binding factor among all these different fields is that they all point to the information concerning a particular student. We represent this record as follows:

Name: "xyz"
DOB: "1st Jan, 1950"
Marks: "88"
Rank: 1

Hope this makes the distinction clear.

Thanks,
Karthik
Instructor, Computational Thinking

Suneeta

unread,
Oct 12, 2020, 7:28:34 AM10/12/20
to Discussion forum for Computational Thinking, ct-su...@onlinedegree.iitm.ac.in, phalgun...@gmail.com

List - Adding a column if a particular data type
Record - adding new fields as row of different data type or same data type
is it right to think record and list this way? 
Reply all
Reply to author
Forward
0 new messages