Thursday, March 14, 2019

Input and Output Program in Python

Here is a sample program that we wrote in Python to show you basic input and output. The code is very simple and easy to understand.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Sample Program Output


Program Listing

# variables.py# Written By Rolly M. Moises and Jake R. Pomperada
# Tools : PyCharm 2018.3.5 Community Edition# March 14, 2019     Thursday   8:21 AM
# Bacolod City, Negros Occidental
print()
print("\tBacolod Software Inc. Employee's Information System")
print()

full_name =input("\tGive Employee's Name             : ")
age = int(input("\tGive Employee's Age              : "))
position=input("\tGive Employee's Position         : ")
wage= input("\tWhat is Employee's Wage          : ")
wage2 = float(wage)
yearly_salary=input("\tWhat is Employee's Yearly Salary : ")
yearly_salary2 = float(yearly_salary)
gender=input("\tWhat is Employee's Gender        : ")

print()
print("\t ===== DISPLAY RESULT =====")
print()
print("\t Employee's Name           :",full_name.upper())
print("\t Employee's Age            : {0}".format(age))
print("\t Employee's Position       :",position.upper())
print("\t Employee's Wage           : PHP %.2f" % round(wage2,2))
print("\t Employee's Yearly Salary  : PHP %.2lf" % round(yearly_salary2,2))
print("\t Employee's Gender         :",gender.upper())
print()
print("\t ===== END OF PROGRAM =====")
print()

Friday, March 8, 2019

Fibonacci Series Using Functions in Python

A simple program we wrote in Python using a function to generated Fibonacci series.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Sample Program Output



Program Listing

#fibonacci.py
# Written By Jake R. Pomperada and Rollyn M. Moises
# Date : February 27, 2019   Wednesday
# Bacolod City, Negros Occidental

def fibonacci(n):
    if(n <= 1):
        return n
    else:
        return(fibonacci(n-1) + fibonacci(n-2))

print();
print("\tFibonacci Series Using Functions");
print();
n = int(input("\tEnter number of terms : "));
print();
print("\tFibonacci Sequence")
print();
for i in range(n):
 print('\t',fibonacci(i),end='');
