Monday, June 2, 2014

Password Security System in Python


One of the biggest threat in computer system is the issue regarding computer security. Most of us are not aware the computer security is a very important topic to be learned in information technology. We have heard many stories that a certain bank there records is being access by hackers and other computer criminals on the loose. This criminals and hackers can access sensitive information such as credit card numbers and other personal information of the customers and clients of the bank. They can use this information to do transactions online or to sell credit card numbers in the Internet.

There are many security measures that are being developed to protect this sensitive and confidential records. The most common security that we often use is the use of username and password. We use this most of the time to open our email addresses, social media accounts just like Facebook, Twitter, Instagram  and among other social media websites. However the use of username and passwords has many loopholes that we must be aware of we must able to create a password and username that is not easy to understand by other people. As I read books and magazines about computer security scientist and computer experts suggest that the username and password must be a combination of letters,numbers or even special characters in order to have more secure username and password.

In this article I would like to share with your a very simple program that I wrote using Python as my programming language I called this program Password Security System in Python. The code is very simple I just use logical operators in Python that is the and condition and if - else statement. If the user provides invalid username and password our program will continue to ask the user to give the right user name and password by using a while loop statement in our program. Again there are many rooms for improvement of our program this is just a beginning how to write your our password security system in Python.

I hope you find my work useful and thank you very much.


Sample Output of Our Program


Python Integrated Programming Environment

Program Listing

print("\n")
print("$$$==================================$$$")
print("       PASSWORD SECURITY SYSTEM         ")
print("$$$==================================$$$")
complete = False

while complete == False:
 print("");   
 username = input("User Name :>> ").lower().strip()
 password = input("Password  :>> ").lower().strip()

 username1 = "admin"
 password1  = "123"

 username2 = "bill"
 password2 = "12345"

 if (username == username1 and password == password1):
     print("\n");
     print ("Access granted")
     print ("Welcome to the System")
     complete =True
     print("\n");   
     
 elif (username == username2 and password == password2):
     print("\n");
     print ("Access granted")
     print ("Welcome to the System")
     complete =True
     print("\n");   
    
 else:
     print("");
     print ("Access Denied  !!!")
     complete=False
     print("\n");   



Odd and Even Number Checker in Python


Learning is a continues process this is true specially we are working in the field of Information Technology. A field that everyday is changing in terms of new development in technology we must able to adapt new methods how to manage information to be beneficial not only to us but also to other people.

In this article I will continue my study and sharing my sample program using Python as my programming language by this time I called this program Odd and Even Number Checker in Python. Writing programs in Python makes me realize that this programming language is easy and simple to use anyone who reads my article I encourage each of you to give Python a try in your programming projects on hand it will make your life much easier and enjoyable way to write code.

What the program will do is to ask the use to enter a number and then our program will determine whether the number that is being given by the user is odd or even number. I write a simple function in python to determine if the number is an odd or even number. Below is the function that I wrote I name it check_value with a parameter that I named number.

def check_value(number):
 if  (number%2 == 0):
    print("The number" ,number,"is an Even Number.")
 else:
   print("The number" ,number, "is an Odd Number.")
   return

I hope you will find my work useful and beneficial in your learning how to program in Python programming language.

Thank you very much.

Sample Output Of our Program


Python Integrated Programming Environment

Program Listing

# Odd and Even Number Checker
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 2, 2014 Monday

def check_value(number):
 if  (number%2 == 0):
    print("The number" ,number,"is an Even Number.")
 else:
   print("The number" ,number, "is an Odd Number.")
   return

print("\n")
print("@==================================@")
print("    ODD AND EVEN NUMBER CHECKER     ")
print("@==================================@")

complete = False
while complete == False:
 print("");
 value = int(input("Kindly Enter A Number :=> "))
 print("");
 check_value(value);
 print("")

 choice = input("Are You Finish?  Y/N: ").lower().strip()

 if choice == "y":
      complete = True
 else:
      print("")

print("\n")
print("Thank You For Using This Program.")
print("\n")       






Login System in Visual Basic .NET and Microsoft Access

