Python module 1 Flashcards
(40 cards)
Name four simplace actions to form a program:
Accept a number representing distance
Accept a number representing travel time
Divide the former value by the later and store the result in memory
Display the result (representing average speed) in a readable format
Machine Language is ____
Rudimentary
Instruction List
Sometimes Abbreviated IL. Different types of computers may vary depending of their ILs
Each Language (machine or natural) consists of the following elements:
An Alphabet
A Lexis
A syntax
Semantics
Alphabet
A set of symbols used to build words of a certain language (e.g., the Latin alphabet for English, the Cyrillic alphabet for Russian, Kanji for Japanese and so on)
Lexis
(aka a dictionary) a set of words the language offers its users (e.g., the word “computer” comes from the English language dictionary, while “cmoptrue” doesn’t; the word “chat” is present both in English and French Dictionaries, but their meanings are different)
Syntax
A set of rules (formal or informal, written or felt intuitively) used to determine if a certain string of words forms a valid sentence (e.g., “I am a python” is a syntactically correct phrase, while “I a python am” Isn’t)
Semantics
a set of rules determining if a certain phrase makes sense (e.g., “I ate a doughnut” makes sense, but “A doughnut ate me” doesn’t.
The IL is
The alphabet of a machine language
A program written in a high-level programming language is called
a source
Source file
the file containing the source code
The two ways of transforming a program from a high-level programming language into machine language:
Compilation
Interpretation
Compilation
The source program is translated one (however, this act must be repeated each time you modify the source code) by getting a file (e.g., an .exe file if the code is intended to be run under MS Windows) containing the machine code; now you can distribute the file wordwide; the program that performs this translation is called a compiler or translator;
Interpretation
you (or any user of the code) can translate the source program each time it has to be run; the program performing this kind of transformation is called an interpreter, as it interprets the code every time it is intended to be executed; it also means that you cannot just distribute the source code as0is, because the end-user also needs the interpreter to execute it.
Text file
a computer program consisting of text after writing a program.
Pure text
without any decorations like fonts, colors, or embedded images or other media. Now you have to invoke the interpreter and let it read your source file
If the interpreter finds an error it finishes its work immediately. The only result in this case is an___
Error Message
Comiplation Advantages
- the execution of the translated code is usually faster;
- only the user has to have the compiler - the end-user may use the code without it;
- the translated code is stored using machine language - as it is very hard to understand it, your own inventions and programming tricks are likely to remain your secret.
Compilation Disadvantages
- the compilation itself may be a very time-consuming process - you may not be able to run your code immediately after making an amendment;
- you have to have as many compilers as hardware platforms you want your code to be run on.
Interpretation Advantages
- you can run the code as soon as you complete it - there are no additional phases of translation;
- the code is stored using programming language, not machine language - this means that it can be run on computers using different machine languages; you don’t compile your code separately for each different architecture.
Interpretation Disadvantages
- don’t expect interpretation to ramp up your code to high speed - your code will share the computer’s power with the interpreter, so it can’t be really fast;
- both you and the end user have to have the interpreter to run your code.
Python is
an interpreted language
Programming Python requires
Python Interpreter
Scripting Language
languages designed to be utilized in the interpretation manner