data types and structures Flashcards
integer(int)
data type for storing rational numbers e.g. x=5
string(str)
data type for storing characters and must have quotation marks around it e.g. myName=’‘John’
float
data type for storing irrational numbers e.g. pi=3.142
boolean (bool)
data type for storing true or false statements e.g. flag=True
how would you display a data type (Integer, String, Float, Boolean) on screen?
use the print() function
how would you collect data from the user?
use input() function e.g. myName= input(“Enter your name”)
how would you display “welcome, (users input)” onto the screen
#create a variable for the users name e.g. "myName" #ask the user to input the value #print your statement
myName=input(“Enter your name”)
print(“welcome”,myName)
data
a value or set of values e.g. 37, HELLO
data structure
a way of storing data in a computers memory so that it can be used efficiently e.g. Array, Linked List, Stack, Queue, Tree, Graph
linear data structure
elements are stored in a linear sequence
e.g. Array, Linked List, Stack, Queue
non-linear data structure
no specific sequence for storage of data
e.g. Tree, Graph
static data structure
data structure with a a fixed memory size e.g. Array
dynamic data structure
data structure where memory can be updated e.g. linked list
homogenous data structure
a data structure where data of the same type can be stored e.g. Array
non-homogenous data structure
a data structure where data of different types can be stored e.g. Linked List