Introduction to Computer Technology version A4

 How do we call people developing computer programs?
 
Software engineers, software developers, or programmers are people writing many programs connected together as an app (applications) to perform a task or many tasks. Sophisticate programs are called software.
 
What is a computer? How can we break down its key components? 

 

A computer, tablet, or laptop consists of hardware and software.
 
The main hardware of a computer is called mother board, which consists of central processor units (CPU), random access memory (RAM) to store data for processing, hard disk to store information or files, keyboard and touch pad to input data, etc.
 
To make computer hardware working, it needs an operating system (OS) such as Windows 10 Home, Android OS, or Mac OS. The OS is an interface between an app (application programs) and hardware.
 
The application programs (software) were written by programmers or software developers in a programming language, which performs a task or multiple tasks for users. For example, we have application programs such as Google Chrome, Google Doc, Microsoft Word, Adobe PDF Reader, etc.
 
There are many programming languages in the software development world such as Python, C++, C#, Visual Basic, COBOL, Java, PLEX-C, etc. Each programming language has its strength, unique syntax, and specialty in specific fields of applications. For example,

·         Visual Basic is very easy to learn and create a simple application. However it didn’t offer many built-in functions for complex applications. Visual Basic is a programming language on Microsoft OS.
·         COBOL is used on IBM mainframe computer to handle banking applications. COBOL is a specialized language used on IBM mainframe.
·         PLEX-C is a specialized programming language used by Ericsson AXE, which is key equipment in telephony. This programming language is easy to learn and offered easy ways in debugging.
·         Python is an interactive language, which allows users to programming directly on Idle interface. Programmers could also write a program similar to other programming languages and then execute those.
 
We will talk more about Python as many programmers have supported this programming language by developing many built-in functions (library) for financial applications, machine learning (ML) and artificial intelligence (AI).
 
Can we use Python in financial applications?
https://www.stxnext.com/blog/why-python-should-be-technology-choice-your-fintech/
 
Python is chosen by financial technical staff for

·         Its simplicity in syntax, i.e. it is faster to write an application in Python as compared to other programming languages such as Java and C++.
·         Lower software development costs and shorter time to market. Because it is simple, it takes less time or programmers to develop an application, i.e. paid less to developers and faster deployment of an application to end users.
·         Open source financial libraries. It is open source means that anybody wanted to contribute built-in functions to the Python library, and then they could do so. Developing an application would be less expensive with free built-in libraries.
 
How are Python in machine learning (ML) and artificial intelligent (AI) applications?
 
ML and AI applications provide a system, which could learn new data or improve pre-entered data in database. Software engineers must predict a lot of cases could happen to the system, thus the system could answer or perform tasks accordingly. However ML or AI system is not able to learn as a human being. It learnt new data based on pre-programmed statements.
 
Read https://expertsystem.com/machine-learning-definition/
 
·         A great choice of libraries is one of the main reasons Python is the most popular programming language used for AI. A library is a module or a group of modules published by different sources like PyPi which include a pre-written piece of code that allows users to reach some functionality or perform different actions. Python libraries provide base level items so developers don’t have to code them from the very beginning every time.
 
·         ML requires continuous data processing, and Python’s libraries let you access, handle and transform data.
 
What is Python or a programming language?
 
Python has been around for more than 20 years. Google engineers have been using Python in many applications such as processing of videos in YouTube. “Python is developed under an OSI-approved open source license, making it freely usable and distributable, even for commercial use. Python's license is administered by the Python Software Foundation.” Any software engineers could develop programming codes and add those into Python libraries making it available worldwide.
 
In a programming language, we have to differentiate

·         A string consists of sequence of characters such as letters, digits, and special characters. There are a few methods to manipulate a string such as appending two strings, search a character within a string, etc.
·         An integer is a whole number
·         A float is a floating-point number, which means it is a number that has a decimal place. Floats are used when more precision is needed.
·         Etc.
 
A program or an app consists of many programming statements, which will be executed sequentially. Each program statement must follow syntax of its programming language. Python is a simple programming language, but it has its own syntax to follow.
 
We could give you an example of a simple program at Python Idle’s prompt

