Python: package

Python package is a collection of modules in a directory. To tell Python, that this directory should be considered a package, we have to add a file named __init__.py Python package is a directory that contains a __init__.py file and a set of modules. The name of the directory is considered as the name of … Read more

Python: Function

Functions enable us to isolate and encapsulate a certain piece of code into its own block. And then it can be used in different places of the program without repeating the same code over and over again. NOTES In Python, functions are first-class objects(entities), so a function can be- Let’s see how we can define … Read more

Python: if…else [Control Flow]

In the code, we sometimes want certain pieces to be executed, and we ignore certain parts of the code. Keywords like “if“, “else“, and “elif” help us with that. if Condition Using the “if” condition we ask the interpreter to execute the code under the “if” block, only if the provided condition. Check the general … Read more

Python: Dictionary [Data Type]

Dictionary in Python is a collection of key/value pairs. Dictionaries use keys(labels) to store item/value references, instead of numbered index. Python Dictionary is a unordered and mutable collection of Zero(0) or more key/value pairs. Only hashable objects can be used as key in a Dictionary. Dictionary items are not ordered, and are not stored in … Read more

Python: List [Data Type]

List in Python is a data type that stores a collection of data, of one or more types. Python list is mutable. Lists are ordered collections of items. Items in the list store the order of each item.

Python: Integer [Data Type]

Integer in Python represents whole numbers, without any fractional part. An integer can be positive, negative, or zero. NOTES Max size of an integer in Python depends on the memory of the machine. Integers can be very large in Python, though working with a very large integer will be very slow. If the integer in … Read more

Python: String [Data Type]

What is a String? String in Python is- Examples of String Create String Use “str” function to create a new string. If no value is provided to “str” function then an empty string is created- Output: We can wrap a sequence of characters with single or double quotes to define a string literal. Output: Multi-line … Read more

Python: Data Types

General Data Types Data Type Python Type Immutable & Hashable Boolean bool Yes Integer int Yes Floating point number float Yes String str Yes Bytes bytes Yes Collection Data Types Data Type Python Type Immutable & Hashable Tuple tuple Yes Set set No Frozen Set frozenset Yes List list No Dictionary dictionary No