Murach Python Programming Chapter 1 & 2
How do you insert comments in Python?
# followed by the comment
What is the most common shebang line for python?
#!/usr/bin/env python3
What is the symbol in Python for exponents?
**
file type for python source code
.py
file types for python module code
.pyc or .pyo
How many bits are in a byte?
8
What is the assignment operator in Python?
= sign
escape character
A character in text that is not taken literally but has a special meaning when combined with the character or characters that follow it. The \ character is an escape character in python strings.
Compiler
A computer program created to read an entire program and convert it into a lower-level language and ultimately to assembly language used by the processor.
What is camel case?
A convention for naming variables in Python in which the first word is lowercase and the first letter of subsequent words is uppercase
source code
A program in a high-level language before being compiled.
Interactive Shell
A program that allows the user to type in Python expressions and statements one at a time and evaluates them.
Platform-independent application
A program that can be run on any computer regardless of operating system or hardware configuration.
Python virtual machine (PVM)
A program that interprets Python byte codes and executes them.
Command Prompt
A request for input that appears at the beginning of the command line.
Function (Programming)
A term used in programming to describe a self-contained sequence of instructions that performs a specific task or tasks and is designed to be able to be reused throughout the program. Functions often accept some kind of input, perform some process on that input, and return a result that can be used by other parts of a program. Most programming languages allow for user-defined functions, but will also provide pre-defined functions.
Shortcut for retyping a previous line in the python shell
Alt-p
exception
An error or other message raised by the interpreter or compiler to indicate a special circumstance that should be handled by an exception handler. If an exception is not handled, the program will stop and report the error.
literal value
Any constant value written in a program
Byte code instructions
Are read and interpreted by the JVM
BDFL (abbr.)
Benevolent Dictator for Life
CPU
Central Processing Unit; the brain of the computer.
ARGUMENT (PROGRAMMING)
Data passed to a function in a software program
Persistent Data Storage
Data stored beyond the current transaction history which can be retrieved later
What IDE is commonly used for python development?
Eclipse
What is the shortcut for compiling and running source code in python IDLE?
F5
Who created the Python programming language?
Guido van Rossum
Name three popular Python IDEs...
IDLE, PyCharm, Eclipse
What is integer division and what is the operator?
Integer division is division that drops the decimal values, the operator is //
What is modulo and what is the operator?
Modulo is the same as remainder, returning the leftover integers from division. The operator is %.
Compound assignments in python
Putting the operator before the = sign performs the operation and updates the value of the variable.
What happens if you assign a new value to a variable that is of a different data type?
Python adjusts and uses the new data type
RAM
Random Access Memory
What is the use of /r versus /n?
The answer has yet to determined by me, in general, /n is used but there may be some application for /r, particularly when looking through data sets created on different OSs
What two types of formatting are often used for naming variables?
Underscore notation and Camel case
What are the two ways to insert quotation marks within a string?
Use the escape character or use double quotations for the outside of the string and single quotations for the quotation marks
Main Memory (RAM)
Working memory that a program uses for intermediate calculations.
Can you use numbers in a variable name?
Yes, but it cannot begin with a number
how is explicit continuation done?
\ and indent the next line
New line in Python
\n
Return in Python
\r
Tab in Python
\t
Python interpreter
a program that converts the source code to byte code
How do you store a number as a string?
enclose it in quotation marks
What is another term for a runtime error?
exception
Floating-point (python)
float
convert a string value to a floating-point number
float(string)
What is the standard indentation for Python code?
four spaces
GUI (abbr.)
graphical user interface
input (python)
input([prompt]). Remember that all data is stored as strings.
Integer (Python)
int
convert a string value to an integer
int(string)
IDE (abbr.)
integrated development environment
How does Python assign variable type?
it does so automatically based on the input
concatenate
link together
chained functions
nesting functions within each other as a sort of shorthand code
numeric literal
number not enclosed in quotes
How do you concatenate a string?
place a + between the strings
print function in python
print(data, [sep =' '], [end = '\n']). The default is that spaces are added and the print ends with a newline. Also numbers don't have to be converted to strings.
round a number
round(number, [digits]), rounds the decimal places
named argument
specifies which parameter an argument should be passed into
How do you insert and multiline comment in Python?
start each comment line with #
How is implicit continuation done?
start the next line before or after a + or - or ( and indent the next line
String (Python)
str, enclosed in quotation marks
What are the two most common types of error in Python?
syntax error and runtime error
Why two types of software are stored in disk memory?
systems software and application software
string literal
text enclosed in quotes
shebang line
the starting line in a Unix program that begins with #! and specifies the interpreter for the progam
Determining the type of data
type(data)