Python
exception handling
Exception handling ensures that the flow of the program doesn't break when an exception occurs. For example, if a program has bunch of statements and an exception occurs mid way after executing certain statements then the statements after the exception will not execute and the program will terminate abruptly. use booleans to build around exceptions or try/except
Machine code
In computer programming, machine code, consisting of machine language instructions, is a low-level programming language used to directly control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very specific task, such as a load, a store, a jump, or an arithmetic logic unit (ALU) operation on one or more units of data in the CPU's registers or memory. Machine code is a strictly numerical language which is intended to run as fast as possible, and may be regarded as the lowest-level representation of a compiled or assembled computer program or as a primitive and hardware-dependent programming language. While it is possible to write programs directly in machine code, managing individual bits and calculating numerical addresses and constants manually is tedious and error-prone. For this reason, programs are very rarely written directly in machine code in modern contexts, but may be done for low level debugging, program patching (especially when assembler source is not available) and assembly language disassembly. The overwhelming majority of practical programs today are written in higher-level languages or assembly language. The source code is then translated to executable machine code by utilities such as compilers, assemblers, and linkers, with the important exception of interpreted programs,[1] which are not translated into machine code. However, the interpreter itself, which may be seen as an executor or processor performing the instructions of the source code, typically consists of directly executable machine code (generated from assembly or high-level language source code). Machine code is by definition the lowest level of programming detail visible to the programmer, but internally many processors use microcode or optimise and transform machine code instructions into sequences of micro-ops. This is not generally considered to be a machine code.
Interpreter
In computer science, an interpreter is a computer program that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. An interpreter generally uses one of the following strategies for program execution: Parse the source code and perform its behavior directly; Translate source code into some efficient intermediate representation and immediately execute this; Explicitly execute stored precompiled code[1] made by a compiler which is part of the interpreter system. Early versions of Lisp programming language and minicomputer and microcomputer BASIC dialects would be examples of the first type. Perl, Python, MATLAB, and Ruby are examples of the second, while UCSD Pascal is an example of the third type. Source programs are compiled ahead of time and stored as machine independent code, which is then linked at run-time and executed by an interpreter and/or compiler (for JIT systems). Some systems, such as Smalltalk and contemporary versions of BASIC and Java may also combine two and three.[2] Interpreters of various types have also been constructed for many languages traditionally associated with compilation, such as Algol, Fortran, Cobol, C and C++. While interpretation and compilation are the two main means by which programming languages are implemented, they are not mutually exclusive, as most interpreting systems also perform some translation work, just like compilers. The terms "interpreted language" or "compiled language" signify that the canonical implementation of that language is an interpreter or a compiler, respectively. A high level language is ideally an abstraction independent of particular implementations.
Compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the source language) into another language (the target language). The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language, object code, or machine code) to create an executable program. There are many different types of compilers. If the compiled program can run on a computer whose CPU or operating system is different from the one on which the compiler runs, the compiler is a cross-compiler. A bootstrap compiler is written in the language that it intends to compile. A program that translates from a low-level language to a higher level one is a decompiler. A program that translates between high-level languages is usually called a source-to-source compiler or transcompiler. A language rewriter is usually a program that translates the form of expressions without a change of language. The term compiler-compiler refers to tools used to create parsers that perform syntax analysis. A compiler is likely to perform many or all of the following operations: preprocessing, lexical analysis, parsing, semantic analysis (syntax-directed translation), conversion of input programs to an intermediate representation, code optimization and code generation. Compilers implement these operations in phases that promote efficient design and correct transformations of source input to target output. Program faults caused by incorrect compiler behavior can be very difficult to track down and work around; therefore, compiler implementers invest significant effort to ensure compiler correctness. Compilers are not the only language processor used to transform source programs. An interpreter is computer software that transforms and then executes the indicated operations. The translation process influences the design of computer languages, which leads to a preference of compilation or interpretation. In practice, an interpreter can be implemented for compiled languages and compilers can be implemented for interpreted languages.
operator
Operators are used to combine expressions into more complex expressions. For example, in x + 3 * y the operators are + and *
A CPU deals with memory in fixed pieces. The smallest addressable piece is typically 8 bits, which is called a byte of memory. A single byte can store 2^8 = 256 values. That's more than enough to represent every possible ASCII character (in fact, ASCII is only a 7 bit code).
/
As of 2019, the largest transistor count in a commercially available microprocessor is 39.54 billion MOSFETs, in AMD's Zen 2 based Epyc Rome, which is a 3D integrated circuit (with eight dies in a single package) fabricated using TSMC's 7 nm FinFET semiconductor manufacturing process.[1][2] As of 2020, the highest transistor count in a graphics processing unit (GPU) is Nvidia's GA100 Ampere with 54 billion MOSFETs, manufactured using TSMC's 7 nm process.[3] As of 2019, the highest transistor count in any IC chip is Samsung's 1 TB eUFS (3D-stacked) V-NAND flash memory chip, with 2 trillion floating-gate MOSFETs (4 bits per transistor).[4] As of 2019, the highest transistor count in a non-memory chip is a deep learning engine called the Wafer Scale Engine 2 by Cerebras, using a special design to route around any non-functional core on the device; it has 2.6 trillion MOSFETs, manufactured using TSMC's 7 nm FinFET process. In terms of the total number of transistors in existence, it has been estimated that a total of 13 sextillion (1.3×1022) MOSFETs have been manufactured worldwide between 1960 and 2018, primarily on the volume of recently shipped NAND flash (with no indication given for how evolution in the number of bits/NAND flash cell was factored into this). MOSFETs account for at least 99.9% of all transistors, so other types were ignored. This makes the MOSFET the most widely manufactured device in history.[11]
/
As you 'edit a file' you are really making changes to data in memory, not the file itself. The changes will not show up in the file on the disk until you tell the application to 'save' it.
/
The basic idea of object-oriented development is to view a complex system as the interaction of simpler objects.
/
Your first task is to find a correct algorithm. After that, strive for clarity, simplicity, efficiency, scalability, and elegance.
/
Unicode
A character code that enables most of the languages of the world to be symbolized with a special character identification. Unicode is a character encoding standard that has widespread acceptance. ... They store letters and other characters by assigning a number for each one. Before Unicode was invented, there were hundreds of different encoding systems for assigning these numbers
function nesting
A function defined inside another function is called a nested function. Nested functions can access variables of the enclosing scope. In Python, these non-local variables are read-only by default and we must declare them explicitly as non-local (using nonlocal keyword) in order to modify them.
DeMorgan's Law
A method you can use to rewrite the negative version of complex conditionals.
alpha-numeric characters
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
ASCII vs. UNICODE
ASCII is just for english. Unicode is all global language characters. ASCII defines 128 characters, which map to the numbers 0-127. Unicode defines (less than) 221 characters, which, similarly, map to numbers 0-221 (though not all numbers are currently assigned, and some are reserved). Unicode is a superset of ASCII, and the numbers 0-127 have the same meaning in ASCII as they have in Unicode. For example, the number 65 means "Latin capital 'A'". Because Unicode characters don't generally fit into one 8-bit byte, there are numerous ways of storing Unicode characters in byte sequences, such as UTF-32 and UTF-8.
control structures
According to the structure theorem, any computer program can be written using the basic control structures . A control structure (or flow of control) is a block of programming that analyses variables and chooses a direction in which to go based on given parameters. In simple sentence, a control structure is just a decision that the computer makes. So, it is the basic decision-making process in programming and flow of control determines how a computer program will respond when given certain conditions and parameters. There are two basic aspects of computer programming: data and instructions . To work with data, you need to understand variables and data types; to work with instructions, you need to understand control structures and statements. Flow of control through any given program is implemented with three basic types of control structures: Sequential, Selection and Repetition. Sequential Sequential execution is when statements are executed one after another in order. You don't need to do anything more for this to happen. Selection Selection used for decisions, branching - choosing between 2 or more alternative paths. if if...else switch Repetition Repetition used for looping, i.e. repeating a piece of code multiple times in a row. while loop do..while loop for loop These control structures can be combined in computer programming. A sequence may contain several loops; a loop may contain a loop nested within it, or the two branches of a conditional may each contain sequences with loops and more conditionals. From the following lessons you can understand the control structures and statements in Python language.
runtime error
An error that does not occur until the program has started to execute but that prevents the program from continuing.
initialize
Assign a value to a variable for the first time. set to the value or put in the condition appropriate to the start of an operation. "the counter is initialized to one"
definite and indefinite loops
Definite: a set of instructions is repeated a specific number of times. It is implemented by using count-controlled loops, such as for loops. Indefinite: a set of instructions is repeated until a condition is met. It is implemented by using condition-controlled loops, such as while loops.
interpreter vs compiler
Interpreter translates just one statement of the program at a time into machine code. Compiler scans the entire program and translates the whole of it into machine code at once. An interpreter takes very less time to analyze the source code. However, the overall time to execute the process is much slower.
module vs. library
Library : It is a collection of modules. (Library either contains built in modules(written in C) + modules written in python). Module : Each of a set of standardized parts or independent units that can be used to construct a more complex structure. It's important to keep in mind that all packages are modules, but not all modules are packages. Or put another way, packages are just a special kind of module. Specifically, any module that contains a __path__ attribute is considered a package. In my opinion, a library is anything that is not an application - in python, a library is a module - usually with submodules. The scope of a library is quite variable - for example the python standard library is vast (with quite a few submodules) while there are lots of single purpose libraries in the PyPi, e.g. a backport of collections.OrderedDict for py < 2.7 A package is a collection of python modules under a common namespace. In practice one is created by placing multiple python modules in a directory with a special __init__.py module (file). A module is a single file of python code that is meant to be imported. This is a bit of a simplification since in practice quite a few modules detect when they are run as script and do something special in that case. A script is a single file of python code that is meant to be executed as the 'main' program. If you have a set of code that spans multiple files, you probably have an application instead of script.
Metaprogramming
Metaprogramming is a programming technique in which computer programs have the ability to treat other programs as their data. It means that a program can be designed to read, generate, analyze or transform other programs, and even modify itself while running. In some cases, this allows programmers to minimize the number of lines of code to express a solution, in turn reducing development time.[3] It also allows programs greater flexibility to efficiently handle new situations without recompilation.
The global Keyword
Normally, when you create a variable inside a function, that variable is local, and can only be used inside that function. To create a global variable inside a function, you can use the global keyword.
nesting
Putting an object inside another object; In computing science and informatics, nesting is where information is organized in layers, or where objects contain other similar objects. It almost always refers to self-similar or recursive structures in some sense. Nesting can mean: nested calls: using several levels of subroutines.
garbage collection
Releases memory that was used for a variable's value once the variable is no longer to be used by a program. e.g x = 1 x = 2 # x = 1 is deleted In computer science, garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. Garbage collection relieves the programmer from performing manual memory management where the programmer specifies what objects to deallocate and return to the memory system and when to do so. Other similar techniques include stack allocation, region inference, memory ownership, and combinations of multiple techniques. Garbage collection may take a significant proportion of total processing time in a program and, as a result, can have significant influence on performance. Resources other than memory, such as network sockets, database handles, user interaction windows, file and device descriptors, are not typically handled by garbage collection. Methods used to manage such resources, particularly destructors, may suffice to manage memory as well, leaving no need for GC. Some GC systems allow such other resources to be associated with a region of memory that, when collected, causes the work of reclaiming these resources.
What is unique about a set?
They don't allow for duplicate items!
assembly language
Today, assembly language is still used for direct hardware manipulation, access to specialized processor instructions, or to address critical performance issues. Typical uses are device drivers, low-level embedded systems, and real-time systems. In computer programming, assembly language (or assembler language),[1] often abbreviated asm, is any low-level programming language in which there is a very strong correspondence between the instructions in the language and the architecture's machine code instructions.[2] Because assembly depends on the machine code instructions, every assembly language is designed for exactly one specific computer architecture. Assembly language may also be called symbolic machine code. Assembly code is converted into executable machine code by a utility program referred to as an assembler. The conversion process is referred to as assembly, as in assembling the source code. Assembly language usually translates each mnemonic assembly instruction to machine code 1:1, but comments and statements that are assembler directives,[5] macros,[6][1] and symbolic labels of program and memory locations are often also supported. However, before assemblers and compilers in general became more accessible to consumers in the late 80s, assembling with pen and paper by comparing the mnemonic instructions to an opcode chart was a common practice, especially with users of 8-bit home computers such as the Commodore 64 and the ZX Spectrum, like their predecessors had been doing on mainframes in the early fifties, before assembler programs became generally available for institutional "stored-program computers".
What is the major difference between tuples and lists?
Tuples are immutable!
aliasing
in computer graphics, the jagged, or saw-toothed appearance of curved or diagonal lines on a low-resolution monitor. the misidentification of a signal frequency, introducing distortion or error.
Relational Operators
Used to compare two values. Operators include =,<,>,<=,>=,<>
Global Variables
Variables that are created outside of a function (as in all of the examples above) are known as global variables. Global variables can be used by everyone, both inside of functions and outside. x = "awesome" def myfunc(): print("Python is " + x) myfunc()
To concatenate, or combine, two strings you can use the + operator.
a = "Hello" b = "World" c = a + b print(c)
ASCII (American Standard Code for Information Interchange)
a code for representing English characters as numbers, with each letter assigned a number from 0 to 127 industry standard encoding for english keyboards ASCII was developed from telegraph code. Its first commercial use was as a seven-bit teleprinter code promoted by Bell data services. Work on the ASCII standard began on October 6, 1960, with the first meeting of the American Standards Association's (ASA) (now the American National Standards Institute or ANSI) X3.2 subcommittee. The first edition of the standard was published in 1963,[4][5] underwent a major revision during 1967,[6][7] and experienced its most recent update during 1986.[8] Compared to earlier telegraph codes, the proposed Bell code and ASCII were both ordered for more convenient sorting (i.e., alphabetization) of lists, and added features for devices other than teleprinters.[citation needed] Originally based on the English alphabet, ASCII encodes 128 specified characters into seven-bit integers as shown by the ASCII chart above.[11] Ninety-five of the encoded characters are printable: these include the digits 0 to 9, lowercase letters a to z, uppercase letters A to Z, and punctuation symbols. In addition, the original ASCII specification included 33 non-printing control codes which originated with Teletype machines; most of these are now obsolete,[12] although a few are still commonly used, such as the carriage return, line feed and tab codes. For example, lowercase i would be represented in the ASCII encoding by binary 1101001 = hexadecimal 69 (i is the ninth letter) = decimal 105.
String Methods
bunch more than in picture https://www.w3schools.com/python/python_strings.asp
Random Number
import random print(random.randrange(1,10))
Web colors
describing and specifying those colors. Colors may be specified as an RGB triplet or in hexadecimal format (a hex triplet) or according to their common English names in some cases. A color tool or other graphics software is often used to generate color values. In some uses, hexadecimal color codes are specified with notation using a leading number sign (#).[1][2] A color is specified according to the intensity of its red, green and blue components, each represented by eight bits. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and 16,777,216 colors that may be so specified. Colors outside the sRGB gamut can be specified in Cascading Style Sheets by making one or more of the red, green and blue components negative or greater than 100%, so the color space is theoretically an unbounded extrapolation of sRGB similar to scRGB.[3] Specifying a non-sRGB color this way requires the RGB() function call; it is impossible with the hexadecimal syntax (and thus impossible in legacy HTML documents that do not use CSS). e.g. The RGB color 0, 255, 150 is a dark color, and the websafe version is hex 00FF99. The color can be described as middle saturated spring green. A complement of this color would be 255, 0, 105, and the grayscale version is 167, 167, 167.
Other escape characters used in Python:
https://www.w3schools.com/python/python_strings.asp
decision structures
introduce decision-making ability into a program. They enable you to branch to different sections of the code depending on the truth value of a Boolean expression. Decision structures evaluate multiple expressions which produce TRUE or FALSE as outcome. diamonds show conditional decisions
Formatting Types
more on link: https://www.w3schools.com/python/ref_string_format.asp
If you create a variable with the same name inside a function, this variable will be local, and can only be used inside the function. The global variable with the same name will remain as it was, global and with the original value.
output is: Python is fantastic Python is awesome
truncate
to shorten by cutting off
Type Conversion
x = 1 # int y = 2.8 # float z = 1j # complex #convert from int to float: a = float(x) #convert from float to int: b = int(y) #convert from int to complex: c = complex(x) print(a) print(b) print(c) print(type(a)) print(type(b)) print(type(c)) Note: You cannot convert complex numbers into another number type.
are tuples immutable?
yes.