Category: python basic

python tutorials and learn python

Created with Sketch.

Python – While Loop

Python – While Loop Loop is a very popular phrase in programming jargon. A program, by default, follows a sequential execution of statements. If the program flow is directed towards any of the earlier statements in the program, it constitutes a loop. However, sending it unconditionally causes an infinite loop, which is not desired. Python…
Read more

Python – Decision Control

Python – Decision Control: if, else, elif By default, statements in the script are executed sequentially from the first to the last. If the processing logic requires so, the sequential flow can be altered in two ways: Conditional execution: a block of one or more statements will be executed if a certain expression is true.…
Read more

Python – Operators

Comparison and Logical Operators in Python The comparison operators returns a boolean either True or False. Assuming that x=10 and y=20, the result of the operations is also given in following table: Operator Description Example > True if the left operand is higher than the right one >>> x>y False < True if the left…
Read more

Python – Dictionary

Python – Dictionary Like the list and the tuple, dictionary is also a collection type. However, it is not an ordered sequence, and it contains key-value pairs. One or more key:value pairs separated by commas are put inside curly brackets to form a dictionary object. Syntax: dict = { key1:value1, key2:value2,…keyN:valueN } The following declares…
Read more

Python – Set

Python – Set A set is a collection of data types in Python, same as the list and tuple. However, it is not an ordered collection of objects. The set is a Python implementation of the set in Mathematics. A set object has suitable methods to perform mathematical set operations like union, intersection, difference, etc.…
Read more

Python – Tuple

Python – Tuple Tuple is a collection of items of any Python data type, same as the list type. Unlike the list, tuple is mutable. The tuple object contains one or more items, of the same or different types, separated by comma and enclosed in parentheses (). Syntax: tuple = (value1, value2, value3,…valueN) The following…
Read more

Python – List

Python – List In Python, the list is a collection of items of different data types. It is an ordered sequence of items. A list object contains one or more items, not necessarily of the same type, which are separated by comma and enclosed in square brackets []. Syntax: list = [value1, value2, value3,…valueN] The…
Read more

Python – String

Python – String A string object is one of the sequence data types in Python. It is an immutable sequence of Unicode characters. Strings are objects of Python’s built-in class ‘str’. String literals are written by enclosing a sequence of characters in single quotes (‘hello’), double quotes (“hello”) or triple quotes (”’hello”’ or “””hello”””). >>>…
Read more

Python – Number Type

Python – Number Type An object of Number data type represents a numeric literal. In computer science, a literal is a notation for representing a fixed value in the source code. For example, in the assignment statement: >>> X=10 Here 10 is a literal, as the numeric value representing 10 is directly stored in memory.…
Read more

Python – Data Types

Python Data Types Data types are the classification or categorization of data items. Data types represent a kind of value which determines what operations can be performed on that data. Numeric, non-numeric and Boolean (true/false) data are the most used data types. However, each programming language has its own classification largely reflecting its programming philosophy.…
Read more