Information is very important to us as human being this information is very useful in making decisions in our day to day lives.  Now every individuals is equip with different devices and gadgets which enables them to communicate, read news from the Internet, do some buying and selling in the Internet.  But the biggest question is how secure our information whether it is stored in the Internet or on our own computer.  Generally speaking one of the most important issues is all about computer security that most people is not bothered with. Why because some people think if you use difficult username and password in your computer or your account the in web you are already secure and having a peace of mind because you know no body has the access to your account but only you alone.

Again this presumption is not correct most of the time, hackers and other people that has a high level of technical skills and knowledge in computers were able to gather information about any person and use those information for their own benefit. We have heard many times hackers able to get and stoles thousands or even millions of credit card numbers from banks and financial institution worldwide and sold this credit card numbers including the information of the person online with the right price you can get one and use it in your shopping or  business transactions. Why this things happened because there are security issues and problems were discovered in banks information system that hackers will able to exploit. Sometimes this loopholes in the system was also discovered by bank employees or IT personnel in the bank that they have a direct access in the system.  As I said in any bank or even financial institution they should practice security audit from time to time to know what are the problems or bugs in their system to avoid to be the next victim of hackers or intruders.

In this article I will discuss and show you how to create a database drive login system using Microsoft Visual Basic .NET as my programming language and Microsoft Access 2007 as my database.  I called this program login system using Microsoft Visual Basic 2010 and Microsoft Access 2007.  To be honest this is my first database application that I wrote using Visual Basic .NET because most of the time I used Microsoft Visual Basic 6 as my tool in creating customized database application for my clients here in the Philippines.  But I think learning the new version of Visual Basic is very important skills in today's information technology driven society and also to upgrade my skills in programming tool.   By contrary database programming in Visual Basic .NET is much easier compared to Visual Basic 6 why because all the necessary commands for database access is already built in and the user interface is excellent in my own opinion.
I started designing first my user interface in a form I named the form login system in its caption. The background of the form I choose light green it is my own preference  you can select the colour that you want in your program it doesn't matter it is more of the personal choose. Next in line I draw two text box the txtusername and txtpassword that will accept the user name and password of the user. I also write the labels to give the use the idea what to do the first label asking the user to enter the user name, the second label is asking the user to enter the password.  There are also two command buttons the OK and CLOSE. The OK command button if the user already type the username and password  and then click the OK button it will check if the username and password exist in our table named login in our Microsoft Access database named user. If the user choose the close command button the program will close and it will return to our windows operating system. In my case the computer that I am using in writing and developing this program I am using  Microsoft Window 8.


About the code I make sure the code is short and easy to understand by my fellow programmer. I am using connection string to allow me to connect Microsoft access 2007 database to my visual basic code as usually we must use SQL statement to do some queries in our table. In our SQL statement we issue a command SELECT username,password FROM login where username=? and password=? this statement tell SQL that we select fields username and password to check if the username and password provided by our user in our form is correct or not.  I also use a function in Visual Basic .NET to convert username and password into lowercase the command is ToLower(). Every time a user type username and password even the user type in capital or combination of uppercase and lowercase our program will convert all the user name and password into lower case. If the user name and password is correct our program will congratulate the user is not it will give a chance to the user to key in once again the correct user name and password in our program.




Sample Output of Our Program


Program Listing


Imports System.Data.OleDb
Public Class frmlogin
    Private Sub Btn_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_login.Click
        Dim con As New OleDb.OleDbConnection
        con.ConnectionString = "PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source = ..\user.mdb"
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT username,password FROM login where username=? and password=?", con)

        cmd.Parameters.AddWithValue("username", Me.txt_username.Text)
        cmd.Parameters.AddWithValue("password", Me.txt_password.Text)

        Try
            con.Open()
            Dim read As OleDbDataReader = cmd.ExecuteReader()

            If read.HasRows Then
                read.Read()

                If Me.txt_username.Text.ToLower() = read.Item("username").ToString And Me.txt_password.Text.ToLower = read.Item("password").ToString Then
                    MsgBox("You have login in the system successfully.", MsgBoxStyle.Information, "For your information")
                    Me.Hide()

                ElseIf String.IsNullOrEmpty(Me.txt_username.Text) Or String.IsNullOrEmpty(Me.txt_username.Text) Then
                    MsgBox("Please make sure the username and password is not empty.", MsgBoxStyle.Exclamation, "Warning")
                End If

            Else
                MsgBox("Username and Password is incorrect. " & vbCrLf &
                       " Access Denied !!! Please Try Again.", MsgBoxStyle.Exclamation, "Warning")
                Me.txt_username.Text = ""
                Me.txt_password.Text = ""
                Me.txt_username.Focus()
            End If

            read.Close()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            con.Close()
        End Try

    End Sub

    Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click
        End
    End Sub
