Posts

Showing posts from January, 2021

BASIC DATA TYPES IN PYTHON

Image
  NUMERIC Numeric data can be broadly divide into integers and real numbers (i.e. fractional numbers). Integers can themselves be positive and negative. Unlike many other programming languages, Python does not have any upper bound on the size of integers. The real numbers or fractional numbers are called floating point numbers in programming languages. Such floating point numbers contain a decimal and a fractional part. Let us look at an example that has an integer as well as a real number: STRING A String in Python can be a series or a sequence of alphabets, numerals and special characters. Similar to C, the first character of a string has an index 0. Single quotes or double quotes are used to represent strings.   There are many operations that can be performed on a string. There are several operators such as slice operator ([] and [:]), concatenation operator (+), repetition operator (*), etc. Slicing is used to take out a subset of the string, concatenation is us...

DATA TYPES IN PYTHON

  STANDARD DATATYPES Data types are the classification of categorization of data items which represents the kind of value that tells what operations can be performed on a particular data. The data stored in memory can be of many types. For example, a person’s name is stored as an alphabetic value and his address is stores as an alphanumeric value. Sometimes we also need to store answer in terms of only ‘yes’ or ‘no’ , i.e. true or false( This type of data is known as Boolean data ). Python has six basic data types, which is as follows: 1. Numeric 2. String 3. List 4. Tuple 5. Dictionary 6. Boolean

VARIABLES IN PYTHON

Image
  VARIABLES DECLARING A VARIABLE A variable holds a value that may change. The process of writing the variable name is called Declaring the variable . In Python, variables do not need to be declared explicitly in order to reserve memory spaces as in other programming languages like C, java etc. When we initialize the variable in Python, Python interpreter automatically does the declaration process.   INITIALIZING A VARIABLE The general format of assignment statement is as follows: The equal sign (= ) is known as Assignment operator. An expression is any value, text or arithmetic expression, whereas variable is the name of the variable. The value of the expression will be stored in the variable. Examples of variable initialization : The above statements reserve two memory spaces with variable names year and name. 2020 and John are stored respectively in these memory spaces as shown below: Whenever we want to display the value of the variable, simply type these varia...

COMMENTS, IDENTIFIERS AND KEYWORDS IN PYTHON

Image
  COMMENTS Python allows you to add comments in the code as other programming languages do. Comments are used by the programmer to explain the piece of code to others as well as to himself in a simple language. Every programming language uses special character for commenting, so does Python.   Python uses hash character (# ) for comments. Putting # before a text ensures that the text will not be parsed by the interpreter. Comments do not affect the programming part and the Python interpreter does not display any error message for comments. Comments show up as it is in the programming. It is a good practice to use comments for program documentation in your program so that it becomes easier for other programmers to maintain or enhance the program when required. PYTHON IDENTIFIERS A Python identifier is the name given to a variable, function, class, module or other object. An identifier can begin with an alphabet (A –Z or a -z ), or an underscore (_) and can include any nu...