Introduction to Python
Python is a widely used general-purpose, high level programming language. It was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with an emphasis on code readability, and its syntax allows programmers to express their concepts in fewer lines of code.
Application Area of Python
· Build a Website
· Develop a Game
· Program a Robot
· Develop Artificial Intelligence
· Perform a Scientific computations
Installation of Python.
Follow the given steps to install python on your computer:
OBTAIN A PYTHON DISTIBUTION
Visit the website www.python.org/download in this chapter we are using python 3.7.0
Python installation Process
After downloading the python
distribution , double click on the download software and installation process
begans .click on the run and installation will be continued and next and after
it load the software in your PC finish button will be highlighted.
Compnents of the Python window.
Python has following components.
Title Bar
This area displays the name of the application and the file,It also contains command like minimise, maximize restore and close.
Menu bar
In menu bar all menus are there many options by you can work easily with window of the python.
Script Area
It is used to type your program in script area
Status Bar
Status bar tell us the current status of the contols /cursor on the window.
Tokens
TOKENS : Python breaks each logical line into a sequence of elementary lexical components known as tokens.
Keywords, Identifiers, Literals, Operators, Punctuators
Keywords : are the reserved words in Python. We cannot use a keyword as a variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language. In Python, keywords are case sensitive.
Identifiers
Python identifier: is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).
Name of Some Identifiers
Else ,Income Tax, 2M Value , Discount_amount,Birth.Date:
Literals : A literal is something that the parser recognizes as syntax for writing an object directly.
There are four types four types Literals
Boolean Literals : The two Boolean values are True and False (the capitalization must be exactly as shown), and the Python type is bool. In the first statement, the two operandsevaluate to equal values, so the expression evaluates to True; in the second statement, 5 is not equal to 6, so we get False.
String Literals: A string literal is where you specify the contents of a string in a program. Here 'A string' is a string literal. The variable a is a string variable, or, better put in Python, a variable that points to a string. String literals can use single or double quote delimiters.
Special Literals : The NONE operator is the special Literal in the python it has same significance as it has in the other languages.
Numeric Literals: In python numeric literals are of three type : Integer,Float,complex.
Pythons Mode
Interactive mode: Is a command line shell which gives immediate feedback for each statement, while running previously fed statements in active memory.
Use of Print : It is used to print the output of the program as we are using in the other languages.
>>>print(“Hello World”)
Hello World
Python is case sensitive language so it differentiate between uppercase and lowercase.
Variables in python:A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing. Every value in Python has a datatype. Different data types in Python are Numbers, List, Tuple, Strings, Dictionary, etc.
Rules to Write Variables : Rules for Python variables: A variable name must start with a letter or the underscore character. A variable name cannot start with a number. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)
Script Mode.
If you need to write a long piece of Python code or your Python script spans multiple files, interactive mode is not recommended. Script mode is the way to go in such cases. In script mode, You write your code in a text file then save it with a .py extension which stands for "Python". It is used to write short programs
Answer the following Questions:
- Write about python language?
- What are four application area of python?
- Components of python window.
- Write in brief about the two modes of the Python window?
- What are variables of Python?