1.1 Review of Python Basics Flashcards
What is Python?
a popular programming language.
What is Python?
It was created in 1991 by Guido van Rossum.
Python is used for:
- web development (server-side),
- software development,
- mathematics,
- system scripting.
What can Python do?
*can be used on a server to create web applications.
*can be used alongside software to create workflows.
*can connect to database systems. It can also read and modify files.
*can be used to handle big data and perform complex mathematics.
*can be used for rapid prototyping, or for production-ready software development.
Why Python?
*Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
*Python has a simple syntax similar to the English language.
*Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
*Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
*Python can be treated in a procedural way, an object-orientated way or a functional way.
Whenever you are done in the python command line, you can simply type _____ to quit the python command line.
exit()
*very important
*indicate a block of code.
Python Indentations
Python will give you an error if you skip the ________:
indentation
Python has _________ capability for the purpose of in-code documentation.
commenting
________ start with a #, and Python will render the rest of the line as a comment
Comments
Python also has extended documentation capability, called _________.
docstrings
can be one line, or multiline
Docstrings
Python uses ______ ______ at the beginning and end of the docstring
triple quotes
Unlike other programming languages, Python has no command for declaring a variable.
Creating Variables
*A ________ is created the moment you first assign a value to it.
variable
_________ do not need to be declared with any particular type and can even change type after they have been set.
Variables
Rules for Python variables:
*A variable name must start with a letter or the underscore character
*A variable name cannot start with a number
*A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
*Variable names are case-sensitive (age, Age and AGE are three different variables)
Three numeric types in Python:
- int
- float
- complex
To verify the type of any object in Python, use the _____ function
type()
is a whole number, positive or negative, without decimals, of unlimited length.
int or integer
is a number, positive or negative, containing one or more decimals.
float
Float can also be scientific numbers with an “__” to indicate the power of 10.
e
_________ numbers are written with a “j” as the imaginary part
complex
Specify a Variable Type
*There may be times when you want to specify a type on to a variable.
*This can be done with casting.
*Python is an object-orientated language, and as such it uses classes to define data types, including its primitive types.