End Class







Prime Number Checker in Visual Basic NET

One of the fascinating machine man was able to develop and invented is the computer. This tool makes our day to day work more easier and efficient in a way that most common task and repetitive work can be done by the computer  faster and most important is its accuracy to perform computation.  Computer evolves a lot from a mere tool for solving mathematical problems during second world war into a machine that runs our entire information system around the world.  As a user we always rely on the aspect the computers can always gives us correct results as long the program that runs on it is correct all the time.

This is also one of my thinking before when I started my study in computer science during my college days our teacher would tell us if we right correct code in our program it will always generate correct results he is correct. But I have later learned in my later career in information technology field that even we have a correct written program there are some situation that our program will misbehave or gives us wrong results. It is a funny story that I have read and hear that some people always blame the computer if they can't get the right result that they needed. Common sense tells us that computer is a machine it does not its own mind of thinking compared to us human being that we are intelligent over many things including animals that surround us.

Computer scientist wrote different principles in programming to create error free programs but the problem is the users does not understand most of the time what are the limitations of the computer.  For instance our program will ask the user to enter their name in the system and our program will store those information in the database. If the user will give erroneous information about themselves or wrong spelling our program does not have the capability to check for those entries in the first place. We can only check if the fields are not empty before it will be submitted to our system to be saved but the verification must be done first by the user in the first place.

For me the biggest time that is allocated is not just writing the code of the program but in the process of debugging finding and correcting errors in our program. Once we correct the errors in our program we deploy our program to our end user they are the one will scrutinize and give us the feedback about the problems that they encounter in your our program. In order for us to minimize this problem we must able to have a good program planning before we write our first line of code in our program. By this way we can focus in solving the main problem of program and make our user happy by giving them a program that is very easy to use and more efficient to cater their day to day work.

In this article I will discuss about a program that will check if the number being given by the user is prime number or not.  Most of us during our elementary years our math teacher teach us the if a number the is integer by nature is bigger than one and have no other divisors other than oen and itself is considered as prime number.  For example 5 is a prime number, since no number except 1 and 5 divides on it.  It is also the same with 8 is not considered as prime number because it can be divide by 2 and 4.

What our program will do is very simple it will ask the user to enter a number in our text box. There are three command button the first command button is check prime if the user click this button it automatically determines whether the number is prime number or not a prime number by displaying a message in our form.  The second command button is the clear is this clear button allows the user to clear the text box and label message in our form that enables the user to enter new number to be check by our program. The third and last button is quit button this quit button if the user choose it will display a message dialog box asking the user if the user wants to quit the program for good or continue using the program.  I also put a code that will check if the user was not able to put any number in the text box it will give the user a message to put some numbers in the text box. This code I wrote just to protect our program to generate a wrong value.


I hope you have learned something in our program Prime Number Checker written in Visual Basic .NET if you have some questions, comments and suggestions how I can improve my codes and articles please send me an email I am very glad to hear it from you as readers in this website.

Thank you very much.




Sample Output of Our Program

Program Listing

