Friday 4 August 2017

PYTHON


Python was started in December 1989 by Guido Van Rossum in Netherland.
Downloading python:
Open  google and download python.org
Click on download python.
We can see add and start download click on it. 
After downloading we can see in our downloads folder. 
Right click and open and click on next to continue. 
Click on accept. 
We can see our software is downloading.  
Successfully completed download.
Click on finish. 
Now, after downloading we can click on install now. 
Click on next to continue. 
Select the directory where it should be download and click on next.
Continue to click next. 
We can see python is installing. 
After installing click on finish. 
After that we can see console window.
In start type python we can see IDLE has been downloaded we can write programs in that also.
Left side part is IDLE and right side part is command line.
Hello world program: 
Variables:
Name of memory location where data is stored.
Once a variable is stored space is allocated in memory.
Variable assignment:
We use the assignment operator(=) to assign values to a variable.
Eg:
Assigning values to variable:
Comments:
# -- single line comment.
"" -- Multiline comment.
Loops:
for:
Iterate a variable over a sequence in the order.
Syntax:
for <variable> in <sequence>:
Flow chart:
Eg:
while:
Execute number of statements or body till the condition passed in while is true.
Once the condition is false control come out of the loop.
Syntax:
while <expression>:
body
Flow chart:
Eg:
Control statements:
if:
Used to test a condition. condition is true statement of if block is executed otherwise it its skipped.
Syntax:
if(condition):
statements
Flow chart:
Eg:
if else:
Execute body of if only when condition is true.
Body is false else is executed.
Syntax:
if test expression:
Body of if
else:
Body of else
Eg:
Flow chart:
if else if:
elif is an abbreviation of else if.
Eg:
break:
Break statement is a jump statement that is used to pass the control to end of the loop.
Syntax:
break
Flowchart:

Eg:
Continue:
Returns the control to the beginning of the loop.
Rejects all remaining loops and control goes back to top of the loop.
Syntax:
continue
Flow chart:

Eg:
Strings:
Simplest and easy to use in python.
Accessing strings:
Both forward and backward indexing are provided using strings in python.
Forward indexing starts with 0, 1, 2, 3.
Backward indexing starts with -1, -2, -3, -4.
Eg:
str[0]='P'=str[-6] 
str[1]='Y'=str[-5]
str[2]='T'=str[-4] 
str[3]='H'=str[-3] 
str[4]='O'=str[-2] 
str[5]='N'=str[-1]
Programs:
Add two strings:


Partial string:


Find starting point of a string:
Count the number of occurances of a substring in a string:


Ask user input name and age and write a sentence:
Reading and writing to a file:
Reading from a file:
Create some data and save it in a .txt file and copy it where we installed python.

After that write a program and we can see the data which we enter in .txt file can be seen as output in our program because we are reading the data from a file.
Writing to a file:



Replacing Ravi with Chandu:
Graphic output syntax:
Line:
Circle:
Rectangle:


Star:
Program for finding first non repeated character in a given string:
Program for finding permutation of a string:
Program for finding digit identification if string have any numbers:
Program for finding replacing the first highest repeated character with user given character:
Program to print the following pattern:
Program to sum a number in given string:
Database:









Downloading connector for python.