Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Essential Python Terminologies and Concepts

LS100 — Module 00B · Python Fundamentals

Harvard University

Souvik Mandal, Ph.D., Linkedin ID: souvik-mandal-phd

Project Leader & Instructor, Computational Behavioral Sciences, LS100, FAS, Harvard University

Below is a list of key Python terminologies every beginner should understand, along with brief explanations:

Python is dynamically typed, meaning you don’t need to specify the type of a variable and a variable’s type can change when you assign a new value. You can always check the type of a value by using the type() function (e.g. type(42) returns <class 'int'>).

Using operators, you can form expressions like a * b + 5 or if (x > 0 and x < 10): .... The operators follow standard precedence (e.g. multiplication comes before addition, unless parentheses are used to group).

Both loop types use indentation to define the loop body. You can use the keyword break to exit a loop early, or continue to skip to the next iteration. In general, for loops are common when iterating over known collections or ranges, and while loops are useful when the repetition should continue until a condition changes (which might depend on user input or some calculation). Loops are essential for tasks like iterating through data, repeating an operation multiple times, or searching through collections[1].

Additionally, methods (see below) are sometimes called “behavioral attributes” or “procedural attributes” of a class. Data attributes define what an object needs to have (state), while methods define how to interact with the object (behavior)[3]. For example, if you have an object person of class Person with attributes name and age, those are data attributes. If Person has a method speak(), that method is also considered an attribute of the class (a function attribute). In Python, you access attributes with the dot notation: e.g. person.name or my_car.color. Trying to access an attribute that doesn’t exist will result in an AttributeError. Understanding attributes is important when dealing with objects and classes, as it helps organize data and functionality together.

In Python, a set is an unordered collection of distinct (unique) immutable objects[3]. For example, {1,2,3,3} will end up as {1,2,3} because duplicates are removed[3]. Sets themselves are mutable (you can add or remove elements), but because they are unordered, you cannot access elements by index. There is also a special type called a frozenset which is an immutable set. Beginners commonly use sets when they need to gather unique items or perform mathematical set operations.

Strings are fundamental for input/output, representing messages, file paths, data read from files, etc. Even though they are immutable, operations are designed to be efficient and convenient.

References

[1] LearnPython.com. “Python Terminology for Beginners.” https://learnpython.com/blog/python-terms-for-beginners/

[2] W3Schools. “Python Glossary.” https://www.w3schools.com/python/python_ref_glossary.asp

[3] LearnPython.com. “Python Terminology for Beginners, Part 2.” https://learnpython.com/blog/python-terms-for-beginners-2/

[4] Python Packaging Authority. “pip · PyPI.” https://pypi.org/project/pip/