1.Introduction To Python:
1.1 What is Python:
Python is a popular high level programming language. It was created in 1991 by Guidovan Rossum.
It is used for:
- web development (server-side),
- software development,
- mathematics,
- system scripting.
1.2 Application of the python:
- Python can be used on a server to create web applications.
- Python can be used alongside software to create workflows.
- Python can connect to database systems. It can also read and modify files.
- Python can be used to handle big data and perform complex mathematics.
- Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
- Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
- Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
- Python can be treated in a procedural way, an object-orientated way or a functional way.
2. Variables in Python:
2.1 Defining a variable:
One of the most powerful features of the programming language is ability to manipulate variable. A variable is a name that refer to a value. Python is dynamically typed, which means that you don't have to declare what type each variable is. An assignment statement create new and gives them values
Examples:
message = ’python example program’
n = 17
pi = 3.1415798794
This example makes three assignments. The first assigns a string to new variable named message , the second assigns the integer 17 to n, the third assigns the (approximate) value of pi to variable pi.
2.2 Rules for defining variable:
- 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 alphanumeric characters and underscores (A-z, 0-9, and _ )
- Variable names are case-sensitive (age, Age and AGE are three different variable)
2.3 Displaying the variable
To display the value of the variable we use the print statement
Example
>>Print(n)
17
>>print(pi)
3.1415798794
- Type of the variable is the type of the value it refers to.
3. Statements:
A statement is a unit of code that the python interpreter can execute. We have seen two kinds of statement they are
- Print being an expression statement
- Assignment statement
When you type a statement in interactive mode ,the interpreter execute it and display the result, if there is one. A script usually contains sequence of statement, if there is more than one statement, the result appear one at the a time as the statement execute.
Example:
>>Print(1)
>>x=2
>>print(x)
Output:
1
2
Conclusion: The assignment operator produce no output.