Programing Flashcards
how do you define a subroutine
def function1():
define a local varibable
A variables that is declared inside the function
define a global variable
variable that can be accessed and changed throughout the whole program, including subroutines
which varible is a global varibale:
SUBROUTINE add(a, b)
value ← a + b
RETURN value
ENDSUBROUTINE
new_value ← add(3, 5)
OUTPUT new_value
new_variable
which varibles are globle:
SUBROUTINE add(a, b)
value ← a + b
RETURN value
ENDSUBROUTINE
new_value ← add(3, 5)
OUTPUT new_value
a
b
local
what is decomposition
Breaking the problem down into smaller sub-problems, so that each sub-problem accomplishes an identifiable task, which might itself be further subdivided.
what is pattern recognition
Finding repeating patterns that could be solved quickly
what is abstraction
Removing unnecessary detail from a problem
how is data represented in boolean logic
on or off
what is a variable
a named memory address that holds a value
what is a constant
A constant is a location in memory which stores a value that does NOT change.
what is iteration
a loop that repeats certain steps
what is selection
a section of code is run only if a condition is met
what is IF, ELIF and ELSE and example of
selection and iteration
when shoud you use ELIF
if the first statement isnt true and you want to test for a second condition
What is the symbol for real division
//
What does “//” do
finds the integer of a divison
e.g 100//3 = 33
What is an integer
data types
A whole number
What is a real
data types
A fraction/ decimal number
What is Boolean
Data types
Only stores True or False
What is character
Data types
only stores strings of ASCII characters
What is string
Data types
A sequence of characters
How do you declare a variable
Using the = sign
What function calculates remainder
MOD
What symbol means equal in python
==
What symbol means not equal to in python
!=
What symbol means greater than in python
>
What symbol means less than in python
<
What symbol mean Greater than or equal to in python
> =
Which symbol means Less than or equal to in python
<=
Why are data structures used
They allow progamers to store more than one piece of data at a time
What are Arrays
A type of data structure that allows programers to put data into a list
What type of brackets are used in arrays
Sqaure brackets
[]
How do you import an array
from array import *
How do you define an array
variable_name = array( data-type ,[elements])
How do you ouput an array
print(array_name)
How do you output a certain number in an array
print(array_name[no.position])
How do you find the length of a string
len()
How do you find the position of characters in a string
find()
What is a substring
a string of characters that exists inside a string
What is Concatenation
the joining together of two strings
What opperation is used for concertration
+
How do you convert String to a float
pseudo code
variable = float(variable)
How do you convert data types in python
new_ data _type()
How do you generate random numbers in python
random. randint()
What symbol is used for assignment in Pseudo code
←
Which way does the arrow point when assigning somthing in Pseudo code
The arrow points from the data towards the place where the data is stored
Age ← USERINPUT
What is used for user input in Pseudo code
USERINPUT
What is used for output in Pseudo code
OUTPUT
How do you start a for loop in Pseudo code
FOR
How do you end a for loop in Pseudo code
ENDFOR