Module 1 Flashcards

1
Q

Language

A

a means for expressing and recording thoughts

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

Machine language

A

very rudimentary computer language

binary language (0s and 1s)

it is the language that computers understand at their core

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

Natural language

A

languages that develop organically, naturally

human language

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

What are the 4 parts of a language?

A

alphabet

lexis

syntax

semantics

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

what is a language’s alphabet?

A

a set of symbols used to build words of a certain language

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

what is a language’s lexis?

A

a set of words the language offers its users

a dictionary

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

what is a language’s syntax?

A

a set of rules used to determine if a certain string of words forms a valid sentence

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

what is a language’s semantics?

A

a set of rules determining if a certain phrase makes sense

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

instruction list

A

complete list of known commands for a computer

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

alphabet of a machine language

A

the computer’s mother tongue

these are sets of symbols that we use to give commands to a computer (through a high-level language like Python)

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

High level programming language

A

java, python, javascript, c#, etc.

a programming language designed to be easier for humans to understand and write, using syntax closer to natural language, rather than the low-level machine code of a computer

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

source code

A

a program written in a high-level programming language

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

source file

A

the file containing the source code

in other words a file containing a program written in high-level programming language

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

compilation

A

the source program is translated to machine language

This action must be repeated each time you modify the source code

This means the program can be distributed as an executable file to be run on other computers

C#, C++, Java

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

interpretation

A

the source code is read into machine code each time the program is run

the downside is that whoever is running the program must have the interpreter installed to run it

Python, JavaScript

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

computer program is actually just a …

A

pure text file (no decorations, like fonts colors embedded images, or other media)

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

interpreted languages are also known as

A

scripting languages

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

Python creator

A

Guido van Rossum

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

Guido van Rossum

A

the creator of python

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

CPython

A

The default implementation of the Python language – the one that is downloaded from Python.org

The canonical version

written and maintained by the Python Software Institute (PSF) of which, Guido is president

Written in the C programing language

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

Cython

A

translates python code into C

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

What does the interpreter do?

A

It directly executes instructions written in a programming language.

It reads the high level programming language and translated it into low level machine code

Specifically, it reads the source code from left to right top to bottom as is common in western culture and uncovers errors as it goes.

the first error it encounters, it finishes its interpretation of the code

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

Advantages of compilation

A

execution of the translated code (the code that is translated to machine language) is generally faster

only the user (the programmer) needs to have the compiler. The end-user gets the translated file

The translated code is stored as machine language, and so it is very hard to understand it, so programming tricks can remain hidden

24
Q

Disadvantages of Compilation

A

The complication is a time consuming process

you have to have as many compilers as hardware platforms you want your code to run on

Compiler catches only syntax and semantic errors while compiling. So other errors may not be found until runtime and may be hard to race at that point

25
Advantages of Interpretation
You can run the code as soon as you complete it The code is stored as programming language (high level language) so you do not need a compiler for each type of system in order to disburse the code In other words, it can be run on different computers that use different types of machine language
26
Disadvantages of Interpretation
Interpretation will take some CPU power, so an interpreted program will never be as fast or as efficient as a compiled program Both the programmer and the end user need the interpreter in order to run the program Not as secure as compiler because everyone can see the source code
27
Python rival languages?
Perl ruby - more innovative than Python
28
Which Python does this course (2025) use?
Python 3
29
Jython
A Python written in Java instead of C
30
PyPy
A Python environment written in Python
31
What do you need in order to work with Python?
Python must be installed on your computer An editor which supports your code must be available A console from which you can launch your code and stop it when there is a problem A debugger which will allow you to inspect your code at each moment of execution
32
negative indexing
Negative indexing starts at -1 So, given thisList = ['hat', 'cat', 'mat'] print(thisList[-1]) console: mat OR thisStr = 'a string here this is one' print(thisStr[-1]) console: e no start: no stop: step = -1 (flips the string) print(thisStr[::-1]) console: eno is siht ereh gnirts a
33
Booleans
True or False capitalized first letter # so, true and false would result in NameErrors as Python would consider them unassigned variables
34
What does "pass" do?
Nothing. Nothing at all. A whole lotta nothing.
35
What does "continue" do?
Skips the current iteration of a loop and continues to the next iteration. x = 0 while x < 8: if x % 2 == 0: continue print('#') The code above won’t print anything because x is never incremented so it will always be 0 which means the continue just skips the iteration of the loop over and over again. Infinitely. Also this wouldn't work either, as the continue just skips the print every time x = 0 while x < 8: if x % 2 == 0: continue print('#') X+=1
36
What does the bitwise left shift operator ( << ) do?
The bitwise left shift operator (<<) moves the bits of its first operand to the left by the number of places specified in its second operand Shifting a single bit to the left by one place doubles its value
37
name this operator: <<
bitwise left shift operator
38
What is the result? 2 << 5
64
39
Name this operator: >>
bitwise right shift operator
40
What does the bitwise right shift operator do?
The bitwise right shift operator (>>) moves the bits of its first operand to the right by the number of places specified in its second operand Shifting a single bit to the right by one place halves its value
41
What does IDLE stand for?
Integrated Development and Learning Environment
42
What does a debugger do?
A tool that lets you launch your code step-by-step and inspect it at each moment of execution
43
What is the expected behavior of the following program? prin("Goodbye!")
This program will generate an error Specifically, a NameError (since the object "prin" is not defined
44
What is a console?
A command-line interpreter that lets you interact with your OS and execute Python commands and scripts
45
What is the best definition of a script?
A text file which contains instructions which make up a Python program
46
What is the expected behavior of the following program? print("Hello!")
Prints Hello! to the console
47
What is the result of this program ? And why? thisStr = “here it is” print(thisStr[::-1])
si ti ereh The string indexing resolves to: [no start index : no end index : -1 step] So it starts at the end of the string and steps backwards until the beginning
48
A complete set of known commands in a programming language is called
An instruction list
49
Integer division always produces an integer if …..
Both operands are an integer otherwise it produces a float. And it always rounds down to the nearest integer value that is less than the real (not rounded) result Which means every rounded float will be .0 So…. print( 6 // 4. ) Will print ….. 1.0 It would be 1.5 if it was regular division but it rounds down to 1.0 when it is integer division
50
What is the result of this code snippet? print( -4 - +4 )
-8 The +4 is redundant, so -4 -4 = -8
51
What is the printout of the code below? print( print( ‘this’ ) )
this None The print() function has no return value, therefore, printing the print function produces None
52
What is “syntax” for any programming language?
The specific rules and structure that determine how code is written and organized, ensuring the computer can understand and execute it correctly. Think of it as the language’s grammar.
53
What is the semantics of a programming language?
The meaning and interpretation of the code, or what the code actually does when executed, as opposed to its syntax (grammar)
54
What is the Python command for declaring a variable?
There isn’t one. A variable is created the moment you assign a value to it
55
How do you convert one data type to another
With casting str() int() float()
56
What will be the output of the following code when the user provides the following input: 5 num = float(input('Give a float:')) num *= 3 print('You gave ' + num)
TypeError You can't concatenate a number to a string
57
What is the result? 6/2
3.0 division always returns a floating point number