Python Concepts Flashcards

1
Q

Object Oriented Programming

A

Object-oriented programming is a programming paradigm that provides a means of structuring programs so that properties and behaviors are bundled into individual objects.

This type of programming utilizes objects and classes. Objects can contain both functions (or methods) and data.

An object provides a public interface to other code that wants to use it but maintains its own private, internal state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is Javascript an Object Oriented Programming Language?

A

Javascript is not a class-based object-oriented programming language. However, it does have ways of implementing object oriented programming. It just doesn’t strictly enforce compliance with OOP Principles.

It’s better known as a scripting language

You can implement OOP in JS by using objects, which contain properties and methods and support prototypal inheritance.

__proto__ property on objects can can be modified to refer to other prototypes

Object.create or the “new” keyword can be used to pass an argument to a prototype

ES6 also introduced the “class” keyword, but it’s just syntactic sugar over the existing prototyping technique. You can also implement subclasses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

4 Core Principles of Object Oriented Programming (OOP)

A

Abstraction
Encapsulation
Inheritance
Polymorphism

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Python Class

A

Classes are templates used to define the properties and methods of objects in code.

They can describe the kinds of data that the class holds, and also how a programmer interacts with that data.

Class instances are created to implement design principles such as inheritance and encapsulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Python Object

A

A python object is an instantiation of a class. It has both attributes and behaviors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Python Methods

A

Python methods are functions defined inside the body of a class. They are used to define the behaviors of an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Python Object Attributes

A

Attributes are defined in the class template and represent the state of an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Abstraction

A

One of the 4 core principles of OOP

Abstraction - objects only reveal internal mechanisms that are relevant for the use of other objects, hiding unnecessary implementation code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Encapsulation

A

One of the 4 core principles of OOP

Encapsulation - wrapping data and the methods that work on that data in one unit.

Reduces software development complexity greatly and can help prevent accidental modification of data

Most of the time encapsulation can be achieved by creating classes with an overarching design structure that includes private and public methods (or getters and setters) for our systems to interact

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Inheritance

A

One of the 4 core principles of OOP

Inheritance is one of the most important principles of object-oriented programming (OOP). It allows for one class (child class) to inherit the fields and methods of another class (parent class).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Polymorphism

A

One of the 4 core principles of OOP

polymorphism means having many forms

objects are designed to share behaviors but they can take on more than one form.

Polymorphism in Python allows us to define methods in the child class with the same name as defined in their parent class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Strongly Typed

A

Strong typing means that variables do have a type and that the type matters when performing operations on a variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Dynamically Typed

A

Dynamically-typed languages are those (like JavaScript) where the interpreter assigns variables a type at runtime based on the variable’s value at the time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Scalar Types

A

scalar types have a finite set of possible values, and can be compared to other scalar values as equal, greater than or less than.

examples:
int
float
True
False
None`
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Collection Types

A

Collections in python are basically container data types

examples:
Set
List
Tuple
Dictionary
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

string

A

A collection of one or more character put in single, double or triple quotes

17
Q

list

A

An ordered collection of one or more data items, put in square brackets

Lists ARE Mutable

18
Q

tuple

A

an ordered collection of one or more data items, not neccessarily the same type, put in parentheses

tuples are IMMUTABLE

19
Q

set

A

Sets are similar to lists, but are unordered, unchangeable, and do not allow duplicate values.

20
Q

dict

A

store python data in key value pairs

duplicate keys not allowed

as of Python 3.7, dictionaries ARE ordered