This series of Python Tutorials help you get started with the basics of Python programming. Also, we will look into most used Python Libraries with thorough examples.

Python Tutorial

Welcome to Python Tutorial by TutorialKart!

There is nothing you need to know in prior. If you are interested in learning Python programming from scratch, we have a well built and organised set of tutorials to help you master Python.

Get Started

The following tutorials help us to install Python in our computer.

Basics

The following tutorials cover basics of any programming language like variables, datatypes, comments, conditional statements, looping statements, functions, etc.

  • Syntax Introduction to the syntax of Python programming. Indentation, identifiers, etc.
  • Variables Variables are storage locations to store given value. Learn how to define a variable, and how to store a value in the variable.
  • Comments Learn how to write comments in a Python program. Single-line comments, Double-line comments.
  • Numbers Types of numbers in Python: int, float. Learn how to define int or float, and perform different operations on them.
  • Booleans Booleans are used to hold the state of either True or False. Learn how to define a boolean, use them in statements, etc.
  • Strings String is a sequence of characters. Learn how to define a string, multiline string, and different String methods.
  • Keywords Keywords are the reserved words in Python programming. Each of them have a specific meaning and purpose.
  • Constants Constants are used to store read only values (values that cannot be changes). Even though Python does not have builtin type of Constants, this tutorial presents a workaround.
  • Datatype Conversion Convert a value in variable from one datatype to another.
  • Underscores in Numbers Underscores in numbers are used to improve the readability of numbers when the numbers are relatively large.

Operators

  • Arithmetic Operators Python Tutorial about Addition, Subtraction, Multiplication, Division, Modular Division, Floor Division, and Exponentiation Operators.
  • Bitwise Operators Python Tutorial about bitwise AND, bitwise OR, bitwise XOR, bitwise NOT, bitwise Zero fill left shift, bitwise Signed right shift operators.
  • Assignment Operators Python Tutorial about Assignment, Addition Assignment, Subtraction Assignment, Multiplication Assignment, Division Assignment, Modulus Assignment, Exponentiation Assignment, Floor-division Assignment, AND Assignment, OR Assignment, XOR Assignment, Zero fill left shift Assignment, and Signed right shift Assignment Operators.
  • Comparison Operators Python Tutorial about Equal-to, Not-Equal-to, Greater-than, Less-than, Greater-than or Equal-to, Less-than or Equal to Operators.
  • Identity Operators Python Tutorial about IS, and IS NOT identity operators.
  • Logical Operators Python Tutorial about logical AND, logical OR, and logical NOT operators.
  • Membership Operators Python Tutorial about IN and NOT IN membership operators.

Conditional Statements

Conditional Statements are used to execute a block of statements based on the result of a condition.

  • If Statement Learn the syntax and usage of basic conditional if statement in Python.
  • If-Else Statement Learn the syntax and usage of conditional statement with if and else blocks.
  • Elif Statement Learn the syntax and usage of if-elif-else ladder conditional statement.
  • Ternary Operator Ternary Operator is used to select one of the two values based on a condition. Code using Ternary Operator is concise over if-else for this use case.

Looping Statements

Looping statements are used to execute a block of statements repeatedly for N number of times, or for each item/element in a sequence/collection. Looping control statements like break, and continue, control the execution flow of a loop, like breaking the loop, or continuing with the next iteration, respectively.

  • While Loop Execute a block of code as long as the condition is True.
  • Infinite While Loop While Loop with condition always True, so that the While Loop runs indefinitely.
  • Nested While Loop While Loop inside a While Loop.
  • While Loop with Break While Loop with a break statement inside it. break statement can break the while loop even before the condition becomes False.
  • While Loop with Continue While Loop with a continue statement inside it. continue statement can skip the execution of further statements inside while loop for the current iteration.
  • For Loop The syntax of a basic For Loop in Python, and examples.
  • For Loop with Index This tutorial shows how to get the index of the element when looping over an iterator using a For Loop.
  • For Loop with Range This tutorial shows how to use a For Loop with a Range object.
  • For Loop with Increment in Steps Iterate through an iterable in steps by skipping some elements in between, using For Loop.
  • Break Statement It is used to break a loop statement (For Loop / While Loop) prematurely.
  • Continue Statement It is used to skip the execution of further statements in a loop, for the current iteration, and continue with the next iteration.

Collections

Python Sequences are objects whose elements are ordered and could be accessed using index. The following tutorials cover different sequences in Python programming language.

List

  • Lists Python Tutorial with an introduction to lists, syntax to create lists, examples, etc.
  • List Methods Python list class provides many methods that transform or operate on the items of the List. This tutorial provides all the methods of a List class, and examples for each of the methods.
  • List Programs Python programs that cover different use-cases related to lists.

