Learnitweb

Category: Python tutorial

  • Addition(+) and multiplication(*) operators with string in Python

    Python allows for the use of the addition (+) operator and multiplication (*) operator on strings. In this tutorial, we’ll see how to use these operators with string in Python. Addition(+) operator with string Adding two strings is known as concatenation. Concatenation of two strings creates a string by adding the second string to the…

  • Slicing String in Python

    Slicing is used to obtain a sub-string from a given string by slicing it from a given start and end. Here start and end mean the index within a given string. There is another optional parameter step which indicates the increment between each index for slicing. There are two ways to slice a Python string:…

  • Strings in Python

    Textual data in Python in represented by string objects. Strings are immutable sequences of unicode code points. Strings in Python can be written in three ways: 1. Single quotes Single quoted strings allows embedded double quotes. Single quoted strings do not span multiple lines. 2. Double quotes Double quoted strings allow embedded single quotes. Double…

  • Boolean type in Python

    Boolean values in Python are represented as two constants True and False. True and False constants are simply set to integer values of 1 and 0, i.e True is represented as 1 and False is represented as 0. In simple way, True and False are alternative ways to spell integer values 1 and 0. Note:…

  • Complex number in Python

    Complex numbers are used in scientific calculations. Complex number in Python is represented in the form of a + bj. Here, a and b are real numbers and j represents the imaginary unit, satisfying the equation j2 = -1. Because no real number satisfies this equation, j is called an imaginary number. For the complex…

  • Base conversion functions in Python

    Python provides base conversion functions to convert an integer number to another base. Whenever you print a binary, octal or a hexadecimal integer number, it is printed by default in decimal form. But sometimes there is a need to change base of an integer, for example, decimal form to binary form. Please note that all…

  • float values in Python

    float (floating point real values) or simply called floats, represent real numbers and are written with a decimal. The left of the decimal represents integer value and the right represents the fractional part. Floats may also be represented in scientific notation or exponential notation, with e or E indicating the power of 10, for example,…

  • Integral values in Python – an introduction

    Integer is a number with no fractional part(no decimals). For example, 1, 100, 0, -999 are integers while 1.99 and 1/3 are not integers. We can represent integral values in four ways: Decimal (also base 10) This is the standard system for denoting integer. For example, 1,2,75,999. Binary (also base 2) A binary number uses…

  • Python Data Types

    Before starting the discussion, please note that everything in Python is an object. Following are the types built into Python: None – This type has a single value and there is a single object with this value. This object is accessed through the built-in name None. It is used to signify the absence of a…

  • Python identifiers and keywords

    An identifier is a name given to a variable, function, class or module. Only following are allowed in identifiers: Lowercase (a-z) characters Uppercase (A-Z) characters Digits (0-9) Underscore(_) An identifier can be a combination of lowercase characters, uppercase characters, digits and underscore. An identifier can not start with a digit. 1y is invalid identifier whereas…