Python

41 flashcardsby —Griffith—
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
Define the three components of a problem in program development
Inputs, Outputs, and Processing
2
What tool represents Inputs, Processing, and Outputs?
An IPO Chart
3
What is the purpose of outlining the solution?
To identify major tasks, subtasks, structures, and variables
4
What is an algorithm?
A clear, step-by-step set of instructions
5
What tools commonly represent algorithms?
Pseudocode and Flowcharts
6
Why do we desk check algorithms?
To find logic errors early
7
What is coding the algorithm?
Translating the algorithm into a programming language
8
What is the final step of program development?
Documenting and maintaining the program
9
What is pseudocode?
Steps describing a solution’s logic in plain English
10
What keywords in pseudocode represent input?
READ, INPUT
11
What keywords in pseudocode represent output?
PRINT, DISPLAY
12
What keywords represent decisions?
IF, THEN, ELSE
13
What symbols in a flowchart represent start/end?
Terminal (oval/lozenge)
14
Which flowchart symbol is used for I/O?
Parallelogram
15
Which symbol represents a process?
Rectangle
16
Which symbol represents decisions?
Diamond
17
What is a variable in Python?
A named storage for a value
`x = 5`
18
What does type() do?
Shows the data type of a value
`type(10) # int`
19
What is type casting?
Converting a value into another type
`x = int("5")`
20
What are the arithmetic operations in python?
+, -, *, /, //, **, %
21
What is comparison in Python?
<, <=, >, >=
22
Runs code only if condition is true
``
if age > 18:
print("Adult")
``
23
What is a two-way decision?
Runs one block if true, another if false
``
if num > 0:
print("Positive")
else:
print("Not positive")
``
24
What is a multi-way decision?
Checking several conditions
``
if grade >= 80:
print("A")
elif grade >= 60:
print("B")
else:
print("C")
``
25
What is a while loop?
Repeats while a condition is true
``
i = 1
while i <= 3:
print(i)
i += 1
``
26
Repeats a known number of times
``
for i in range(3):
print(i)
``
27
What does break do?
Stops the loop immediately
``
for i in range(5):
if i == 3:
break
``
28
What does continue do?
Skips the rest of the current loop iteration
29
What is a function?
Reusable code defined with def
``
def greet():
print("Hello")
``
30
What is a parameter?
A variable in a function definition
``
def add(x, y):
return x + y
``
31
What is an argument?
A value passed to a function when calling it
`add(3, 4)`
32
What is return used for?
Sending back a result
``
def square(n):
return n * n
``
33
What is string indexing?
Accessing characters by position
``
name = "John"
name[1] # 'o'
``
34
What is slicing?
Extracting part of a string
`"Hello"[1:4] # 'ell'`
35
What is string concatenation?
Joining strings with +
`"Hi " + "there" # "Hi there"`
36
What is a list?
A mutable ordered collection
``
nums = [1, 2, 3]
nums.append(4)
``
37
What is a tuple?
An immutable ordered collection
`t = (1, 2, 3)`
38
What is a set?
Unordered collection of unique items
`s = {1, 2, 2, 3} # becomes {1, 2, 3}`
39
What is a dictionary?::
Key-value pairs
`student = {"name": "Alice", "age": 20}`
40
What are the steps of file handling?:
Open, read/write, close
``
f = open("data.txt", "r")
content = f.read()
f.close()
``
41
What does try-except do?
Handles runtime errors
``
try:
print(10 / 0)
except:
print("Error occurred")
``
Study all 41 cards for free