Dictionary

  • Dictionary Python Tutorial with an introduction to dictionaries, syntax to create dictionaries, examples, etc.
  • Dictionary Methods Python Tutorials explained in detail about the methods available in dict class.
  • Dictionary Programs Python programs that cover different use-cases related to dictionaries.

Set

  • Sets Python Tutorial with an introduction to sets, syntax to create sets, examples, etc.
  • Set Methods Python Tutorials explained in detail about the methods available in set class.
  • Set Programs Python programs that cover different use-cases related to sets.

Tuple

  • Tuples Python Tutorial with an introduction to tuples, syntax to create tuples, examples, etc.
  • Tuple Methods Python Tutorials explained in detail about the methods available in tuple class.
  • Tuple Programs Python programs that cover different use-cases related to tuples.

Strings

Strings are sequences of characters. The following tutorials deal with String methods, checks on strings, transformations on strings, String properties, etc.

  • String Methods This Tutorial tabulates all the String methods, with description and links to the individual methods that contain well detailed examples for each of the String methods.
  • Python String Programs Python Tutorials that cover different operations on strings.

Functions

A function is a logical piece where a block of code (set of statements) is given a name. We can execute this function by the name, pass some parameters to this function to transform them, and return a value if required.

Python offers some functions that are built in to Python core, and also offers syntax to write our own functions.

  • Functions Learn how to write a function in Python. Functions can take arguments, can return a value, can be passed as arguments to other functions, etc.
  • Builtin Functions Python provides several builtin function for the most trivial functionalities. This tutorial presents all the builtin functions available in Python, and tutorials for each of them.
  • Lambda Functions Lambda Functions are anonymous functions. This Python Tutorial presents the syntax, and how to use Lambda Functions. *

Basic Conversions

We can convert values from one datatype to another using builtin functions or type conversion.

The following tutorials cover some of the basic type conversions from one datatype to another.

Bytes

  • Length of Bytes Tutorial to get length of bytes present in the given bytes object.

Ranges

Python Ranges are a series of numbers defined by a start (default=0) element, end element, and an optional difference between the adjacent elements.

The following tutorials will get you started with Python Ranges, how to create them, how to traverse them, etc.,

Set

Set is an unordered collection of items.

The following tutorials cover how to create a Set, how to iterate over the elements, find an element in a Set, etc.

File Operations

The following tutorials cover basic CRUD file operations: Create, Read, Update and Delete.

  • Create new Text File
  • Read File as String in Python Python Tutorial to read the file content at given location, to a String.
  • Write String to Text File in Python Python Tutorial to write given string to a text file at given location.
  • Delete File in Python Python Tutorial to delete a file at specific path.
  • Check if File Exists Python Tutorial to check if file defined by given path is present or not using os.path.isfile() function.
  • Check if Directory Exists
  • Get the list of all files in a directory
  • Loop through files in directory
  • Overwrite Existing Text File
  • Loop through lines in Text File

Input / Output Operations

We can read input from user via standard input console, and write output to standard output console.

Other Concepts

  • Multithreading Python Tutorial to introduce you to Multithreading concept in Python.
  • XML Parsing Python Tutorial to introduce you to parsing of XML files.

JSON

JSON is the most used data format used to transfer information between applications.

  • JSON Tutorial Introduction to working with JSON files or JSON strings in Python.

DateTime

The following tutorials cover DateTime library methods to work with date and time in Python programming.

Pandas

In Python, pandas is a library used for data manipulation and analysis. Pandas library offers data structures and operations for manipulating numerical tables and time series.

  • Pandas Tutorial Pandas is an open source data analysis tool. This tutorial is an introduction to Pandas library.

MongoDB

MongoDB is a database in which documents are stored in JSON form.

The following tutorials will get you started with working on MongoDB from Python programs.

PySpark

  • Spark Application in Python Python Tutorial to prepare input, create an Apache Spark Application, submit this application to Spark, and observe the output.
  • Python Spark Shell Learn how to start Spark interactive Python Shell, Word-Count example with PySpark, etc.

OpenCV

The following tutorials cover OpenCV Python API for Image Processing.

Python Testing

  • Python unittest Tutorial unittest is used to write unit test cases for testing. This tutorial gives an introduction to unittest library.

Python Programs

The following are the commonly used use cases for learning and to master Python programming.

Interview Questions

The following are the most usually asked Interview Questions with well explained answers and programs.

  • Python Interview Questions A list of commonly asked questions, and their answers, in an interview requiring Python programming skillset.

Conclusion

In this Python Tutorial, we have learned the basics of Python programming, some of the most used builtin functions, python modules, how to work with file system, string operations, and many advanced concepts.