Private Sub Prime_Number_Check(ByVal number_value As Integer)
        Dim prime_number As Boolean = True
        For i = 2 To number_value / 2
            If (number_value Mod i = 0) Then
                prime_number = False
                Exit For
            End If
        Next i
        If prime_number = False Then
            lbl_message.Text = "The number " & Val(txt_value.Text) & " is not a Prime number."
        Else
            lbl_message.Text = "The number " & Val(txt_value.Text) & " is a Prime number."
        End If
    End Sub
    Private Sub btn_check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_check.Click
        If Trim(txt_value.Text) = "" Then
            MsgBox("You must put a number it can't be empty.")
            Me.txt_value.Focus()
            Me.lbl_message.Text = ""
        Else
            Prime_Number_Check(Val(txt_value.Text))
        End If

    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.txt_value.Text = ""
        Me.lbl_message.Text = " "
        Me.txt_value.Focus()
    End Sub
    Friend WithEvents btn_quit As System.Windows.Forms.Button

    Private Sub btn_quit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_quit.Click
        If MsgBox("Are you sure you want to quit?", MsgBoxStyle.Critical + MsgBoxStyle.YesNo, "Quit Program?") = MsgBoxResult.Yes Then
            Me.Hide()
        Else
            Me.Show()
            Me.txt_value.Text = ""
            Me.lbl_message.Text = " "
            Me.txt_value.Focus()
        End If
    End Sub
End Class






Addition of Five Numbers Using JQuery


As a programmer I always try different ways to solve problems in programming in many different ways or methods and using different programming languages. In this article I will show you how to write a very simple program using JQuery Framework to find the sum of five numbers given by the user of our program.

JQuery Framework is a JavaScript library that enables programming to add functionality in their web applications in the client side. Based on my personal experience I have use JQuery to validate entries in the text field in HTML, I can also use it to create dynamic web pages and animations. Most of the website that we have seen in the Internet using JQuery in one way to another. Our program works very simple it will ask the user to enter five numbers in five text field and then it will return the total sum. I also added a function that the user can only use their keyboard to navigate the text field by simple pressing the return key or the enter key.

I hope you find my work useful in learning how to use JQuery Framework.

Thank you very much.


Sample Output of Our Program

Program Listing

<html>
<head>
 <script type="text/javascript" src="jquery.js"></script>
 </head>
<body bgcolor="lightgray">
  <font size="6" face="Arial" color="green">
  Addition of Five Numbers Using JQuery </font>
  <font size="3" face="Arial" color="green">
  <br><br>
  Value No. 1: <input type="text" id="no1" name="field1" size="4"><br>
  Value No. 2: <input type="text" id="no2" name="field1" size="4"><br>
  Value No. 3: <input type="text" id="no3" name="field1" size="4"><br>
  Value No. 4: <input type="text" id="no4" name="field1" size="4"><br>
  Value No. 5: <input type="text" id="no5" name="field1" size="4"><br>
<br>
  <input id="send" type="submit" value="ADD SUM" title="Click here to find the sum of numbers">
    <br><br>
<font size="5" face="Arial" color="green">
    <span style="padding:0 10px;"></span>
</font>
    <script>
   
        $('#send').click(function () {
            var a = $("#no1").val();
            var b = $("#no2").val();
            var c = $("#no3").val();
            var d = $("#no4").val();
            var e = $("#no5").val();
var display_result = "The total sum is " +addition(a,b,c,d,e) +".";       
  $("span").append(display_result)
          
        });
function addition(a1,b1,c1,d1,e1)
     {
     var total_sum = Number(a1) + Number(b1) + Number(c1)+ Number(d1)+ Number(e1)  
return(total_sum);
}
</script>

  
<script type="text/javascript">

$('#no1').keypress(function(event){

var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
$('#no2').focus();
}
event.stopPropagation();
});

$('#no2').keypress(function(event){

var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
$('#no3').focus();
}
event.stopPropagation();
});

$('#no3').keypress(function(event){

var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
$('#no4').focus();
}
event.stopPropagation();
});

$('#no4').keypress(function(event){

var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
$('#no5').focus();
}
event.stopPropagation();
});

$('#no5').keypress(function(event){

var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
$('#send').focus();
}
event.stopPropagation();
});
</script>
 </font>  
  
</body>
</html>
</body>
</html>

DOWNLOAD FILE HERE

Bad Words Remover in PHP

PHP is a very versatile web programming language it is being used by millions of websites in the Internet. Most of the commonly used content management system just like WordPress, Drupal and Joomla is being written using PHP and MySQL database. As a developer majority of my programming projects is written in PHP and MySQL I found this programming language very easy to use and can done the job in a very short period of time and within the budget.

