Question

In: Computer Science

Can you please post the most/main important terminologies for Python coding and explain what they mean...

Can you please post the most/main important terminologies for Python coding and explain what they mean (e.g. Class - xyz, function - xyz, conductor - xyz, method - xyz, instance variable - xyz, variable - xyz) (Feel free to add anything I may have missed or that you think is also important)?

Solutions

Expert Solution

(NOTE - If you need more information, let me know in the comment box. I have included the basics as mentioned)

PYTHON

It is a high level and general purpose programming language created by Guido van Rossum.

Python is dynamically typed and garbage-collected. It supports multiple programming paradigms including structured, object oriented and functional programming.

IDLE

IDLE is short for Integrated Development Environment for Python. It is the editor and interpreter used for building and executing Python programs.

Python uses whitespace indentation , rather than curly brackets or keywords, to delimit blocks. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block. This feature is sometimes termed the off-side rule, which some other languages share, but in most languages indentation doesn't have any semantic meaning.

Classes and Objects

A class is a user-defined blueprint or prototype from which objects are created. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) for modifying its state.

Some important attributes :

  1. Classes are created by a keyword named class.
  2. Attributes are the variables that belong to class.

An object is nothing but an instance of a class. It is a real entity.

Functions

In Python, a function is a group of related statements that performs a specific task.Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable.Furthermore, it avoids repetition and makes the code reusable.

  1. Keyword def that marks the start of the function header.
  2. A function name to uniquely identify the function. Function naming follows the same rules of writing identifiers in Python.
  3. Parameters (arguments) through which we pass values to a function. They are optional.
  4. A colon (:) to mark the end of the function header.

Constructors

Constructors are generally used for instantiating an object.The task of constructors is to initialize(assign values) to the data members of the class when an object of class is created.In Python the __init__() method is called the constructor and is always called when an object is created.

Syntax :

def __init__(self):
    # body of the constructor

Methods

  1. Method is called by its name, but it is associated to an object (dependent).
  2. A method is implicitly passed the object on which it is invoked.
  3. It may or may not return any data.
  4. A method can operate on the data (instance variables) that is contained by the corresponding class.

Syntax :

class class name

def method name () :

#method body

Class variables and Instance variables

Class Variables — Declared inside the class definition (but outside any of the instance methods). They are not tied to any particular object of the class, hence shared across all the objects of the class. Modifying a class variable affects all objects instance at the same time.

Instance Variable — Declared inside the constructor method of class (the __init__ method). They are tied to the particular object instance of the class, hence the contents of an instance variable are completely independent from one object instance to the other.

Example :

class Car :

wheels =4 #class variable

def __init__(self, name) :

self.name = name #instance variable

Libraries

Python's large standard library, commonly cited as one of its greatest strengths, provides tools suited to many tasks. For Internet-facing applications, many standard formats and protocols such as MIME and HTTP are supported. It includes modules for creating graphical user interfaces, connecting to relational databases, generating pseudorandom numbers, arithmetic with arbitrary-precision decimals,manipulating regular expressions, and unit testing.


Related Solutions

For Python, explain as much as you can please 1) What are namespaces and how are...
For Python, explain as much as you can please 1) What are namespaces and how are they used in Python? 2) What is the difference between Inheritance and Composition?
<Python coding question string practice> Can anyone please answer these python string questions?? 1. Write a...
<Python coding question string practice> Can anyone please answer these python string questions?? 1. Write a function called username that takes as parameters a person's first and last names and prints out his or her username formatted as the last name followed by an underscore and the first initial. For example, username("Martin", "freeman") should print the string "freeman_m". 2. Write a function called letters that takes as a parameter a string and prints out the characters of the string, one...
Please post two email usage guidelines that you feel are most important to follow and tell...
Please post two email usage guidelines that you feel are most important to follow and tell us why you feel those guidelines are important (guidelines may be found online or from your experience). 1. Be concise and to the point. Do not make an e-mail longer than it needs to be. Remember that reading an e-mail is harder than reading printed communications and a long e-mail can be very discouraging to read. 2. Answer all questions, and pre-empt further questions....
Can you please explain in detail what each line of code stands for in the Main...
Can you please explain in detail what each line of code stands for in the Main method import java.util.Scanner; public class CashRegister { private static Scanner scanner = new Scanner(System.in); private static int dollarBills[] = {1, 2, 5, 10, 20, 50, 100}; private static int cents[] = {25, 10, 5, 1}; public static void main(String[] args) { double totalAmount = 0; int count = 0; for (int i = 0; i < dollarBills.length; i++) { count = getBillCount("How many $"...
Python has an established coding style, but the style is a suggestion, and although you can...
Python has an established coding style, but the style is a suggestion, and although you can style your code using different style choices, you are strongly encouraged to be consistent. true or false
What does 'Assurance Bucket' analogy mean? can you explain it please... Thank You
What does 'Assurance Bucket' analogy mean? can you explain it please... Thank You
a)Please explain what are macroeconomic indicators. b)List three of the most important macroeconomic indicators to you...
a)Please explain what are macroeconomic indicators. b)List three of the most important macroeconomic indicators to you personally; justify your choices c)List three of the most relevant macroeconomics indicators to your current profession which is reconciling sales; justify your choices
Please explain all answers in depth What skills do you consider most important when it comes...
Please explain all answers in depth What skills do you consider most important when it comes to teams and teamwork? Which of these skills do you feel you possess and which ones do you need to further develop? What are some effective strategies for enhancing successful team performance? How can these strategies help to decrease threats to team performance and motivation?
This is for python coding First of all, you need to know what Natural Numbers are....
This is for python coding First of all, you need to know what Natural Numbers are. They are the positive integers (whole numbers) 1, 2, 3, etc., and zero as well. For this project, there are TWO PORTIONS: PORTION 1: Write a program to find the SUM of the first n natural numbers the user wants to add. The program should first prompt the user for how many natural numbers are to be summed. The use for loop to do...
Python 3 can you explain what every single line of code does in simple terms please...
Python 3 can you explain what every single line of code does in simple terms please so basically # every single line with an explanation thanks def longest(string): start = 0;end = 1;i = 0; while i<len(string): j = i+1 while j<len(string) and string[j]>string[j-1]: j+=1 if end-start<j-i: end = j start = i i = j; avg = 0 for i in string[start:end]: avg+=int(i) print('The longest string in ascending order is',string[start:end]) print('The average is',avg/(end-start)) s = input('Enter a string ')...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT