Progweek1 Flashcards

(96 cards)

1
Q

Unix was born in _

A

1973

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

Unix provides a _ between the _ and the _.

A

simple-to-use and powerful interface

user (the programmer)

hardware (the computer)

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

Unix was based on simple ideas:
1
2
3
4

A
  1. simple interface
  2. simple instructions that can be combined
  3. hierarchical file system
  4. independent from specific computer architectures
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Since its development, Unix served as a _

A

base to develop operating systems

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

structure of systems developed by Unix:
⥐⥐⥐
1 ⇋ 2 ⇋ 3 ⇋ 4

A

1: user
2: shell
3: kernel
4: Hardware
2&&4: OS

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

The Unix shell is _.
It allows _.

A

an interface between the user and the operating system.

to run system commands.

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

why a shell?

A
  • powerful: Allows to solve
    many simple problems in a few
    lines.
  • Fast && flexible: offers
    a scripting language which
    often results in faster solutions
    to problems.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

syntax of commands

A

<options><parameters>
</parameters></options>

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

what is the command to list ll the file and directories in my desktop

A

l s −a

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

command that shows you the manual of the
specific command

+give eg

A

man

eg: man ls)

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

To work with objects in the file system we use their paths. There are two
ways of expressing the path of a file:

A
  1. Absolute: Starting from the root, e.g.: /Users/Lorenzo/Desktop
  2. Relative: Starting from the current
    position in the file system,
    e.g.: ./Lorenzo/Desktop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

“..”
meaning on the shell?

A

“the parent directory”

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

“.” meaning on the shell?

A

“this directory”

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

def of Files:

A

A sequence of bytes.

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

def of Path: (+eg)

A

The position in the file
system,e.g., /Users/Lorenzo/Desktop

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

def of Permission:

A

What can a user do with
the file read/write/execute for the owner,
owner group, everyone

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

hox to see permission on the shell?

A

use option ls -l

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

def of Directories:

A

A file that indexes other
files.

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

main ingredients of the file system:

A
  • files
    • path
    • permission
    • owner
    • dimension
    • last modified
  • directories
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

list the files in dir

A

ls dir

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

count words in file

A

wc file

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

count characters in file

A

mc file

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

count lines in file

A

lc file

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

look for all the lines in the file that match the expression

A

