Posts

Showing posts from April, 2020

escape sequence in python

ESCAPE SEQUENCES IN PYTHON An escape sequence is a combination of characters that has a meaning other than the literal characters contained in it. When a character is preceded by a backslash (\), it is called an escape sequence and it has a special meaning to the compiler. Here is the table for Python escape sequences:- S.No. ESCAPE SEQUENCE DESCRIPTION 1. \\ Prints backslash 2. \’ Prints  single quote 3. \” Prints double quote 4. \a Makes beep sound 5. \b Backspace-removes previous character 6. \f Formfeed 7. \n Newline 8. \r Carriage return 9. \t Horizontal tab 10. \v Vertical tab 11. \uxxxx Returns character with hexadec...

Data Types in Python

Data Types in Python Variables can hold data of different types. Data types determine the type and size of data associated with variables. Following are the standard or built-in data type of Python: 1. String 2. Numeric :-integers, floating point, complex numbers 3. Boolean 4. Collections:-List, Tuple, Dictionary String type The text enclosed in quotes forms a String in Python. Strings are sequences of character data. String literals may be delimited using either single or double quotes. For example, str=”abc” creates a string other examples are str=’abc12’ str=”hello world” str=”” //empty string str=”12” str=”@hello” But str=’Hello” is an invalid string as opening and closing quotes are different. Numeric data type Number data types are used to store numeric values. There are three distinct numeric types:  Integers  floating point numbers  complex numbers Integers Integers are whole numbers without any fractional par...

variables in python

Image
Variables Variables are names used to hold one or more values.. A variable is a way of referring to a storage area in a computer program.Values stored in a variable can be changed. Variables are just like named labels. For example, you can store name of a student in a variable “stud_name” or simply “name”. When you create a variable you reserve some space in memory. Unlike other programming languages you don't need to specify the type of variable and there is no command to declare a variable. The declaration happens automatically when you assign a value to a variable. For example,  roll_no=121  Creates a variable namely “roll_no” of numeric type. Other examples: name=’Ankita’                 #variable of type string percentage=76.9             #variable of type floating point Naming of variables should follow the rules of identifier naming rules. Dynamic Typing The ...

Keywords and Identifiers in Python

Image
Keywords and Identifiers Keywords Keywords are the reserved words in Python. They convey a special meaning to the compiler. Keywords are reserved for special purpose so We cannot use a keyword as a variable name ,  function name or any other identifier. Identifiers Identifiers are the names used to identify things in your code. An identifier is a user-defined name to represent a variable, a function, a class, a module, or any other object. Any word that has not been commented out, delimited by quotation marks, or escaped in some other way is treated as an identifier by Python . Rules for writing identifiers 1. A Python identifier can be a combination of uppercase/lowercase letters, digits, or an underscore. The following characters are valid: Lowercase letters (a to z) Uppercase letters (A to Z) Digits (0 to 9) Underscore (_) For example, Name1,first_name,LASTNAME,_NAME Are valid identifiers. But following are not valid i...

working with python IDLE

Image
Working with Python IDLE Before you start working in Python, you need to install python on your computers. Multiple distributions of Python are available today. Anaconda Python Distribution is one such highly recommended distribution. Many popular IDEs are also available like Spyder IDE, PyCharm IDE etc. There is a default installation available from www.python.org which is CPython installation. CPython is the original Python implementation. It comes with Python IDLE and Pip. When you download Python in our computer, then you may notice a new program on your machine called IDLE. IDLE is Python’s Integrated Development and Learning Environment. Python IDLE makes it the perfect tool for a beginning programmer. You can work in python in two ways: Interactive Mode(Immediate Mode) Script mode Working in interactive Mode In interactive mode there is a shell between the user and the operating system which reads a Python statement, evaluates the result of that stateme...

introduction to python

Introduction to Python Python is a general purpose, dynamic and high level programming language developed by Guido van Rossum in the late 1980s. It is simple and easy to learn and provides lots of high-level data structures. Python is a powerful and versatile scripting language. At the same time it is simple and easy to learn. It supports Object Oriented programming approach to develop applications. It is an interpreted language, which can save you considerable time during program development because no compilation and linking is necessary. It comes with a large collection of standard modules that you can use as the basis of your programs — or as examples to start learning to program in Python. Some of these modules provide things like file I/O, system calls, sockets, and even interfaces to graphical user interface toolkits like Tk. Advantages of using Python  Easy to use Python is relatively easy to learn language as it uses simpler syntax and shorter codes. Readi...