prepare for interview Flashcards

1
Q

Hard Disk

A

Non-volatile data-storage device. rotating magnetic disk.

Uses magnetic storage to store and retrieve digital information. composed of one or more rapidly rotating platters coated in thin magnetic material. Data accessed in random-access manner (can be stored and retrieved in any order).

Non-volatile: retain stored data when powered off.

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

Computing Machine

A

Machine that does something based on input, and produces output

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

Turing Machine

A

‘the blueprint of modern computing’. ‘Machine’ that recieves a tape of 1’s and 0’s, reads it, changes 1’s to 0’s and 0’s to 1’s according to instructions. the tape that used to be a question becomes an answer to the question.

Initially just a theoretical idea of a device that, when given a tape of whatever needed length of 1s and 0s, reads the tape and changes the 1s and 0s in accordance with its instructions. the tape of 1s and 0s starts as a question, and when the turing machine is finished with it, becomes the answer.

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

Von-Neumann Architechture

A

computer model designed by John Von-Neumann in 1945.

Input -> Memory -> Output
V> Processor (Control Unit <->Arithmetic Logic Unit)

+ Input stored as command in Memory,
+ Processor fetches command from Memory,
+ CU manages commands and input/output,
+ ALU handles calculations,
+ CU stores complete commands in memory,
+ Output is displayed.

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

Operating System

A

Program that allows a user to interact with the computer.

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

History of Linux

A

developed by Linus Torvalds.

started in 1991 as a pet project,

became community open source project

Linux 1.0.0 launched in 1994

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

What is Linux?

A

Open source Operating System. Android is based in Linux.

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

CPU

A

Central Processing Unit. interprets and executes all instructions. consists of single microprocessor, but stronger mainframes use one or more. contains CU and ALU (Command Unit, Arithmetic Logic Unit)

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

Stores temporary files.

Small chunk of memory on the computer’s processor that stores basic computer instructions that were recently or are frequently used.

Makes processing go faster because frequent data close to CPU

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

RAM

A

Computer memory that can be read and changed in any order.

Typically used to store working data and machine code.

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

ROM?

EPROM?

A

Read-Only Memory. Non-volatile memory, cannot be electronically modified after manufactury.

Erasable Programmable, read only memory. can be erased if exposed to certain ultraviolets.

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

BIOS

A

Basic Input Output System

Boot Loader
Computer instructions in ROM in motherboard chip.
Controls input and output operations.
Loaded into memory on startup, performs POST (power on self test), then loads OS from hard drive into memory.

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

BUS (Address, Data, Control)

A

Set of wires carrying signals between devices. connect CPU, memory and I/O devices.

Address bus: carries the address of memory location/ IO device CPU is communicating with

Data bus: carries data between CPU and memory / IO device

Control Bus: carries control signals, telling IO devices what to do

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

I/O device

A

Any external device that could send input or receive output.
(secondary storage, keyboard, mouse, monitors, printers)

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

File system

A

The way in which files are named and placed logically for storage and retrieval.

NTFS, NFS and ext4 are file systems.

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

Program

A

Set of code and instructions meant to complete a task.

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

Process

A

Running instance of a program

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

USB

A

Universal Serial Bus

Technology that connects computers with external devices

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

Serial Port

A

Connector that sends data one bit at a time.

May be connected to a computer.

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

Parallel port

A

Device Connector,

sends/receives several bits of data simultaneously using more than one wire.

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

RS-232

A

slow but reliable standard transferring data as voltage signal. relatively slow, used still for modems, printers, and other peripherals.

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

(U)EFI

A

Unified Extensible Firmware Interface.

Boot Loader, Replacement for BIOS, controls startup process. supports larger hard drives, faster boot times, improved security, adds GUI to configure UEFI settings.

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

Boot Loader

A

Loads an operating system when a computer is turned on. Stored in non-volatile memory (ROM)

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

GRUB/LILO

A

GRUB: new boot loader with multi-OS device management. Supports Windows, Linux, UNIX, macOS, BSD, and Solaris.