grep expression file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
redirects the output of the command to a file
command > file
26
edirects the output of the command to a file with append
command >> file
27
use the ouput of command1 as input of command2
command1 | command2
28
command1 is executed successfully executes command2
command1 && command2
29
Vim is a _ yet quite _ file _.
minimal powerful file editor
30
In a few words, C is:
- Imperative - Typed - Low level
31
pros of C
- Efficient (you have full control on use of resources) - Fast (you can usually implement very fast programs, e.g., using bit manipulation) - Good if you want to implement low level applications
32
cons of C
Limited degree of abstraction Limited run time support Limited portability Low level of security
33
what is "int main()" ?
declares a function which is called “main” and returns an integer.
34
def of Interpreter:
Program that executes code written in the high-level language. This is the typical approach of functional and scripting languages, standard in Python.
35
def of compiler
The compiler translates the code to the target language producing an executable file. This is the standard approach in most imperative languages, standard in C.
36
C programs are complied: hello.c → 1 → 2 → 3 ⇒ 4
1. preprocessor 2. compiler 3. linker 4. executable code
37
Preprocessing:
takes care of lines that start with “#”
38
Compiling:
takes the code obtained from the preprocessor and produces code that can be executed by the hardware
39
Linking:
links the object file to external libraries
40
This is how you should compile your programs:
gcc -Wall -pedantic -g -o helloworld helloworld.c
41
When you want to learn a new language there are a few things you need to check:
The paradigm: Imperative, functional, logic, etc. The type system: Typed/Untyped, explicit/inferred, type operators, etc. the basic syntax scope of names parameter passing memory management
42
def of commands give eg
roughly, a command is a piece of code that changes the memory (i.e., in general commands do not return values). The main example is assignment which assigns a value to a variable (i.e., essentially a piece of memory with a name).
43
def of expressions give eg
expressions are roughly pieces of code that can be evaluated to obtain a value, e.g., 3 + 2, x + y , sin(3) are all expressions.
44
Programming languages can be roughly divided as follows:
imperative functional logic object-oriented
45
def of imperative: give eg
Programs have a state (snapshot of memory, instruction counter, etc.) and consists of a sequence of commands (Examples: C, Pascal, etc).
46
def of functional give eg
A program consists of function declarations and compositions. Problems are solved in a way that is closer to how we think in mathematics. (Examples: Racket, ML, Haskell, etc)
47
def of logic give eg
A program consists of a collection of logical clauses which describe properties of the problem and of the solution. The execution of the program finds a solution matching the requirements. (Examples: Prolog, ASP, etc) .
48
def of object oriented give eg
This programming approach uses "objects" which contain data and operations. It's often combined with other programming styles. Examples of OOP languages are C++, Python, Java, and Ocaml.
49
very program has the following structure: 1 2 3
1. preprocessor directives 2. global declaration 3. function implementation
50
To work with data in our programme we use two basic constructs:
1. variables 2. constants
51
def of variables
a piece of memory with a name (called identifier) whose size depend on the type of the content and whose content can change during the execution of the program.
52
def of constants:
a piece of memory with a name whose size depend on the type of the content and whose content cannot be changed during the execution of the program.
53
def declaration:
we specify the name and type of the variable (memory is allocated).
54
def initialization:
we assign a value to a variable for the first time.
55
A data type is:
- a collection of objects ({. . . , 1, 0, 1, 2, . . .} for int) - a collection of operations (+, ⇤, , / etc. for int.)
56
Primitive types:
these are the types that are available to the programmer as building blocks of their program.
57
Type constructors:
these are ways of defining new types.
58
C is a _ programming language. This mean that variables, constant, and expressions will contain/express only data of _.
typed a specific type
59
Types in C must be mentioned _
explicitly
60
#include ?
includes the standard input-output library functions in a C program, such as printf and scanf.
61
& in scanf(%d, &i):
is used to tell scanf the location (address) in memory where it should store the integer that it reads from the user input.
62
Variables of type char are of _ byte(s) (_ bits) and can therefore represent _ = _ characters.
one 8 2^8 256
63
To check the size that a variable of a certain type occupies you can use the function __ which returns the dimension in bytes of the given type.
sizeof(type)
64
The types float and double are used to represent __.
real numbers
65
All floating types are _numbers can you use the unsigned modifier?
signed no
66
Float are usually _ bytes long and double _ bytes long.
4 8
67
The operator % is the modulo operator,.e.g,. 3%2 is 1. This operator cannot be used with __.
double and float
68
property of types: - → - → - →- → -→ _
char → int → long → float→double → long double
69
how to do 2^5
pow(2,5)
70
how to do |-5|
fabs(-5)
71
False is represented by _
0
72
True is represented by any value _
bigger than 0
73
The most immediate application of boolean expressions are __
conditional statement
74
Statements in a program are executed one after each other; this is know as _
sequential flow control.
75
In C, a loop consists of two parts: the _ and the _
body control statement
76
A control statement :
indicates the condition(s) driving the loop by executing the body until the condition or conditions become False.
77
In C, the looping statements are classified into two types:
Entry controlled loop Exit controlled loop
78
Entry controlled loop:
the condition is checked before execution of the body.
79
Exit controlled loop:
the condition is checked after execution of the body.
80
while-loops, entry- or exit controlled?
entry
81
for loops, entry- or exit controlled?
entry
82
do-while loops, entry- or exit controlled?
exit
83
if, if-else, and switch are _
conditional statements
84
As you already have experience, if we are not careful we can end up in a case in which the expression will never become zero. This will lead to an _ , and we will be stuck forever!
infinite loop
85
The condition in for loops is _ ; if it is nonzero (True), control passes back to the beginning of the loop, and it stops when False is returned.
a logical expression
86
f o r ( 1; 2; 3) { 4 ; }
1. initialization 2. condition 3.update 4. statements
87
what does the do-while loop tests?
It tests the termination condition after each pass through the loop body. The body is executed at least once!
88
the break statement is a special command that _ _. It stops __ a loop
interrupts the flow of control prematurely
89
the switch statement:
It is a way to generalize the conditional (if-else) statements. It compares constants.
90
def of function:
is a block of code -or collection of statements- that runs when is invoked. We can pass data (parameters) into a function.
91
In C, the main() function is __. It is user-defined and mandatory!
”the entry point of a program where the execution starts”
92
the main function is called by the _, not the _
OS user
93
i n c l u d e i n t a = 3 3 ; i n t main ( ) { i n t b = 7 7 ; p r i n t f ( ” a = %d\n” , a ) ; p r i n t f ( ”b = %d\n” , b ) ; r e t u r n 0 ; } what is the global and the local variable?
local: b global: a
94
Local variables :
are declared in the body of a function
95
Global variables :
are declared outside of any function, and are available for any routine in the program
96
unction prototype:
t y p e f u n c t i o N a m e ( p a r a m e t e r s ) ;