In this article I would like to share with you a sample program that I wrote before that will remove bad words in a given sentence or paragraph by the user. This program is very useful is you are trying to create a comment system in PHP and MySQL it will remove or filter bad words given by the user of your system.

I hope you find my work useful in your programming projects and assignments using PHP and MySQL.

Thank you very much.


Sample Output Of Our Program






Sunday, June 1, 2014

Sorting Three Numbers in C++

When is the last time we try to arrange or sort as series of numbers using pen and paper? That’s ok if you are trying to sort or arrange numbers that are very few but what is your are dealing of many numbers it seems that job is not easy using manual operation just like using pen and paper it very prone to errors and it takes a lot of effort in our part to sort each number in proper order. One of the benefits of your computers in general it helps us making our lives easier and less effort. The computer is a complex machine and has the ability to perform fast computation compared to its human counterparts. Sorting in computer science mean it is the arrangement of numbers, letters or works in ascending or descending order. Let me explain the two types of sorting arrangement in details.
Ascending sort mean that we arrange the numbers, texts or words small the smallest value to the highest number values. In terms of letters we start with letter A to Z as simple as that in ascending order. On the other hand descending order is the opposite of ascending order in this case from the biggest number value to the smallest number value or Z to A in terms in alphabets. In our sample code here I am not using any sorting algorithms to sort these three numbers. All we need is the use of the if – else statement to compare which of the three numbers is the smallest, middle and the highest number.
I call this program Sorting Three Numbers this program is not difficult but we must able to understand its inner logic with its conditional statement we use here that is If-Else statement in C++. The first thing that our program will do is to ask the user to enter three numbers simultaneously. In this case we assign three variables A,B,C. After we ask the user to enter three integer number our program will process this values using a series of conditional statements in C++.
if(a<b){
if(a<c){
cout<<a<<", ";
if(c<b)
cout<<c<<", "<<b<<"\n";
else cout<<b<<", "<<c<<"\n";
}
In this code if variable a is less than B then proceed with the second if statement if (a < c) if the condition in true then the smallest number is A will be displayed in our screen. This if-else statement that we have right now is called compounded or nested if-else statement because we have the outer if statement and inner if-else statement inside of it. The third condition is we select variable C that is the smallest number from the list of three given earlier by our user. So the arrangement if variable C is smallest will be cout<<c<<", "<<b<<"\n"; this means c is the smallest value and followed by b. If the condition is not true then it proceed with next statement that is cout<<b<<", "<<c<<"\n"; that meaning of this command is the variable B is the smallest value and then followed by the second value that is variable C.
else{
cout<<c<<", ";
if(a<b) cout<<a<<", "<<b<<"\n";
else cout<<b<<", "<<a<<"\n";
}
}
In this section of our code I will explain that if both two conditions is false then this will be the last condition of our first if-else statement by this time the value of variable C will be displayed in the screen and then we have another condition that tells us if (a<b) then the display will be cout<<a<<", <<b<<"\n"; and will followed by our else statement cout<<b<<", "<<a<<"\n";. At this point we can clearly see that we just rearrange the placement of our variable the fits in our condition. We are just dealing only with three numbers.
The second if-else statement we are dealing the if (b <c) then the display will be cout <<b<<”.”; Another condition if (a <c) the it will display cout << a <<”,” <<c<<”\n”; but it the condition is false it will display the cout << c<<”,”<<a<<”\n”;
if(b<c){
cout<<b<<", ";

if(a<c) cout<<a<<", "<<c<<"\n";

else cout<<c<<", "<<a<<"\n";
}
This is the last part of our code by this time we are dealing with the variable C is the condition is false then it will display the value of variable C. Next will follow the condition of if (a<b) then it will display cout << a << “,” <<c<<”\n”; and then if it is false it will display the following statements to the user cout<<b<<", "<<a<<"\n";
else{
cout<<c<<", ";
if(a<b) cout<<a<<", "<<c<<"\n";

else cout<<b<<", "<<a<<"\n";
}
}
After the execution of our program it will display a message that thanking the user for using our program and then it will return to your operating system. I hope you have learned something new in this article sorting three numbers. In this article I’m using CodeBlocks as my text editor and Dev C++ that is being integrated within our Codeblocks text editor. If you have some comments, questions and suggestions feel free to email me.

