Friday, March 2, 2012

Python Program To Read Value String From Keyboard And Save To A Variable

Python Program To Read Value String From Keyboard And Save To A Variable

see also -
python compiler download
how to compile a python code
Here i am going to explain how you can read strings and data like integer float long double long and other data types from keyboard and save it to a variable in python.The python code is simpler than java.Java program need more steps to read a value or string from keyboard.
You can run this code by saving the program to c:\python27\program.py and open the command prompt and type the above code ( in screen shot ).
Code to read a string from keyboard in python :


name = raw_input("Enter your name:") 
print "Hello", name 
raw_input("Press a to exit.") 

Here name is the variable and Enter your name: is the message will be printed


Tags : how to read data from keyboard in python.how to input data from keyboard to a python program,how to read a string from keyboard ,input a line from keyboard to python program,keyboard input handling in python,source code to read input from keyboard 

How To Compile A Python Program In Windows

How To Compile A Python Program In Windows
I am going to explain how you can easily compile a python program in windows .You can compile python program in windows in two ways:
How to compile or run your python program Step by steps
First download and install   python 2.7.2  or any other versions suable for you compiler in your windows computer
Way 1
Goto My computer c:\python27\ and open python.exe and type your code and press enter
Way2
Open any text editor like notepad and type your program after typing the code save the program into the directory (folder) c:\python27\  filename such as programname.py
Then open command prompt type the following code
cd c:\python27\
python.exe programname.py
here cd is change directory or set your path
python.exe is the compiler and programname.py is python code with extension .py


Tags : how to compile python file ,how to compile .py file,how to compile python source code in windows,execute or run a python program in windows,run python project in windows xp,windows 7,windows 8

Python Compiler For Windows Free Download And Installation

Python Compiler For Windows  Free Download And Installation 

Python is a high level programming language which supports multiple programming paradigms.A python program can be easily understandable compared to c ,c++ and other languages.Normally the program file extension is .py .The python programs can be converted into executable files.The latest version of python ( python 2.7.2 can be downloaded from following link.
Windows Installer Direct Download 
Official website of python - http://www.python.org/
Download python compiler for windows computers - http://www.python.org/download/

The python compiler can be installed as normal setup files.The above version supports the operating systems Windows xp,Windows vista,Windows 7,Windows 8 and other versions of windows.

Tags : python compiler for windows xp,windows vista,windows 7 ,windows 8,python compiler free download,python latest version for free,python 2.7.2 free download

Sunday, February 19, 2012

Java Script To Start A File Download Automatically After 30 Seconds Or Page Load

You can initialize automatic downloads after some waiting time. Optionally you may add a count down screen to start download here i am explaining two ways to start download after 30 seconds.You can also add "click here if the download doesn't start automatically" using ordinary links.
In firefox and google chrome it is easy to do this auto download


Code 1 - You may assign waiting time by replacing 30 with  your assigned time in seconds

<html> 
<title> Title of your download page </title>
<meta http-equiv=REFRESH CONTENT="30; url=http://full path of your file"> 
<body> 
 If the download doesn't start automatically<a href="http://full path">click here</a>. 
</body>
</html>


Some browsers are not supporting the above codes so you may use my second code to start download automatically

Code 2 Waiting time is in micro second 100 micro second = 1 second


<script type="text/javascript">
var t=setTimeout("download()",30000)
function download()
{
window.location = 'full path of your file';
}


</script>


Tags : java script to start download automatically after specified time,php code to start download automatically after page load,waiting download in php,ajax download with waiting,java script ,ajax script code to auto download,internet explorer google chrome firefox browsers

Wednesday, February 8, 2012

C Program For Binary Search With Flowchart

Aim 
To write a c program to perform binary search

Program
#include<stdio.h>
main()
{system("clear");
int n,a[100],i,j,temp,s,low,high,mid,flag=0;
printf("Enter The limit");
scanf("%d",&n);
printf("Enter The number\n");
for(i=0;i<n;i++)
{scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("The sorted list of numers\n\n");
for(i=0;i<n;i++)
printf("%d\n",a[i]);
printf("\nEnter The number to be searched");
scanf("%d",&s);
low=0;
high=n-1;
while(low<=high)
{mid=(low+high)/2;
if(s==a[mid])
{
printf("The numberis found at The position%d\n\n",mid+1);
flag++;
break;
}
else if(s>a[mid])
low=mid+1;
else
high=mid-1;
}
if(flag==0)
printf("The number is not found \n\n");
}

Flowchart




Tags : flow chart and algorithm for binary search in c,c program for binary search,binary search flow chart and algorithm free,program in c for binary search

Thursday, December 1, 2011

How To Connect To A Database In PHP

Creating a Connection between PHP and Mysql

To update,create,change,insert .. a database you need to create a connection between mysql and php.
To connect with a database we can use the function mysql_connect()
Function mysql_connect() need 3 main parameters they are server name user name and password.
Code to Connect with a database
<?php
$server="localhost";  // SERVER NAME Default is localhost
$user  = "root";     // USER NAME Default is root
$pass  = "";        // PASSWORD  Default is nothing
$connection = mysql_connect($server,$user,$pass);
if (!$connection)
  {
  echo "An error occurred";
  }
mysql_query("") // INSERT YOUR SQL QUERY  BETWEEN ""
mysql_close($connection);
?>

Conditions In PHP

Conditions in php
If  Else
If else statements are used to check a condition is true or false and execute a group of statements if true other wiseexecute some other statements.The if statement also sub divided to Else if .... else.It is used to check more than one conditions in the same  set of codes.
if (codition)
{ set of codes to execute when condition is true}
else
{set of codes to execute when condition is false }


if (codition_one)
{ set of codes to execute when condition is true}
elseif
{set of codes to execute when condition_one is false and condition_two is true}
else
{set of codes to execute when conditions are false}

Eg:
<?php
$a=1;
if($a==1)
{
echo "number = 1";
}
elseif($a==0)
{ echo "Number is not zero";


}
else
echo "number is not 0 nor 1";
?>

Switch
Simply a Switch statement  is used to execute a group of codes when anyone of condition matches.
switch (some_variable)
case 1:
break;
case 2:
break; 
.
.
.
.
default :

Eg:

<?PHP
$week=2;
switch($week)
{
case 1:
echo "day is Sunday";
break;
case 2 :
echo "day is Monday";
break;
case 3:
echo "day is Tuesday ";
break;
case 4:
echo "day is Wednesday";
break;
case 5:
echo "day is Thursday ";
break;
case 6 :
echo "day is Friday";
break;
case 7:
echo "day is Saturday ";
break;
default :
echo "Invalid choise";
}

 Output is day is Monday