print("\n");
print("\tEnd of Progra



Simple Calculator Program in Python Using Function

A simple calculator program we wrote using Python and functions. The code is very simple and easy to understand.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com




Sample Program Output

Program Listing


# calculator.py
# Rollyn M. Moises and Jake R. Pomperada
# February 27, 2019    Wednesday
# Bacolod City, Negros Occidental

def menu():
    print();
    print("\t\t Simple Calculator Program");
    print();
    print("\tWritten By Rollyn M. Moises and Jake R. Pompreada")
    print();
    print("\t1. Addition");
    print("\t2. Subtraction");
    print("\t3. Multiplication");
    print("\t4. Division");
    print("\t5. Quit Program");
    print();
    return int(input("\tChoose your option: "));


def add(a, b):
    print();
    print("\t",a, "+", b, "=", a + b);


def sub(a, b):
    print();
    print("\t",a, "-", b, "=", a - b);


def mul(a, b):
    print();
    print("\t",a, "*", b, "=", a * b);


def div(a, b):
    print();
    print("\t",a, "/", b, "=", a / b);


loop = 1
choice = 0
while loop == 1:
    choice = menu()
    if choice == 1:
        print();
        add(int(input("\tAdd this: ")), int(input("\tto this: ")))
    elif choice == 2:
        print();
        sub(int(input("\tSubtract this: ")), int(input("\tfrom this: ")))
    elif choice == 3:
        print();
        mul(int(input("\tMultiply this: ")), int(input("\tby this: ")))
    elif choice == 4:
        print("\n");
        div(int(input("\tDivide this: ")), int(input("\tby this: ")))
    elif choice == 5:
        loop = 0
print();
print("\tThank you for using this program.");
print();
print("\tEND OF PROGRAM");




Factorial of a Number Using Functions in Python

A very simple program to show you how to perform factorial of a given number by the user using functions in Python

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Sample Program Output


Program Output

# factorial.py
# Rollyn M. Moises and Jake R. Pomperada
# February 25, 2019    Tuesday
# Bacolod City, Negros Occidental


def factorial(number):
    solve_results = 1
    for i in range(2, number + 1):
        solve_results *= i
    return solve_results


def my_program():
  print();
  print("\t@==================================@")
  print("\t      Factorial of a Number     ")
  print("\t@==================================@")
  print();
  value = int(input("\tEnter a Number : "))
  print("");
  if value < 0:
    print("\tSorry, factorial does not exist for negative numbers")
  elif value == 0:
    print("\tThe factorial of 0 is 1")
  else:
    print("\tThe factorial of",value,"is",factorial(value))
  print();
  repeat = input('\tDo you want to continue ? (Y/N) : ')
  if repeat.upper() == "N":
      print()
      print("\tThank You For Using This Program.")
      print();
      print("\tEND OF PROGRAM");
      quit

  if repeat.upper() == "Y":
      my_program()

if __name__ == '__main__':
    my_program()




Reading a Text File in Python

A very simple program that I wrote using Python to read the content of the text file.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com




Sample Program Output




Program Listing


# read.py
# Rollyn M. Moises and Jake R. Pomperada
# March 7, 2019   Thursday
# Bacolod City, Negros Occidental

print()
print("\tREADING A TEXT FILE");
print()
print("\tContent of the text file below")
print()

read_text_file = open("read.txt", "r")
content = read_text_file.read()

print(content)


Content of read.txt

   Fundamentals of Python Programming

Written By

 Mr. Rollyn M. Moises,MSCS and Mr. Jake R. Pomperada,MAED-IT

 Published  By

 Mindshapers Co. Inc. Publishing Company
 Rm 108 ICP Bldg. Recoletos Street, Intramuros, Manila

 Telephone Numbers : (02) 254-6160 and (02) 527-6489


 Email Address     : mindshapersco@yahoo.com 


Login and Registration in Python and MySQL

Here is a program that we wrote together with my best friend Rolly M. Moises a login and registration created using Python programming language and MySQL as our backend database. We wrote this code for our upcoming book on Python programming.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com










Sample Program Output



Program Listing


# login_registration.py
# Rollyn M. Moises and Jake R. Pomperada
# March 8, 2019   Friday
# Bacolod City, Negros Occidental

import pymysql
import subprocess as sp
import getpass


class Login:

    def __init__(self):
        self.connection = pymysql.connect(
            host='localhost',
            port=3306,
            user='root',
            password='',
            db='school_management',
        )

    def check_user(self, username, pwd):
        try:
            with self.connection.cursor() as cursor:
                sql = "SELECT * FROM users WHERE username = %s and password = %s"
                try:
                    rows = cursor.execute(sql, (username, pwd,))
                    if rows > 0:
                        record = cursor.fetchone()
                        print()
                        print("\tHello %s %s" % (record[3], record[4]),'.')
                        print()
                        print("\tWelcome to the System.")
                    else:
                        print("\tInvalid Username and/or Password. Try again.")
                except:
                    print("\tUnable to fetch records")

            self.connection.commit()
        except:
            self.connection.close()

    def login_screen(self):
        print()
        print("\tLOGIN SECURITY PAGE");
        print()
        user = input("\tEnter Username : ")
        password = getpass.getpass(prompt='\tEnter Password :')
        self.check_user(user, password)

    def logout(self):
        print("\n")
        print("\t\t\tTHANK YOU FOR USING THIS SOFTWARE.")
        print()
        print("\tCopyright 2019.  Product of Bacolod City, Negros Occidental Philippines.")
        print()
        self.connection.close()

    def register_user(self, username, password, firstname, lastname):
        try:
            with self.connection.cursor() as cursor:
                sql = "INSERT INTO users (`username`, `password`,`firstname`,`lastname`) VALUES (%s, %s,%s,%s)"
                try:
                    cursor.execute(sql, (username, password, firstname, lastname))
                    print()
                    print("\tRegistration Successfully Saved in the Database.")
                except:
                    print()
                    print("\tUnable to Register User.")
            self.connection.commit()
        except:
            self.connection.close()

    def register(self):
        print()
        print("\tLOGIN REGISTRATION PAGE");
        print()
        user = input("\tEnter Username : ")
        password = getpass.getpass(prompt='\tEnter Password : ')
        confirm_password = getpass.getpass(prompt='\tConfirm Password : ')
        print()
        first_name = input("\tEnter Firstname : ")
        last_name = input("\tEnter Lastname   : ")
        print()
        if password != confirm_password:
            print("\tPassword does not match. Try Again.")
        else:
            self.register_user(user, password, first_name.upper(),last_name.upper())


class Menu:

    def logout(self):
        self.login.logout()

    def selection(self):
        ch = "0"
        self.login = Login()
        while ch != "3":
            tmp = sp.call('cls', shell=True)
            print()
            print("\t\t    LOGIN AND REGISTRATION SYSTEM");
            print("\t\t\t     CREATED BY");
            print("\t\tROLLYN  M. MOISES AND JAKE R. POMPERADA")
            print()
            print("\t[1] Login Registered User")
            print("\t[2] Register New User")
            print("\t[3] Exit Program")
            print()
            ch = input("\tSelect option : ")
            menu_selection = {
                "1": self.login.login_screen,
                "2": self.login.register,
                "3": self.logout,
            }
            func = menu_selection.get(ch)
            if func is not None:
                func()
            else:
                print("\tInvalid option selected")
            print()
            input("\tPRESS ENTER KEY TO CONTINUE.")
menu = Menu()
menu.selection()


school_management.sql

-- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 08, 2019 at 04:32 AM
-- Server version: 10.1.37-MariaDB
-- PHP Version: 7.3.0

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `school_management`
--

-- --------------------------------------------------------

--
-- Table structure for table `student`
--

CREATE TABLE `student` (
  `id` int(11) NOT NULL,
  `name` varchar(100) DEFAULT NULL,
  `course` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `student`
--

INSERT INTO `student` (`id`, `name`, `course`) VALUES
(8, 'Jake Rodriguez Pomperada', 'Bachelor of Science in Computer Science');

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(100) DEFAULT NULL,
  `password` varchar(100) DEFAULT NULL,
  `firstname` varchar(100) DEFAULT NULL,
  `lastname` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `username`, `password`, `firstname`, `lastname`) VALUES
(4, 'admin', 'admin', 'JAKE', 'POMPERADA'),
(5, '123', '123', 'ROLLYN', 'MOISES');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `student`
--
ALTER TABLE `student`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `student`
--
ALTER TABLE `student`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


DOWNLOAD SOURCE CODE HERE


Wednesday, March 6, 2019

Accept and Displays Values Using Lists in Python

Write a program using a list that will accept ten integer values and then the program will display all the ten integer values given by the user on the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting.

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing

# list.py
# Rollyn M. Moises and Jake R. Pomperada
# March 1, 2019   Friday
# Bacolod City, Negros Occidental

memo=[]
print();
print("\t Accept and Displays Values Using Lists");
print();
for i in range (10):
    x=int(input("\t Give value in item no. {0} : ".format(i+1)))
    memo.insert(i,x)
    i+=1;

print();
print("\t The List of Values")
print();
print("\t",memo);
print();
print("\t END OF PROGRAM");