Thank you very much.


Sample Output Of Our Program


Code::Blocks text editor that is being used in writing this program


Program Listing

#include <iostream>
using namespace std;

int main()
{
int a=0, b=0, c=0;
cout << "\t <====== SORTING THREE NUMBERS =====>";
cout << "\n\n";
cout<<"Please Enter Three Numbers :=> ";
cin>>a>>b>>c;
cout << "\n\n";
cout<<"Numbers sorted in Ascending Order : ";
if(a<b){


if(a<c){
cout<<a<<", ";
if(c<b)
cout<<c<<", "<<b<<"\n";
else cout<<b<<", "<<c<<"\n";
}
else{
cout<<c<<", ";
if(a<b) cout<<a<<", "<<b<<"\n";
else cout<<b<<", "<<a<<"\n";
}
}
else{
if(b<c){
cout<<b<<", ";
if(a<c) cout<<a<<", "<<c<<"\n";
else cout<<c<<", "<<a<<"\n";
}
else{
cout<<c<<", ";
if(a<b) cout<<a<<", "<<c<<"\n";
else cout<<b<<", "<<a<<"\n";
}
}
cout << "\n\n";
cout << "THANK YOU FOR USING THIS PROGRAM";
cout << "\n\n";
system("pause");

}

Addition of Three Numbers Using AngularJS


As I started learning different programming languages I have learned that there are many libraries or frameworks that can help us in our day to day work as computer programmers and developers one of the most recent framework that I work with is a JavaScript framework named AngularJS.

AngularJS is an open source framework that is being manage by Google and the community to help programmers and developers to help them create single web page that uses HTML,CSS and Javascript in the client side. In addition AngularJS was designed with the use of the concept of Model-View-Controller capability to make web development and testing much easier to do.

In this example that I will show you I will write a simple program that uses AngularJS to find the sum of three numbers. What the program will do is very simple it will accept three numbers from the user, perform addition operation and then display the sum values of three number that is being given by the user.

I hope you will find my work useful in your programming projects and assignments in the near future.




Sample Output Of Our Program

Program Listing

add.htm

<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<script src="angular.js"></script>
<style>
.wrapper {
  width: 90%;
  display: block;
  margin: 0 auto;
  padding: 2.5em;
}
</style>

</head>
<body bgcolor="lightgreen">
<br><br>
   <h2><center> Addition of Three Numbers Using AngularJS </center> </h2>
   
   <div class="wrapper" ng-app>
  1st No.<input type="number" placeholder="Enter a number" ng-model="num1" /><br>
  2nd No.<input type="number" placeholder="Enter a number" ng-model="num2" /><br>
  3rd No.<input type="number" placeholder="Enter a number" ng-model="num3" />
  <p>The sum total of {{num1}}, {{num2}} and {{num3}} is {{ num1 + num2 + num3}}.</p>
</div>
   
</body>
</html>




Area of a Circle in Python


Beginners, students and hobbyist who spend their time in learning how to write simple program may encounter solving the problem of area of a circle by finding its radius. In this article I will show you how to write you own program in solving the area of the circle by using Python as your programming language. In developing this program I was able to identify what is the program should suppose to do. 

First our program will ask our user to enter the radius of our circle. After the user provided the radius of our circle our program will perform a series of computation to find the area of the circle. In this example of mine I have created a function to return the computed value of the area of the circle. I called the function area_of_circle(r) with a parameter r it represent the radius of our circle. The formula we use to find and solve the area of the circle is  a = r**2 * math.pi. The command math.pi is a built in function i Python which contains the fixed value of a pi of a circle that has a value of  3.141592653589793. In order for us to use the math.pi statement we must include this library file command on the top of our program with this command import math this instruction tells our Python compiler to include the math library file in our program so that we can use properly the math.pi statement in our program.

def area_of_circle(r):
    a = r**2 * math.pi
    return a

A function to solve the area of the circle 

In addition my program ask the user whether the user will continue to us the program of not. It enables our user to run the program again and give a another different value of area of the circle. By doing so it makes our program interactive, user friendly and more easier to us.

