Coding questions Flashcards
What is the difference between list and tuples in Python?
Lists are mutable, can be edited. Tuples are immutable.
Lists are slower than tuples.
Lists use [] tuples use ()
What are the key features of python?
- its an interpreted language, does not need to be compiled before its run.
- you don’t need to tell it what type of variables you’re making.
What type of language is python? programming or scripting?
- capable of scripting, but in general it is considered programming.
Explain how python is an interpreted language
any programming language which is not in machine-level code before runtime.
what is pep 8?
Python Enhancement Proposal. a set of rules that specify how to format python code for maximum readability.
Benefits of using python
- easy to use.
- interpreted language i.e. executes the code line by line and stops if an error occurs in any line.
- free and open source
- python has vast libraries that contain almost any function needed.
- portable i.e. can run on any platform.
what are python namespaces?
the name which is assigned to each object in python. the objects are variables and functions. 4 types of namespaces: 1. built in 2. global 3. enclosing 4. local
What are the common built in data types in python/
numbers - integers, floats, complex numbers. list tuple string set dictionary boolean
What is the difference between .py and .pyc files?
.py files are python source code files.
.pyc files contain the btyecode of the python files.
What is slicing in python
used to access parts of sequences like lists, tuples, strings. [start:end:step]
how to combine data frames in pandas?
- concatenating by stacking vertically
- concatenating by stacking horizontally
- combining on a common column. (joining)
pd. concat()
what are python modules
files containing python code. os sys math random data time
what is type conversion
conversion of one data type into another
int()
float()
difference between arrays and lists
have the same way of storing data.
Arrays can hold a single data type whereas lists can old any data type.
What does [::-1] do?
reverses the order of an array