Showing posts with the label Python Tutorial

Python Tutorial | Learn Python Programming Language

Python Basics   1.  Python - Introduction  2.  Python - Local Environment Setup  3.  Python - Writing Programs  4.  Python - Variables  5.  Python - Data Types  6.  Python - Type Conversion and Casting  7.  Python - Operators  8.  Python - Conditional if  9.  Python - Cycles 10.  Python - Functions and Function parameters 11.  Python - Lambda 12.  Python - Console Input and Output 13.  Python - Literals 14.  Python - Return Statement 15.  Python - Function as Type, Parameter and Result of Another Function Python Object-oriented programming   1.  Python - Classes and Objects  2.  Python - Encapsulation  3.  Python - Inheritance  4.  Python - Polymorphism  5.  Python - Abstract Classes Python Handling Errors and Exceptions 1.  Python - Try, Except, and Finally 2.  Python - Except and Handling Different Types of Exceptions 3.  Python - Throwing and Creating Custom exceptions Python  - Lists, Tuples, Dictionaries, and Sets 1.  Python - Lists 2.  Python - Tuples 3.  Python - Dictionaries 4.

Python Built-In Modules - Examples

Built-in modules are part of the Python programming language and comes with the Python distribution. A built-in module can be used directly in a Python program without any installation or setup. These modules simplify the development process by allowing the developers to use the pre-defined functions and classes for routine work, code reuse, and productivity. Some examples of built-ins are math, random, json, os datetime, and sys. Let’s take a look at a Python code example of some of the built-in module and how you can use it in your Python code. random module The random module is responsible for generating random numbers. The main functions of the random module are: random():  generates a random number in the range of 0.0 and 1.0 randint():  returns a random number within a given range randrange(): returns a random number from the given range of numbers shuffle(): shuffles the list choice(): returns a random list element The random floating point number between 0.0 and 1.0 is the resu

Python - datetime module

The datetime module contains the following classes, which together comprise the majority of the functionality for working with dates and times: date time datetime date class To work with data, we’ll use the Date class defined in the DateTime module. To construct a Date object, let’s use the Date constructor. The Date constructor takes three parameters: Year, Month, and Day. date(year, month, day) For example, let's create a date: import datetime   date = 2024 , 1 , 1 ) print(date)       # 2024-01-01 The today() method is used to retrieve the current date. from datetime import date   today = print(today)       # 2023-12-31 print( "{}.{}.{}" .format(, today.month, today.year)) # 31.12.2023 Using the properties day, month, year you can get the day, month and year respectively time class The time class takes care of dealing with time. With its constructor, a time object can be created: time([hour] [, min] [, sec] [, microsec]) The hour,