·         a = 3      # we assigned variable “a” with a value of “3”
·         b = 10   # we assigned variable “b” with a value of “10”
·         a + b
·         # Idle would print out the value of “13” as a result of “a + b” or “3 + 10”
·         a * b
·         # Idle would print out the value of “30” as a result of “a times b” or “3 x 10”
·         # An example about manipulating strings
·         c = “Hello”                # assign variable c with value ‘Hello’
·         d = “everyone”       # assign variable d with value ‘everyone’
·         c + “ “ + d
·         # Idle would print out the value of “Hello everyone” as a result of concatenating of string “c”, a white space, and “d”.
 
As we could see above, Python is an interactive programming language. We could perform many mathematical calculations simultaneously as we used to do on an electronic calculator.
 
Are we only using Python to replace a calculator?
 
No, Python could perform many complex tasks with sophisticate programs or apps. Python is also used in computer graphics. For example, we could write program to draw a circle as a person face, dots as eyes, triangle as nose, and oval as mouth. The face could be filled with any colors as programmer likes. All mouse clicks could be captured by Python and translate into its horizontal and vertical coordinates for further processing. The face could be moved around automatically with appropriate functions in the library graphics.py.
 
A simple application for us is to write a “Happy birthday” song to any of our friends once. We could write the text of the song with unknown name surrounded in curly brackets. This text is like a dictionary or story. We then wrote other programming statements to prompt users to enter a name. The entered name would replace the unknown name in the story. Therefore this song could be reused for anybody.
 
What is a build-in function? Does this help programmers with their programming tasks?
 
Built-in functions come with a specific programming language, e.g. Python. For example, Python has many built-in functions to perform many mathematical calculations and string manipulations. 
 
·         # An example about manipulating strings with built-in function upper()
·         e = “Hello”                # assign variable c with value ‘Hello’
·         c = e.upper()            # turn the string e into upper case letters and copy to variable c
·         print (c)
·         # Idle would print out the value of “HELLO” as a result.
 
Without the built-in function upper, programmers may have to extract each letter in the string “e” and convert it into upper case, and then concatenate those letters. Therefore the programming task is easier with built-in functions.
 
What is a library in Python? How could we use it?
 
A library developed by a programmer(s) offers many useful functions, so we could speed up our software development. Functions available in the library are similar to built-in functions, but we need to import the library into our programs in order to use those.
 
If a programming language has many libraries available, programming tasks would be faster and easier.
 
One of good software development practices is to “divide and conquer” a complex system. The entire system would be broken down or designed into smaller subsystems, which would be communicated or exchanged data with each other via a specified interface, which is often called Application Programming Interface (API). Many sections of codes must be thought out earlier, so it could be developed and then reused as library for other parts of codes or by other software developers.
 
I would like to give an example for developing a robot with ML and AI concepts.
 
Before getting into details, we should understand database, which is like a look up table used in software development.
 
Here is an example of a look up table
 

Name

School

Grade

Address

Francis Lee

Holly Cross

11

64 Harper Street

Donald Thompson

Saint Peter

10

32 Garland Ave

Claude Keener

Monsignor

6

82 French Road

 
There are 4 columns with headings “Name”, “School”, “Grade”, and “Address” in the first row, which will be used as keys to search for data stored in subsequent rows.
 
If we wrote a program asking users to enter a name; user enters “Donald Thompson”. The program would search the first column with heading “Name” for any entry with name as “Donald Thompson.” After finding that entry (third row), the program would print out name, school, grade, and address stored in the same row in a report by using string concatenation. For example, “Student Donald Thompson is attending grade 10 at Saint Peter School. The student is living at 32 Garland Ave.”
 
For machine learning and artificial intelligent applications, the programmers must write programs to base on data entered by users, and search its database to guess the possible answers for that inputted data. Let’s consider a simple program of a robot answer his name based on questions by users.

The original database would consist of a table with 3 columns to store guessing questions from users and its associated answer. The third column would help programmers to identify new data learnt by the robot, so he could manually verify its correctness later. The first column includes typical questions asked by a person for name pre-entered into database by programmers.
 

Question

Answer

Learnt or original data

What is your name?

My name is Anthony Peter

original

Please tell me your name?

My name is Anthony Peter

original

 

 

 

 
Whenever the robot was asked by a user, his voice would be captured and converted into a string, so the string would be processed by programs. For those questions such as “What is your name?” or “Please tell me your name.”, the robot would play the answer “My name is Anthony Peter.”, which was stored in the second column via a speaker.
 
