Python Midterm

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/63

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

64 Terms

1
New cards
Hardware
physical components of a computer (case, mouse, monitor, fan, etc)
2
New cards
Central Processing Unit (CPU)
"Brain" of the computer that performs instructions defined by software
3
New cards
Main Memory
works with the CPU and stores a program and data (RAM- memory lost when powered off)
4
New cards
Secondary Storage Device
long-term memory that holds data (CD, DVD, USB, etc)
5
New cards
Input Device
collects the data and sends it to the computer (keyboard, mouse, etc)
6
New cards
Output Device
data is sent to these where it is presented (displays, printers, Word document, etc)
7
New cards
Software
the programs and other operating information used by a computer.
8
New cards
Binary

1 = on

0 = off

9
New cards
bit
binary digit ( 1 or 0 )
10
New cards
byte
store a letter or small number (8 bits)
11
New cards
machine language (low-level programming language)
series of 1s and 0s
12
New cards
programming language
allows programmers to communicate with a computer that we understand
13
New cards
Assembly Language
more human-like language, a step up from machine language
14
New cards
Assembler
converts Assembly to Machine
15
New cards
Python (high-level programming language
more like our native languages
16
New cards
keywords/ reserved words
has a specific meaning and cant be used for anything else (and, break, while, def, etc)
17
New cards
operators
preform various operations on data (+, -, ==,)
18
New cards
syntax
set of rules that must be strictly followed when writing a program
19
New cards
statement
individual instructions you use to write a program (keywords, operators, etc)
20
New cards
compiler
translate high-level language programs into machine language so the CPU can can understand it (BEFORE)
21
New cards
interpretor
translates and executes instructions of a high-level language program (DURING)
22
New cards
low-level
CPU dependent (not portable)
23
New cards
high-level
Not CPU dependent (portable)
24
New cards
Object
item in a program that contains data and can preform operations
25
New cards
properties/attributes
data in the Object
26
New cards
Methods
special type of procedure that belongs to an Object
27
New cards
algorithm
set of well-defined logical steps that allow a computer to solve a problem
28
New cards
algorithm make-up**

1. Well-ordered and unambiguous 2. be executable 3. solve the problem at hand 4. terminate

29
New cards
command = 'print'
statement = ("Hello World")
30
New cards
**Variable makeup

1. Name (identifier) 2. Value 3. Location 4. Type

31
New cards
string
"Alice"
32
New cards
integer
25
33
New cards
float
5.5
34
New cards
Boolean/bool
represents a Boolean value (Ture/Flase)
35
New cards
getting user input
name = input("Enter your name: ")
36
New cards
output (using f-strings)
print(f"Hello, {name}!")
37
New cards
Control Flow
conditional statements, loops (for..in and while)
38
New cards
conditional statement

if age >= 18:

print("You are an adult.")

elif age < 18:

print("You are a minor.")

else:

print("Invalid age.")

39
New cards
For Loop

for i in range(5):

print(i)

40
New cards
For loop ex

for x in range(10, 0, -1):

print(x)

else:

print(“Blast Off!”)

41
New cards

for X in my_List:

print (X)

don't have to define the variable before

42
New cards
While Loop ex.

count = 0

while count < 5: print(count)

count += 1

43
New cards
While Loop
execute code repeated as long as the condition remains TRUE
44
New cards
len
built-in function the number of items in the sequence
45
New cards

numbers = [1, 2, 3, 4, 5]

print(len(numbers))

5
46
New cards
function
block of reusable code that performs a certain task
47
New cards
function make-up

1. name (identifier) 2. return type 3. parameter list 4. body

48
New cards
def
defines the function
49
New cards
function name

def function_name()

call this function many times using the name but with a different parameters

50
New cards
return
exits the function
51
New cards
random module
import random "random.randrange(1,100,1)"
52
New cards
list
53
New cards
append
append an element to the end of a list
54
New cards
my_list.append(X)
55
New cards
Pop
"remove" or pop an index off the List
56
New cards
remove
remove an element from the list
57
New cards
my_List.remove(x)
58
New cards
local variable
inside a function; do not exist outside of it
59
New cards
global variable
outside a function
60
New cards
string
an array of characters
61
New cards
string concatenation
+
62
New cards
print (3 * "Hip")
duplicate the string
63
New cards
Data structures
way of organizing data so that it can be accessed more efficently
64
New cards
list
a container which stores a collection of related values; also a sequence