LILO: older boot loader with single OS device management. Only supports Linux.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
ATAPI
Advanced Technology Attachment Packet Interface Extension for ATA(/IDE) standard, allows non-hard drive devices to connect to computer (CD-OMs, DVDs, Blu-ray). Uses command-based protocol allowing host computer to send commands to the device and receive data from it.
26
SATA
Serial Advanced Technology Attatchment Replaces older PATA (Parallel) standard, used for hard drives, SSD's and optical drives. (remember ATAPI)
27
Master Boot Record
Boot sector at beginning of storage device (holds partition table + bootstrap code) Locates OS, loads it to memory, transfers control to OS.
28
MTBF
Mean Time Between Failiures. Average time between breakdowns, used to measure performance/safety
29
Swap File
System file that creates temp storage on SSD/HD when system low on memory. Swaps section from RAM storage from idle program to be used by other programs. Simulates disk space as RAM.
30
Virtual Memory
OS technique using hardware and software to temporarily transfer data from RAM to disk storage. Compensates for physical memory shortage.
31
Inode
File data structure, stores metadata about a Linux file (except name and data) Keeps track of all files in Linux System.
32
ASCII table
America Standard Code for Information Interchange: assigns numeric IDs to each letter, numeral, punctuation and other characters. Subset of Unicode, developed in 1960's
33
Unicode
Worldwide encoding standard. developed in 1980's to support a total of 65,536 characters (including ASCII) and more from other languages and scripts. Unicode characters take variable length characters, and therefore take more space than ASCII.
34
wchar
Wide Character. Size of wchar is implementation-defined, but typically 16 bits. | wchar_t *wide_string = L"Hello, world!";
35
UTF-7/8
7-bit / 8-bit encoded Unicode Transformation Format. 7 is backwards compatible, still used in emails. 8 is more efficient and supports more characters, used for web and other applications.
36
POSIX
Portable Operating System Interface set of OS interface standards based on Unix. Any two software conforming to POSIX standard should be compatible.
37
GNU
GNU’s Not Unix Unix-like OS; Collection of programs (applications, libraries, developer tools, and games) Started by Richard Stallman in 1983, as the GNU Project. goal: create a free OS that is compatible with Unix. relevent components: GNU Compiler Collecction (GCC), GNU Debuger (GDB) GNU C Library (glibc), Bourne Again SHell (bash) And of course others
38
IP / TCP / UDP
Internet Protocol, responsible for routing data backets between computers Transmission Control Protocol: does the TCP handshake and ensures all packets reach their destination User Datagram Protocol: connection-less protocol, which does not guarantee data is delivered reliably or in the right order.
39
Kernel
Core of the OS. All system calls from User Space communicate with the Kernel.
40
System Call
routine that allows user apps to request actions that require special privelages (create, delete, open, close, read, write)
41
Waterfall
Project Framework that breaks down of project activities into linear sequential phases
42
SCRUM
Project Framework that starts with what can be seen/known. then tracks progress and tweak as necessary. Emphasizes teamwork, accountability and iterative progress. Is an example of Agile Development
43
Agile Development
Project Framework for iterative and incremental development. + rapid, flexible responses to change. + customer collaboration over contract negotiation + responding to change over following a plan + working software over comprehensive documentation Scrum and Extreme Programming are forms of Agile Development
44
NTFS
New Technology File System Used by Windows NT for storing/organizing/finding files on a hard disk. Direct upgrade to FAT16/32. Reliable: Is a Journaling file system (keeps track of file changes in journal for recovery) Efficient: features file compression and sparse files Secure: supports Access Control Lists (ACLs) to control file access. Encryption: supports file encryption to be accessed by authorized users. Default file system for windows NT, 2000, all the way up to windows 10. Also supported by Linux and macOS, but those primarily work with ext4.
45
NFS
Network File System Protocol for storing files on a network. Distributed file system for accessing files/directories on remote computers and treat them as if they were local. Scaleable (can add more users/devices) Reliable (withstands network failiures) Efficient (uses network resources as opposed to shoving more physical memory into a machine)
46
FAT-16/32
File Allocation Table FAT16, introduced in 1977, for Floppy disks. stores file/folder info as 16-bit entries. max size of FAT-16 partition is 2GB FAT32, introduced in 1996, for USB flash drives and SD cards. stores file/folder info as 32-bit entries. max size of a FAT-32 partition is 32TB.
47
JFS
Journal File System, created by IBM. Meaning the file system tracks changes to files and folders in a log file, to backtrack changes in case of system crash or power failure. ext4 is a JFS.
48
ext4
Fourth Extended File System (after ext1, ext2 and ext3) Journal file system (JFS) for Linux. higher supported size (1 exabyte).
49
Primary Disk Partition
first part of MBR partitioned hard drive. stores OS, boot files (that start the computer)
50
Extended Partition
Partition that holds multiple logical partitions.
51
Logical Partition
Partitions that hold data and applications. (Data files, Media files, Applications, Backups, Games, Software)
52
What are the 9 sections of the manual? (man command)
1 General Commands 2 System Calls (provided by kernel) 3 Library Functions (from program libraries) 4 Special Files (usually to do with /dev/) 5 file formats and conventions (usually to do with /etc/) 6 games: oops 7: Miscellaneous: Macro Packages and Conventions, boot parameters, 8: Sys-admin commands: usually reserved for root 9: Kernel Routines: info about internal kernal operations
53
which command tells you which manual section the "write" command is in?
man -f write // returns page/section write is in
54
When there is more than one program with the same name in the file system, how do you know which will run?
1: program in the same directory will run first, 2: else, the OS will look for the first program that appears in the $PATH environment variable, 3: if it doesn't exist, OS returns an error.
55
what do the "which" and "type" commands do?
which returns the path to the executable, and type returns information, like if the command is internal/external which ls returns: /bin/ls type ls returns: ls is a shell builtin
56
write an alias to remove files ending with ~ from the current directory
alias rt~='rm -r *~'
57
In which file would you place an alias so that you have it when you start a new bash?
~/.bashrc
58
Create a shell function that checks if a file exists. if it does, then copy it to /tmp
#!/bin/sh FILE=1 echo "please enter file name." read FILE if test -f "$FILE"; then cp "$FILE" tmp/"$FILE" fi
59
login to another computer and run gedit on a file in /tmp. ensure that the window that opens is on your computer, and not the remote computer
ssh username@host_ip_addres cd /tmp touch whatever.txt gedit whatever.txt
60
What is the command for knowing who is logged in?
who -b
61
What is the command for checking last reboot?
last reboot
62
What is the command to confirm your IP address?
ifconfig
63
What are the commands you can use to see computer resource usage?
top htop (for better view) nmon gnome-system-monitor
64
What is the command for setting your computer's clock?
sudo timedatectl set-time hh:mm:ss
65
Write a shell script that records the current time to a file in /tmp
#!/bin/sh touch "/tmp/date.txt"; echo $(date) >> "/tmp/date.txt";
66
Command to know how long it takes for -ls -m to run?
time -ls -m
67
What are the differences between crontab, at and batch?
Cron: runs tasks at regular intervals (once a minute, once a day...) think backups and notifications crontab -e 0 2 * * * echo howdy //echoes at 2am every day At: runs task at a later time (think running a test suite or compiling code) at now +5 minutes > notify-send "commit to bathroom" > CTRL+d Batch: just calls at, to run in the background.
68
command to know what processes are running on the machine?
ps aux
69
command to know PID of shell environment?
echo $$
70
ls command, but display hidden files?
ls -a
71
ln VS ln-s
Hard Link: Creates a file sharing the same inode. Good as backup, files are deleted when their last hard-linked pointer is deleted. Soft Link: creates a file pointing to the other file's location. soft link can point to files in other file systems.
72
think about pushd popd
take your time.
73
Why are the -i, -r and -f flags for cp, mv and rm? why doesn't mv have -r?
-i interactive (prompts "are you sure you want to delete/overwrite?") -f force (if it cannot be opened, delete and try again) -r recursive (take into account all subfiles/subdirectories) mv works with recursive flag by default.
74
command to check used disk space?
df, or df -h for human
75
command to edit file permissions remove write and execute from group and others. give read write execute to user. set owner of the file to "guests" group
chmod go-wx file.txt chmod u+rwe file.txt sudo chgrp g-rwx file.txt
76
command to add a guest account with guest password to machine create a guests group, add guest to guests group
useradd guest passwd guest 12345 groupadd guests usermod -a-G guests guest
77
count the number of words that start with 'a' and end with 'z' in the dictionary file, and print the number to a file in /tmp
grep -c "^a.*z$" /usr/share/dict/words
78
Display the words in a file containing qui respelled with kwi
grep -E "qui|kwi" file.txt
79
in a command: what are the last 20 words in the dictionary?
tail -20 /usr/share/dict/words
80
What is the difference between a swap file and a swap partition?
swap file handling is more flexible, but slower. (can't enlarge a swap partition without disk management tools) Swap partitions are faster, and more common.
81
What is Bash?
Bourne Again Shell. command language interpreter, executes commands read from .sh file.
82
Global Variable in Bash
variable declared outside of any function or loop, and can be accessible from anywhere in the script.
83
printenv (bash)
prints environment variables
84
What is the meaning of #!/bin/bash
"shabang". inscructs the program loader to use the /bin/sh program instead of any other, passing the path of the script as the first argument.
85
How do you make multiline comments in bash?
: ' will not execute '
86
What is Version Control?
AKA source control, the practice of tracking and managing changes to software-code. version control tools help software teams manage changes to source code over time. Git is a Version Control Tool
87
Define Git
Distributed Version control system
88
What is a Git repository?
collection of files and folders that are tracked by Git
89
What is the Git HEAD?
Pointer to the current commit. git checkout makes the HEAD point to a different branch. git commit sets the head file to point to the current commit.
90
What is the Git Staging Area?
files to be handled by the next commit. git add adds files to the staging area
91
What is the difference between git fetch and git pull?
fetch downloads changes to local repository, git pull calls fetch AND merges them into your local branch.
92
What is the difference between the HEAD and the master?
HEAD is a file located in the .git directory. contains pointer to current commit. Master is a branch in the git repository. a branch is a pointer to a specific commit.
93
What is the difference between git reset --hard and git reset --soft?
soft reset: moves HEAD to the specified commit, and un-stages files added to staging area between current state and specified commit. hard reset: destroys all changes and removes them from the working directory, staging area and commit history. (soft reset un-adds changes. hard reset deletes changes.)
94
What is a sequence point?
a point in the code where previous expressions have to resolve before proceeding. examples: && || , ; function calls, return, the conditional expressions of if/while/do...
95
C escape character for newline
\n
96
what defines an expression as having an l-value, and what is a side effect?
expressions with l-value have a persistent (FINDABLE) location/address in memory. (a = 7; /*you can find the address of &a*/) (10 += 7; /* you can't find the address &10 */)
97
What is the difference between a declaration and a definition?
Declaration tells the compiler about the existence of a variable/function/object. int x; void function(); definition tells the compiler the location and size of a variable/function/object. int x = 10; void function() { return 10; }
98
What is the difference between unspecified and undefined behavior?
Unspecified: undefined by programming language standard Undefined: undefined by programming language standard AND will cause unpredictable program behaviour
99
What is the difference between unspecified and undefined behavior?
Unspecified: undefined by programming language standard - function arguments can be evaluated in different orders, - pointers pointing to uninitialized memory Undefined: undefined by programming language standard AND will cause unpredictable program behavior - accessing array element out of bounds - dividing by zero - de-referencing null pointer
100
what defines Data, Stack and Heap variables?
Data variable: allocated in data segment, initialized when program starts, de-allocated when program ends. int x = 10; Stack Variable: allocated in stack segment, initialized when function is called, de-allocated when function returns (most anything inside functions) Heap Variable: allocated in heap segment (for dynamically allocated memory), initialized when allocated, de-allocated when freed. (malloc, calloc, free)
101
What is an array?
collection of variables of the same type double balance[3] = {1.2, 3.4, 5.6}
102
What is Forward Declaration?
declaring a variable before providing a definition. int func(); //code int funct(){ return 7;}
103
what does assert do in C?
#include void assert(int expression); prints message to stderr and aborts the program if false or 0. "Assertion failed: expression, file filename, line line-number."
104
What will happen if you use a dangling pointer?
segmentation fault (please use free)
105
in debugging, what is breakpoint, watchpoint and catchpoint?
breakpoint: stop executing at break line watchpoint: stop executing when target memory location is modified catchpoint: stop executing when a specific event occurs
106
What is a memory leak?
program error, allocated memory isn't freed.
107
What is Word?
the size of the basic unit of data that a computer processor can manipulate. depending on the computer architecture, this is either 32 or 64 bits, typically represented as an "int" by 32-bit or 64-bit computer.
108
argc, argv and envp?
argc: variable, stores number of arguments passed to C program argv: array, stores arguments passed to the C program envp: pointer to array of pointers to environment variables (environment variables being HOME, PATH, LANG, LC_ALL, USER, USERNAME, and more)
109
given x = "toot", difference between sizeof("x") and strlen("x")?
sizeof will give the size in bytes (4 characters, 4 * 1 bytes) strlen will return the length, including the escape character \0 (5)
110
what are stdin, stdout and stderr?
Standard Input/Output/Error Streams; interconnected I/O channels between a computer program and its environment during runtime. stdin recieves text as input. stdout outputs text to the shell environment stderr outputs error messages
111
enum
Special type representing a group of constants enum Level { LOW, MEDIUM, HIGH }; enum Level some_level; some_level = LOW; some_level = HIGH;
112
struct
Groups related variables of varying types.
113
chain of responsibility
Behavioral design pattern of passing requests down a chain of handlers. Each handler either processes the request or passes it to the next handler.
114
what is a file, in linux?
A named collection of data on a storage device. can be text, images, programs, etc. All files are organized under a file system.
115
what is the difference between fopen() and open()? what is the difference between what they return?
fopen() and open() are functions in C used to open files. fopen() is a library function (implemented by C standard library). Returns a pointer to a FILE object. Has a variety of modes ("r" reading, "w" writing and "a" appending, and others). open() is a system call (implemented by the OS). Returns an integer file descriptor (identifies the file on the OS)
116
Header File
.h file with declcarations and macro definissions to be shared between source (.c) files. #include header_file_name.h
117
Header Guard
#ifndef FILENAME.H #define FILENAME.H code in header file to prevent duplicate implementation of the same code.
118
Preprocessor
Macro processor, transforms .C into .i file, removes comments, runs macros (header file inclusion, macro expansion, conditional compilation, line control [inform line's origin file])
119
Linker
links .O files together into single binary executeable. resolves symbols, assigns load addresses for object files.
120
Compiler
transforms source code into machine (byte) code.
121
stack, heap, bss, initialized data segment, text segment
stack: memory for local variables/function arguments, return address of current function. managed by compiler. heap: memory region for dynamically allocated variables (not known at compile time, malloc, calloc, realloc, free) bss: (blank started by symbol) memory region initialized to 0. store uninitialized global/static variables. managed by OS initialized data segment: memory region for initialized data (global/static variables) known at compile time. text segment: read-only memory region for machine code and constants (size of the stack or heap)
122
Static
function/variable restricted to same file it is defined in. funcs are global by default.
123
Interface VS implementation
Interface: Blueprint portraying how a function should be implemented later. Implementation Software "around" the interface/blueprint. defining the function's implementation.
124
API
Application Programming Interface. code that enables two software programs to communicate
125
Shell commands: What do ar, nm and objdump do?
ar: create, modife, extract archives (file holding other files called "members of an archive") nm: list symbols from object files. objdump: display information from object files.
126
Software Build process from c sources to running program:
- preprocessor strips .c file into commentless .i (preprocessed) file, runs macros -compiler converts .i code into assembly .s file. -linker performs symbol resolution, relocation, links object files together into single relocateable file. - locater takes relocateable file and linker script file, converts into executeably binary image.
127
What does extern do in C?
Declares variable to be linked externally
128
Recreate the Bursa program
void Bursa(int arr[], int size, int* bursa_arr) { int test_buy_i = 0; int test_sell_i = 0; int i; for(i=1; i arr[test_sell_i]) { test_sell_i = i; } if(arr[i] < arr[test_buy_i]) { test_sell_i = i; test_buy_i = i; } if((arr[test_sell_i] - arr[test_buy_i]) > bursa_arr[2]) { bursa_arr[0] = test_buy_i; bursa_arr[1] = test_sell_i; bursa_arr[2] = (arr[test_sell_i] - arr[test_buy_i]); } } }
129
Which variables initialize automatically?
global+static variables, initialized by bss at load time, assigning constants like 0.
130
actual type of size_t?
long unsigned int. defined in stdlib.h
131
What is a symbol?
Anything with a global or module level name.
132
In a make file, what are these? CC = gcc CFLAGS = -Wall -Wextra -pedantic DEBUG_FLAGS = -g RELEASE_FLAGS = -O2 TARGET = fooer.out OBJS = foo.o main.o
CC: program for compiling C program CFLAGS: flags, to give to c preprocessor DEBUG_FLAGS: for printing debug data RELEASE_FLAGS: at optimization level 2. function inlining (replace functiion calls with code) dead code elimination (unexecuted code yeetus) and constant folding (replace constants with actual values) TARGET: name of the file you want to create OBJECT: list of all object file names
133
In a make file, explain these: .PHONY: all all: main.c foo.c $(CC) -o fooer.out main.c foo.c $(CFLAGS). foo.o: foo.c $(CC) -c foo.c $(CFLAGS). clean : rm edit $(objects) debug : make --debug
all is never a made result, targeting all, requiring main.c and foo.c create (-o) output file with specified name fooer.out using main.c and foo.c and add the CFLAGS targeting foo.o: requiring foo.c, compile without linker (-c) (generates .o file) targeting phony clean: no requirements, delete listed objects targeting phony debug: no requirements run first make command with debug mode
134
implicit rule in makefile
even without adding rules, rules are implied (assume don't run make command if missing objects or missing command requirements)
135
phony targets in makefile
fake targets to permit the command to run even if there *is* a file with the target name. avoids file conflicts.
136
What is Python
general purpose, high level (close to human) programming language. emphasizes: readability, object oriented, dynamically typed, garbage collection, easy to learn, free, open source.
137
Interpreted VS Compiled Language
interpreted language is not converted to machine code before execution. instead interpreter reads line-by-line and executes compiled language is compiled to machine code then executed
138
Dynamic VS static Typing
dynamic typing: infer variable type from assigned value. python does this. static: must declare variable type then assign a value
139
Read-Eval-Print Loop and Python Console
REPL: environment that can evaluate and print results of input expressions Python Console is a REPL for python
140
Primitive Types of Python cast them
fundamental data types of python programs: int(Integer), float(Floats), str(String), and bool(Booleans)
141
Python References
objects that point to other objects x = 10 "x" is a name object that points to the object "10"
142
Python Virtual Machine
manages runtime environment, loads and executes python bytecode (given by CPython interpreter) allows python to run on any machine that has PVM, provides memory management, garbage collection and exception handling services.
143
Python Bytecode
low-level platform-dependant representation of python source code. (.pyc) or generated by CPython interpreter, to be executed by PVM
144
Python Memory Management: CPython Block Pool Arena Reference Counting Garbage Collection
MM: allocating/freeing memory for variables/data structures CPython iterpreter, implements generational garbage collector and reference counting Block: fixed size block of memory size multiple of 8 bytes Pool: 4kb of memory containing blocks Arena: 256kb of memory containing pools Reference Counting: tracking number of references to objects. object freed if 0. Garbage Collection: automatically frees memory for objects no longer in use
145
define a function that prints the type of an object in python
def func(obect): print( "" + str( def( object ) ) )
146
what do break, continue and pass do in python
break: terminates current loop, resume at next execution continue: skip current loop iteration, resume at next iteration pass: nothing. placeholder to be replaced with something useful.
147
python range()
for i in range(0,10,2) print( "even: " + str(i) ) range(start, stop, step)
148
4 differences between python and C?
python: interpreted, dynamically typed, object-oriented, high level language C: compiled, statically typed, procedural (function-oriented), low level language
149
What is an interpreter? for python?
Reads/executes code. For CPython, reads and translates line by line into AST, bytecode, and lets PVM execute.
150
Explain the steps python source code goes through to become executable code
CPython interpreter parses source to abstract syntax tree (so that the compiler can understand) CPython interepreter generates bytecode for each node in the AST (which tells PVM what to do with the data) Python Virtual Machine loads and executes the bytecode
151
How does python manage memory
into arena of 256kb, pools of 4kb, and blocks of bytes size multiple of 8.