However, a user could ask a question for robot name, but those questions were not anticipated and stored in database. For example,

·         User asked “Please say your name.
·         The application stored in the robot could not find the exact question in the database. Thus it search for the synonym of the verb “say”, which is similar as “tell” in the first column. The keywords “Please” and “your name” also matched those words in the first column.
·         Therefore the answer would be very likely as the answer in the second column.
·         The robot would answer “My name is Anthony Peter.”
·         The application would insert another entry in database with this new question and marked it as “learnt” in its third column as described below. This would help programmers to query all “learnt” data later and validate those. After validation or its correctness, programmers would change “learnt” into “update” in database.
 

Question

Answer

Learnt or original data

What is your name?

My name is Anthony Peter

original

Please tell me your name

My name is Anthony Peter

original

Please say your name

My name is Anthony Peter

learnt

 

 

 

 
Is a computer smart and outperform human?
 
No, computer is dummy electronic equipment. Software developers would instruct it performing a task or multiple tasks by a programming statement or series of statements.
 
Even with super smart AI application such as the chess player developed by IBM, programmers must think all possible moves to win a game. The super computer could run very fast and go over all possible moves quicker than a person. However the chess player could not invent a new move to win a game beyond algorithms pre-programmed.
 
As we can see from the simple robot program above, if a user asked “Please pronounce your name,” and the word “pronounce” is not in synonym dictionary for “tell” on the computer, the robot would be halted or silent. In this case, the robot would log this “unanswered” question above in its database, and its programmers would review unanswered questions and teach the robot to answer this question with its name in the future by entering another entry in the database.

Question

Answer

Learnt or original data

What is your name?

My name is Anthony Peter

original

Please tell me your name

My name is Anthony Peter

original

Please say your name

My name is Anthony Peter

update

Please pronounce your name

My name is Anthony Peter

update

 
Notes: “update” in the third column of the database above meant that the programmer has reviewed and updated its data as correct data similar to “original” data.

The robot’s answer based on query of synonym database was marked as “learnt”, so developer would be able to verify all data in rows with third column with “learnt”. This could be done easily with a database query statement or database’s user interface. After validating the answer to ensure that the answer was correct, i.e. no mistake was caused by synonym database, the developer would change the third column of that row into “update”. 

Why didn’t developer change data from “learnt” to “original” after validation? 

This is to differentiate the original work or software development. This is also used in statistic purpose, i.e. figure out why original software development was not perfect, and learnt to improve system in the future. 

The same logic applies for the unanswered questions. Those questions and answers would be marked as “update” after validation. The synonym database may be updated with new data, too. 

What are the main differences between a smart phone/tablet and a laptop computer?
 
A laptop or personal computer is larger, thus it could be equipped with powerful hardware such as large size (powerful) CPU, more memory, high capacity hard disk, larger screen, etc. The operating system (OS) is usually requiring a lot of memory and powerful CPU to execute its programs.
 
Many companies developing the operating systems such as Microsoft (Windows 10) developed Windows 10 for a personal computer, and then remove a lot of functionality (programs or codes) of Windows 10 OS in order to load it on memory of Window 10 smart phone or tablet. Therefore a smart phone or a tablet could not perform many complex applications as a computer due to its limitation of powerful hardware. That’s why you did not see many people playing graphic games on their smart phone or tablet. They have to buy expensive gaming laptop or personal computer equipped with expensive and powerful hardware.
 
---------------------------------------------------------------------------------------------
 
References:
 
1.      A Python book is "Hands-On Python - A Tutorial Introduction for Beginners - Python 3.1 Version" written by "Dr. Andrew N. Harrington" from "Computer Science Department, Loyola University Chicago".
 
Book in PDF format: https://www.tnstate.edu/faculty/fyao/COMP3050/Py-tutorial.pdf
 
Examples: http://cs.luc.edu/anh/python/hands-on/3.0/examples.zip
 
2.      For Python compiler, we could use miniconda3, which supports Python version 3.7.4.
 
Miniconda could be downloaded at: https://conda.io/projects/conda/en/latest/user-guide/install/download.html
 
3.      Book about 2 dimensional arrays in Python:
 