I hope you find my work useful in learning how to write a program using Python.

Thank you very much.


Sample Output Of Our Program


Python Text Editor where are program is written


Program Listing

# area of a circle solver
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 1, 2014

import math

def area_of_circle(r):
    a = r**2 * math.pi
   return a

print("\n")
print("@==============================@")
print("    Area of a Cirlce Solver     ")
print("@==============================@")

complete = False
while complete == False:
 print("");
 radius = int(input("What is the radius of the circle :=> "))
 print("");
 print ("The area of the circle is ",format(round(area_of_circle(radius),4)),'.')
 print("")

 choice = input("Are You Finish?  Y/N: ").lower().strip()

 if choice == "y":
      complete = True
 else:
      print("")

print("\n")
print("Thank You For Using This Program.")
print("\n")       


Consonants and Vowels Counter in Python

As I continue my study how to program in Python programming language I have discovered that Python has many build in functions that makes programming easier and fun. I have decided to create a program that I called Consonants and Vowels Counter what the program will do is very simple it will as the user to enter a sentence or a string and then the program itself will count the number of consonants and vowels in a given sentence or string.

In order for us to understand what are vowels and consonants let us have some little review what is a consonants. Consonants are letters that does not belong to A,E,I,O,U they are as follows B,C,D,F,G,H,J,K,L,M,N,P,Q,R,S,T,V,W,X,Y and Z. One of the built in command in Python in the list command where we can list down all the letters in vowels and consonants so that later on in our program we can easily search those letters in a given string or sentence by the user. The next portion of our program it will ask the user to enter a sentence or a string using the following commands words = input("Kindly enter a sentence or a word :=> ").lower().strip() again in Python programming we are allow to use a variable in our program without declaring it and having its own data type. In this case I use the keyword words as my variable to accept sentence, words or string from our user.

The function lower() and strip() that I added in our program will convert the sentence or string into lowercase and strip any special characters in a given sentence by our user of our program. The next commands number_of_consonants = sum(words.count(c) for c in consonants) and  number_of_vowels = sum(words.count(c) for c in vowels) will count the number of vowels and consonants in a given sentence by the user of our program. I am using a function in Python called count that will count the number of occurrence of vowels and consonants that is being store in our list function. We have also here a for loop statement with variable c which connect to our consonants and vowel variables.

After the checking and counting of consonants and vowels in our program we will display the results in our screen using the following commands print("The String is" ,str(words).upper(),"."), print(""), print(" Number of  Vowels     : ",number_of_vowels),  print(" Number of  Consonants : ",number_of_consonants) the first command it will display the sentence provided by our user in this case I converted the given sentence into uppercase format after which it will display how many vowels and consonants in the given sentence by our user.

The best thing about this Consonants and Vowels Counter Program that I wrote is that I added a while loop statement to enable the user to re run again the program so that it can accept another sentence or string. It makes our program interactive and more user friendly.

I hope for find my work useful in your quest in learning how to program in Python programming language. In my own opinion as a programmer I can say writing a program in Python is much easier and shorter compared with other programming languages like C,C++,C# and Java because it has many built it function that makes the life of a programmer a breeze.

Thank you very much.


Sample Output Of Our Program


Our Python Text Editor

Program Listing

print("\n")       
print("@==============================@")
print(" Consonants and Vowels Counter")
print("@==============================@")

vowels = list("aeiou")
consonants = list("bcdfghjklmnpqrstvwxyz")

complete = False
while complete == False:
  print("")       
  words = input("Kindly enter a sentence or a word :=> ").lower().strip()
       
  number_of_consonants = sum(words.count(c) for c in consonants)
  number_of_vowels = sum(words.count(c) for c in vowels)
  
  print("")       
  print("The String is" ,str(words).upper(),".")
  print("")
  print(" Number of  Vowels     : ",number_of_vowels)
  print(" Number of  Consonants : ",number_of_consonants)
  print("")
  choice = input("Are You Finish?  Y/N: ").lower().strip()
  if choice == "y":
       complete = True
  else:
       print("")
print("\n")       
print("Thank You For Using This Program.")
print("\n")