Advanced Concepts in Python

Cards (95)

  • Advanced Concepts in Python is a document that continues the first part called “Introduction to Python”.
  • All of the class methods in Python have the parameter self, meaning you will have access to the object’s attributes right away, and no variables were declared outside the constructor.
  • Creating an object in Python is done by invoking the class name as a function with the necessary arguments.
  • In Python, you can access the attributes and methods of an object.
  • The variable definition and initialization in Python is done at the beginning of the script.
  • In Python, you can modify the attributes and values of an object.
  • The method bark in Python just returns a string value “Woof!”.
  • Instantiating objects in Python is done by calling the class constructor.
  • Lists/Arrays are commonly used to store multiple items of values.
  • Arrays are a fundamental data structure used in all programming for storing collections of items/elements.
  • In Python, a collection created using square brackets is called a List.
  • A List in Python can contain values, either homogenous or heterogeneous.
  • A numpy array is different from your typical array/list, as you have access to some powerful methods that lets you do operations in the list.
  • Whenever you try to run the python program, it will use the environment to check for installed modules/packages/dependencies.
  • This leads to the isolation of the packages and its versions from other projects and your system.
  • Common methods include np.array(your array here), np.zeros(), np.zeros((2,3)), np.flatten(name_of_array), np.tolist(name_of_array), np.sum(name_or_array), and np.prod(name_or_array).
  • Numpy is considered as one of the popular libraries for Machine Learning, AI, Computer Vision and other topics related on Computer Science, enabling you to manage/handle arrays, matrices and tensors in Python.
  • Any modules/packages/dependencies you've installed after activating the environment, the files associated to modules/packages is located in the environment folder created.
  • A List in Python can contain integers, strings, or a mix of both.
  • In Python, an indexed item/variable can be accessed using its index.
  • With the head method, you can get the number of items/rows from the table (this does not include the column headers).
  • This creates a DataFrame object that contains the list of rows and columns in the file.
  • To configure an X-Y graph using pyplot methods, follow the steps: plot accepts the array/matrix/tensor to be displayed, xlabel and ylabel set the name of the x and y axis, and show is needed to display the whole plot in a window.
  • This gives you the list of columns present in the table.
  • The opposite of the head method, this gets the items/rows starting from the bottom of the table, which you can set the number of items.
  • The X, Y axis, labels and other plot configurations are accessible using this module.
  • read_csv(name/directory of file) OR pd.read_excel(name/directory of file) enables you to read the most common files used, csv or excel extensions.
  • Creating a pandas object df.
  • This enables you to iterate and access the each row and its value specific to the column, with the use of a for loop.
  • The Matplotlib (specifically the pyplot) enables you to draw graphs (which is similar to Matlab).
  • In the constructor, parameters are given which gives values to the class’s attributes, and these values are then given to said attributes.
  • Python defines the constructor using the __init__ method.
  • In Python, self refers to the object, and self.name refers to the attribute name of the class.
  • C++ and Java constructor names are the same with their class names.
  • Objects are present in programming languages that support some or most OOP principles, such as Classes and Objects.
  • __init__ refers to the constructor of the class in Python.
  • Constructor refers to a special function/method typically used to create/instantiate objects of classes.
  • Classes are the templates used to create objects, as they contain the properties/attributes and methods.
  • The initial part of a class in Python includes two methods, init and bark.
  • A range for loop that skips if the value of i is 3 is used in West Visayas State University College of Information and Communications Technology.