data types and structures Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

integer(int)

A

data type for storing rational numbers e.g. x=5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

string(str)

A

data type for storing characters and must have quotation marks around it e.g. myName=’‘John’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

float

A

data type for storing irrational numbers e.g. pi=3.142

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

boolean (bool)

A

data type for storing true or false statements e.g. flag=True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how would you display a data type (Integer, String, Float, Boolean) on screen?

A

use the print() function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

how would you collect data from the user?

A

use input() function e.g. myName= input(“Enter your name”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how would you display “welcome, (users input)” onto the screen

A
#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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

data

A

a value or set of values e.g. 37, HELLO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

data structure

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

linear data structure

A

elements are stored in a linear sequence

e.g. Array, Linked List, Stack, Queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

non-linear data structure

A

no specific sequence for storage of data

e.g. Tree, Graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

static data structure

A

data structure with a a fixed memory size e.g. Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

dynamic data structure

A

data structure where memory can be updated e.g. linked list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

homogenous data structure

A

a data structure where data of the same type can be stored e.g. Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

non-homogenous data structure

A

a data structure where data of different types can be stored e.g. Linked List

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

one dimensional array

A

a data structure that stores a sequence of elements only in one dimmension

17
Q

two dimensional array

A

an array within an array

18
Q

what is a list in python?

A

A list is a data structure that is a changeable, ordered sequence of elements.

Each element or value that is inside of a list is called an item.

lists are defined by having values between square brackets [ ]

19
Q

what method would you use too add one element to a list

A

append():

20
Q

what method would you use to give the overall length of a list?

A

len(list):

21
Q

what method would you use to add a component to a list at a required position?

A

insert():

22
Q

what method would you use to sort a list in ascending order

A

sort():

23
Q

what method would you use to remove an element at an acquired position?

A

pop():

24
Q

what would we get when we add the strings “birth” + “day” = ?

A

“birthday”

25
Q

len(“birthday”) would give you?

A

8 because that is how long the string is

26
Q

carry out the arithmetic 5**5 / 10

A

312.5

27
Q

why do we need Boolean values?

A

we want to find out if things are true or not

the computer keeps track of whether different events have happened or not