32 Arrays Tuples and Records SAMPLE A Level
32 Arrays Tuples and Records SAMPLE A Level
Free Sample
THANK YOU FOR DOWNLOADING THIS FREE SAMPLE RESOURCE!
Here, you’ll find a snippet of the module, which you can use to gauge the quality
of our offering, but will also find super useful in the classroom.
teachcomputerscience.com
Teach Computer Science
A-Level
teachcomputerscience.com
1.
Revision notes
teachcomputerscience.com
Introduction
The primary purpose of a computer system is to process data. The
data can be of any type. If a computer program needs to process one
piece of data, then that data can be stored in a variable, and the
resultant data can be stored in another variable. In this case, a couple
of variables are sufficient to write a program. But real-life programs
need to handle tens of thousands of pieces of data. When handling
large amounts of data, it is impossible to store each piece data in a
separate variable. Therefore, data is grouped together or, more
precisely, structured in a specific format. The collection of data
structured together is called a data structure. In this article, types of
data structures and implementation of some data structures in
computer programs are discussed.
Country
name
Array name
Data elements
Afghanista Index
1
n
Albania 2
Algeria 3
USA 4
Andorra 5
teachcomputerscience.com
2.
Activities
teachcomputerscience.com
Activity-1
Duration: 10 minutes
teachcomputerscience.com
Activity-1
Duration: 10 minutes
#declaring an array
import array
a=array.array('i',range(10))
#entering data into array
i=0
while(i<10):
a[i]=int(input("Enter element:"))
i=i+1
even=array.array('i',range(10))
odd=array.array('i',range(10))
j=0
k=0
l=0
#separating even and odd numbers into separate list
while (j<10):
if(a[j]%2==0):
even[k]=a[j]
k=k+1
else:
odd[l]=a[j]
l=l+1
j=j+1
#printing both the lists
print("The even list")
x=0
while (x<k):
print(even[x],end=" ")
x=x+1
print("\nThe odd list")
y=0
while (y<l):
print(odd[y],end=" ")
y=y+1
teachcomputerscience.com
Flashcards
A collection of data
What is a data structured together in a
structure? specific format is called a
data structure.
teachcomputerscience.com
Glossary
teachcomputerscience.com
Quiz
1. Complete this sentence: Arrays are ……………… data structures.
A. Linear, homogenous and static
B. Linear, homogenous and dynamic
C. Non-linear, homogenous and static
D. Non-linear, non-homogenous and dynamic
teachcomputerscience.com
Teach Computer Science
http://creativecommons.org/licenses/by-nc/4.0/
Thank you!
teachcomputerscience.com
Teach Computer Science
We hope it has been useful for you in the classroom and that your
students enjoy the activities.
For more teaching resources like this, don’t forget to come back
and download the new material we add every week!
teachcomputerscience.com