https://www.cs.cornell.edu/courses/cs1110/2016sp/lectures/05-10-16/27.TwoDArrays.pdf
 
4.      Python and relational database
Chapter 1: Introduction to Databases
https://s3.amazonaws.com/assets.datacamp.com/production/course_1115/slides/ch1_slides.pdf
 
Chapter 2: Filtering and Targeting Data https://s3.amazonaws.com/assets.datacamp.com/production/course_1115/slides/ch2_slides.pdf
 
Chapter 3: Calculating Values in a Query
https://s3.amazonaws.com/assets.datacamp.com/production/course_1115/slides/ch3_slides.pdf
 
Chapter 4: Creating Databases and Tables
https://s3.amazonaws.com/assets.datacamp.com/production/course_1115/slides/ch4_slides.pdf
 
Chapter 5: Census Case Study
https://s3.amazonaws.com/assets.datacamp.com/production/course_1115/slides/ch5_slides.pdf
 
5.      Top 20 Open Source & Free Database Software
https://technostacks.com/blog/best-free-database-software/
 
Learning computer programing is also useful, because we are using computer technology in almost all professions including finance, accounting, management, medical professionals, engineers, etc.
 
In computer technology, relational database is very important, because it helps to store and organize data for an application. In references, there are notes for beginners to learn relational databases. The syntax to access data in a relational database is different in each programming language, but the process is similar.

By looking at the reference #4, the following statements are to open and connect to a database using Python

·         from sqlalchemy import create_engine

·         engine = create_engine('sqlite:///census_nyc.sqlite')

·         connection = engine.connect()

Similar statements above could be found in other programming languages. If you are not using proprietary SQL statements in your programs, you only need to change connection strings in your programs for switching a database, e.g. from MS SQL to Oracle. 

At school, we have learnt how to calculate factors of a number, if it was not a prime. This task may take hours if a big number was given. However a simple computer program could give us an answer within a minute. A sample Python program below is an example.
 
This sample Python program, PrimeNumber.py, is to find factors of a number, if it’s not a prime. Save the text below in a file named PrimeNumber.py, open it with Python’s Idle, and then run it.
 
Notes: in computer technology, making a program execution quick is very important in some applications such as aerospace, telecommunication. Engineers and scientists want to improve codes and hardware, so it could be run faster for a few milliseconds.
 
Calculation for factors was determined by “num”, which was started with “2” and ended with “numCheck/2” instead of starting with “1” and ended with “numCheck” respectively, was the reason.
------------------------------------------------
 
'''Python program syntax does not require a blank line after a loop.
   They only require the next line to be out dent.
 
   We don't consider the validation of negative number in this example.
'''

import sys
 
num = 2               # initialize this variable to 2
factorNo = 'No'  # initialize this variable
 
numberCheck = int(input("Enter a number greater than 0: "))
factors = [1]        # This a list to hold factors of the inputted number
                                # "1" is considered as a factor of any number
 
# The following if statement is to eliminate 0 and negative numbers
if numberCheck <= 0:
    print ("We don't validate", numberCheck, "as a prime number or not.", end=' ')
    print ("We only consider greater than zero or positive number.")
    sys.exit()            # ending the program execution
 
# By modern mathematical definition, "1" is a prime, thus "1" is a prime
if numberCheck == 1:
    print ("The number", numberCheck, "is a prime.")
    sys.exit()           # ending the program execution
 
# Without the if statement above, the following statements considered
# “zero” in validation
while num != int(numberCheck/2) and numberCheck != 0:
 
    x = numberCheck / num
   
    if(x - int(x) == 0):               # The inputted number is not a prime. One of its
                                                     # factor(s) is num.
        factorNo = 'Yes'
        factors.append(num)    # Appending the factor num in the list factors
 
    num = num + 1
    
if (factorNo == 'No' and num == int(numberCheck/2)):
        print ("The number", numberCheck, "is a prime.")
else:
    if numberCheck != 0:
        print (numberCheck, "is not a prime. Its factors are", factors)
    else:
        print ("The number 0 is not a prime by definition.")

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

Author: Vinh Nguyen

P.S. the above notes were written for high school students as an introduction of computer technology, so they would enroll in a college or university for a 3-4 year degree in Computer Science or Computer Engineering, if interested. Illustrated examples were not meant to be perfectly designed or developed.

No comments:

Post a Comment