Category Archives: Python Tutorial

Python error handling

Python exception: try except with 3 examples to handle errors

An exception is an error or event that occurs during a program execution. Depending on error type, exception may crash a program or result in some unexpected behaviour. In order to avoid crashing or end program in unwanted way error must be handled immediately.

Python set example

What is Python Set: 3 Examples of How to Use

In Python Set is almost similar to dictionary. A set is dictionary with no values. As described in dictionary chapter, dictionary data type work with key – value pairs as shown below:

Python data types – Int, Float, string, dict, lists with examples

Python variables and data-types Variables are way to store values that are changeable. Variable has data types that defines what kind of data to store in that variable. For example numbers, strings etc.   Python has following standard data types: Numbers (int, float etc.) String Dictionary Tuple List Python Numeric data types Python has three

Python open method

Understand using Python Open, Read, Write methods with 2 Demos

The open method of Python Python comes up with a built-in function open() that enables programmers to perform open, read, write and other operations with files. >>An example of Open and read file In order to perform the read or write actions in the files, first, it has to be opened. Once a file is opened by

Python class

Understand Python Class, Objects and Inheritance: 3 Examples

Grouping similar types of tasks into classes is termed as object oriented programming. Where Class is a combination of variables/properties and functions/methods. This chapter does not aim at explaining object oriented programming concepts thoroughly. The aim of this chapter is how to create and use Python classes.

How to define and call Python function with return examples

A python function is a block of code that may take one or more input parameters, executes and may return a value. Functions can be used in Python programs repeatedly. A function’s code will only be executed once this is called.

Python range function

Ways to use Python range with 4 examples

Python has a function called range() that is used to create list of integers. For example range(5) is the length of 5 numbers. By default Python range starts from 0.

Python tuple tutorial

Python Tuple: Easily Understand tuples with 5 examples

Among other compound data types available in Pytho,n tuple is one of those. The Tuple is sequence just like list but this type is immutable. That means its values cannot be changed. Once created, rest of the program it will stay same. Besides list use square brackets while tuples use parentheses ().

Python date

13 Examples to Learn Python datetime module in 30 Minutes

Python comes up with a few date and time modules. One of those is python datetime. In order to format date and time you have to import datetime module into your Python programs. This chapter explains how to format date and time with datetime python module, let us first show you how to import datetime in Python program.

Python input method

Python Input VS Raw_input – Learn to Take User input with 2 Demos

Taking user input from keyboard is sometimes required in programming languages. For example developing a calculator, a menu system etc. that asks users to input some value. Python comes up with input() method that allows programmers to take user input.