[Pick the date] [PROGRAMMING FOR BEGINNER ]
Programming for
beginner
programming ႕ ႕
႕ programming
႕ ႕
႕
Programming python language
Saturngod
Source : http://books.saturngod.net/programming_basic/
1 Programming for beginner
Contents
Introduction
1. Chapter 1
1.1. Programming
1.2. Programming Language
1.3. Sequential
1.4. Variable
1.5. Operators
1.6. Problem Solving
1.7. Installing Python 3
2. Chapter 2
2.1. Pseudo Code
2.2. Flowchart
2.3. Hello World
2.4. What is your name ?
2.5. SUM
2.6. Condition
2.7. Calculator
2.8. Looping
2.9. Array
2.10. Function
2.11. Exercise Answers
3. Chapter 3
3.1. Overview
3.2. Classes
3.3. Inheritance
4. Chapter 3
4.1. Basic Data Structures
4.2. Stack
4.3. Stack Abstract Data Type
4.4. Implementing A Stack
2 Programming for beginner
Introduction
႕ ႕
႕
႕
႕ ႕
႕
႕
႕
႕ ႕ ႕
႕
႕
႕
3 Programming for beginner
Chapter 1 :
႕ issue
4 Programming for beginner
1.1 Programming
Programmin
႕ ႕ ႕
႕
႕ ႕
႕
႕
႕
႕
Call
5 Programming for beginner
႕ ႕
႕
႕ ႕ ႕ ႕ ႕ ႕
programme
႕ ႕
႕
Com
႕
6 Programming for beginner
1.2 Programming Language
႕
႕ ႕
႕
Generation
ge
First Generation Language ( 1GL )
Second Generation Language ( 2GL )
႕
7 Programming for beginner
Third Generation Language ( 3GL )
3GL
j -
Third generation
Fourth Generation Language ( 4GL )
႕ ႕
General Use
o Perl
o Python
o Ruby
Database
o SQL
8 Programming for beginner
Report generators
o Oracle Report
Data manipulation, analysis, and reporting languages
o SQL PL
o SPSS
GUI creators
o XUL
o OpenROAD
Mathematical optimization
o AIMMS
o GAMS
Database-driven GUI application development
o Action Request System
o C/AL
Screen painters and generators
o SB+/SystemBuilder
o Oracle Forms
Web development languages
o CFML
Fifth Generation Language ( 5GL )
ref: Wikipedia
9 Programming for beginner
1.3 Sequential
Programmin
i=5+4
i=i +6
႕ ႕
႕
႕
႕ ႕
10 Programming for beginner
1.4 Variable
variable ႕ ႕
11 Programming for beginner
႕
12 Programming for beginner
Bit and Storage Data on Memory
႕ ႕
-
႕
(2 ^ [Total Bit]) - 1
(2 ^ 8) - 1
= 256 - 1
= 255
13 Programming for beginner
Sign Inte
(2 ^ 31) - 1
= 2147483648 - 1
= 2,147,483,647
႕ ႕
14 Programming for beginner
႕ ႕
႕ ႕ ႕
႕
႕ ႕ ႕
- (2 ^ [Total Bit]) to (2 ^ [Total Bit]) - 1
- (2 ^ 31) to (2 ^31) -1
= − ,147,483,648 to 2,147,483,647
႕
15 Programming for beginner
0 to (2 ^ 32) - 1
= 0 to 4,294,967,295
sign 1 bit exponent 8 bit fractionb 23 bit
binary value 0 01111100 01100000000000000000000
Sign 0
exponenet 01111100
1 + SUM ( i=1 To 23) of b(23-i) 2 ^ -i
1 + 2 ^ -2 + 2 ^ -3 = 1.375
2 ^ (e - 127) = 2 ^ 124-127 = 2 ^ -3
value = 1.375 x 2 ^ -3 = 0.171875
႕
16 Programming for beginner
Character 8 Bit
- Bit (4 Bytes)
- Bit (4 Bytes)
႕ ႕
႕
႕
႕ ႕
႕
17 Programming for beginner
1.5 Operators
+
-
*
/
%
k=5
႕
18 Programming for beginner
5+1=6
6=5+1
k=5+1
႕
19 Programming for beginner
-
20 Programming for beginner
21 Programming for beginner
1.6 Problem Solving
႕
႕
႕ ႕
႕
22 Programming for beginner
႕ user input
႕ ႕
႕
input1 = int(input("Please enter first number: "))
႕ ႕
႕
23 Programming for beginner
string 11 ႕
String int()
႕ loop
24 Programming for beginner
1.7 Installing Python 3
Python programming
language
Download
https://www.python.org/downloads/ Python
႕
Windows
25 Programming for beginner
C:\Python34 python
26 Programming for beginner
27 Programming for beginner
dialog Yes
28 Programming for beginner
Python Install command prompt Python
My Computer Right Click
Properties
29 Programming for beginner
Environment Variables...
30 Programming for beginner
Path select Edit
;C:\Python34 OK semi comman (;) OK
31 Programming for beginner
Linux
python3 -V Python 3.
႕
Mac
python3 -V
႕
Testing Python
႕ Terminal (Mac ,
print("Hello World")
32 Programming for beginner
exit()
helloworld.py
print("Hello World")
save
file terminal
Linux, Mac
python3 helloworld.py
Windows
python helloworld.py
Hello World
python
33 Programming for beginner
Chapter 2 :: Programming
႕
႕ ႕
႕ ႕
34 Programming for beginner
2.1 Pseudo
႕
႕ ႕
႕ ႕ ႕
j pseu ႕
႕ ႕
If student's grade is greater than or equal to 40
Print "passed"
else
Print "failed"
႕
႕ ႕
SEQUENCE
WHILE loop ႕
႕ looping
IF-THEN-ELSE
CASE condition ႕
35 Programming for beginner
FOR while ႕ ႕ FOR
၅
SEQUENCE
Pseu
READ height of rectangle
READ width of rectangle
COMPUTE area as height times width
႕
hei ႕
36 Programming for beginner
႕ Pseudo co
Input: READ, OBTAIN, GET
Output: PRINT, DISPLAY, SHOW
Compute: COMPUTE, CALCULATE, DETERMINE
Initialize: SET, INIT
Add one: INCREMENT, INCREASE, DECREMENT , DECREASE
37 Programming for beginner
2.2 Flow Chart
႕
႕
Terminal
Start , Begin
End , Exit, Return
38 Programming for beginner
Lines with Arrows
Rectangle
႕ ႕
39 Programming for beginner
Decision
40 Programming for beginner
Circle
႕ ႕
႕
41 Programming for beginner
Input/Output
႕ ႕
ref: http://www.rff.com/flowchart_shapes.htm
42 Programming for beginner
2.3 Hello World
Pseudo ႕
print("Hello World")
႕ ႕
႕
43 Programming for beginner
2.4 What is your name
႕
႕
username = input("What is your name ? : ")
print("Your name is ",username)
44 Programming for beginner
2.5 Sum
႕
45 Programming for beginner
x = input("Enter first value : ")
y = input("Enter second value : ")
print("X + Y = ", x + y)
႕ ၅ ႕ ၅
႕ ႕
x = input("Enter first value : ")
y = input("Enter second value : ")
try :
x = int(x)
y = int(y)
print("X + Y = ",x + y)
except ValueError:
print("Please enter number only")
46 Programming for beginner
try , except ႕ try ႕ except
except ValueError:
47 Programming for beginner
2.6 Condition
႕
႕
Print "Enter First Number"
READ firstnum
Print "Enter Second Number"
READ secondnum
if secondnum is less than or equal zero
Print "Second number must be greater than zero"
else
Print firstnum + "divied by " + secondnum
Print firstnum/secondnum
48 Programming for beginner
49 Programming for beginner
50 Programming for beginner
႕
႕
51 Programming for beginner
2.7 Calculator
Print "Enter First Number"
READ firstnum
Print "Enter Operator (+,-,*,/)"
READ operator
Print "Enter Second Number"
READ secondnum
output = true
if operator is + then
result = firstnum + secondnum
else if opeartor is - then
result = firstnum - secondnum
else if opeartor is * then
result = firstnum * secondnum
else if operator is / then
result = firstnum/secondnum
else
Print "Wrong Operator"
output = false
if output == true
Print "Result is " , result
+-*/ boolean
output = true
႕
52 Programming for beginner
53 Programming for beginner
2.8 Looping
prin
For Loop
While Loop
Do While Loop
For Loop
54 Programming for beginner
While Loop
႕
55 Programming for beginner
႕
56 Programming for beginner
Do While Loop
int count = 1;
do {
System.out.println("Count is: " + count);
count = count + 1;
} while (count < 11);
System.out.println
57 Programming for beginner
Exercise
*
**
***
****
*****
1. *
2. *
3. *
4. *
5. *
58 Programming for beginner
၅
59 Programming for beginner
Questions
Code: Q1
total = 0;
for x in range(10):
total = total + x
print(total)
Code: Q2
total = 0;
for x in range(10):
total = total + 1
print(total)
60 Programming for beginner
Quiz
Quiz http://books.saturngod.net/programming_basic/CH2/looping.html
61 Programming for beginner
exerci
62 Programming for beginner
Questions 1
11235
1 1 2 3 5 8 13
Question 2
1 is Odd
2 is Even
3 is Odd
1 is Odd
2 is Even
3 is Odd
4 is Even
5 is Odd
63 Programming for beginner
2.9 Array
issue
Array ?
vari
(ice cube tray ႕
Ref: http://en.wikipedia.org/wiki/Ice_cube
64 Programming for beginner
Example
list[0]
႕
65 Programming for beginner
66 Programming for beginner
A
for each
A
67 Programming for beginner
for each
Immutable And Mutable
T ႕
t = (1,2,3) # immutable
l = [1,2,3] # mutable
68 Programming for beginner
Finding Max Number
Code
Looping
Questions
Max Number Min Number
Array [3,4,1,2,9,7] user array
႕ ႕ user print ႕
႕ print
Max number
print
69 Programming for beginner
2.10 Funcation
႕
70 Programming for beginner
World function function
Hello ႕ HELLO World
Python HELLO Python
code function
71 Programming for beginner
list max number code
72 Programming for beginner
Array code
function
Questions
triangle
*
**
***
၅
73 Programming for beginner
2.11 Exercise Answers
74 Programming for beginner
75 Programming for beginner
76 Programming for beginner
77 Programming for beginner
Chatper 3 :: Object Oriented
j
S
3.1 Overview
j
j
႕
႕ ႕
j
func j
78 Programming for beginner
3.2 Classes
j -
Defining a Class
class ClassName:
class animal:
class animal:
number_of_legs = 0
Instances
class animal:
number_of_legs = 0
dog = animal()
79 Programming for beginner
dog.number_of_legs
80 Programming for beginner
dog chicken object
print
Function in Class
class function (self) ႕
class variable
81 Programming for beginner
3.3 Inheritance
႕
j
႕
႕
႕
pytho
j
႕
82 Programming for beginner
Chapter 4: DataStructure
4.1 Basic Data Structures
Data Strucutre ႕
4.2 What is a Stack ?
stack
LIFO (last-in-first-out)
python
javascript
css
html
Data Structure
python
javascript
css
html
83 Programming for beginner
4.3 Stack Abstract Data Type
stac
Stack()
push(item) stack
pop()
peek()
is_empty()
size()
84 Programming for beginner
4.4 Implementing A Stack
__init__(self) j
Object
j ႕
len(self.items) ႕
85 Programming for beginner
- The End -