Friday, May 10, 2024

Python Beginner - Module 3 - Dave & Alison 01

 Kita sudah membuat summary untuk Module 1 dan 2 dari Alison Course dan video 1, 2, 3 dan 4 dari Dave Gray.


Image of Python for Beginners (credit to Google)


Boolean
True: 1
False: 0

and
0   0 ...> 0
0   1 ...> 0
1   0 ...> 0
1   1 ...> 1

or
0   0 ...> 0
0   1 ...> 1
1   0 ...> 1
1   1 ...> 1

XOR ---> Exclusive OR
0   0 ...> 0
0   1 ...> 1
1   0 ...> 1
1   1 ...> 0

True or False: Boolean variable values can only be either true or false.
- True
----------------------------------------------

Module 3 - Chapter 2

Ini adalah chapter tentang "conditions" di Python.

== ...> equal to
!= ...> not equal to
>...> greater than
< .... less than
>= ... greater than equal to

minMarks = 30
studentMarks = float(input('enter your mark: '))
 
if studentMarks > minMarks:
    print("you are eligible")
else:
  print("you are not eligible")
Run Python File:
enter your mark: 40
you are eligible

enter your mark: 12
you are not eligible


elif studentMarks >= 25:
minMarks = 30
studentMarks = float(input('enter your mark: '))
 
if studentMarks > minMarks:
    print("you are eligible")
elif studentMarks >= 25:
   print("you have been put in waiting list")25
else:
  print("you are not eligible")
Run Python File:
enter your mark: 25
you have been put in waiting list

enter your mark: 31
you are eligible

urutan:
if
elif
else

Which of these are conditional operators in Python? Choose three.
- equal to
- greater than
- less or equal to
----------------------------------------------

Module 3, Chapter 3

Ada dua type Loops:
1) Iterative
- doing over and over or repetition.
- for

2) Conditional
- while

# Iteration / for loop
for i in 'string':
    print(i)

# conditional / while loop
i = 1
while i <= 50:
    print(i)
    i += 1 # i = i + 1
Run Python File:
s
t
r
i
n
g
1
2
3
.
.
.
49
50

Which of these is used to denote a list in Python? Choose one.
- [ ]
-------------------------------------------------------

Module 3, Chapter 4

List adalah connection of similar objects

print(fruits)
fruits = [
    'apple', # 0
    'banana', # 1
    'pear', # 2
    'strawberries', # 3
]
print(fruits)
Run Python File:
['apple', 'banana', 'pear', 'strawberries']

print(fruits[2])
fruits = [
    'apple', # 0
    'banana', # 1
    'pear', # 2
    'strawberries', # 3
]
print(fruits[2])
Run Python File:
pear

print(fruits[:2])
fruits = [
    'apple', # 0
    'banana', # 1
    'pear', # 2
    'strawberries', # 3
]
print(fruits[:2])
Run Python File:
['apple', 'banana']
-----------------------------------------

Module 3, Chapter 5

Mari kita mempelajari List operation

We can change value from 'd' to 'c'
characters = ['a', 'b', 'd', 'd']
print(characters)
characters [2] = 'c'
print(characters)
Run Python File:
['a', 'b', 'd', 'd']...> there are two 'd'

['a', 'b', 'c', 'd']...> 'd' is replaced by 'c'

>>> characters = ['a', 'b', 'd', 'd']
>>> len(characters)
4

>>> characters.append('f')
>>> characters
['a', 'b', 'd', 'd', 'f']
>>> characters.remove('f')       
>>> characters
['a', 'b', 'd', 'd']

['a', 'b', 'd', 'd']
>>> characters.pop(3)
'd'

>>> 'b' in characters
True
>>> 'z' in characters
False

Which of these is not one of the list operations in Python? Drag the correct answer into the space provided.
- characters.insert()
-----------------------------------------------------------------------

Module 3, Chapter 6
Bubble Sort:

Bubble sort adalah simple sorting algorithm

list = [8, 3, 1, 4]
print("Original list:", list)

length = len(list)
for i in range(length):
    for j in range(0, length - i - 1):
        if list[j] > list[j + 1]:
            list[j], list[j + 1] = list[j + 1], list[j]

print("Sorted list (ascending order):", list)
Run Python File:
Original list: [8, 3, 1, 4]
Sorted list (ascending order): [1, 3, 4, 8]
-----------------------------------------------

Module 3, chapter 7

Beberapa operators akan kita pelajari
>>> a = 12
>>> if (a > 6) and (a < 20):
...     print(a)
... 
12

Q1: cari binary angka 13
- bagi angka 13 dengan 2: 13/2= 6 ...> reminder 1....> first binary.
- then, 6/2 = 3 ...> reminder 0 ...> second binary
- then, 3/2 = 1 ...> reminder 1 ...> third binary
- kemudian, 1/2 = 0 ...> `reminder 1 ...> fourth binary
Untuk mengetahui binary angka 13, dilihat dari bawah (belakang) atau dari langkah ke 4 (fourth binary): 1101

>>> bin(13)
'0b1101' ...> 1101


Q2: cari angka berapa dari binary 0b1100 atau 1100?
- mulai dari sebelah kanan, yaitu 0
- decimal equivalent 0 = 0 x 2^0 = 0
-  decimal equivalent 0 = 0 x 2^1 = 0
- decimal equivalent 1 = 1 x 2^2 = 4
- decimal equivalent 1 = 1 x 2^3 = 8
Then, 0 + 0 + 4 + 8 = 12

Q3: 12|13 ...> 12 or 13
binary 12 = 1100
binary 13 = 1101
-------------------------------
                = 1101
Convert to value from right: 1(2*0) + 0(2*1) + 1(2*2) + 1(2*3) = 1+0+4+8 = 13
proved by VSC: 
>>> 12|13
13

Q4, Now find 12&13
binary 12 = 1100
binary 13 = 1101
--------------------------
                = 1100
convert to value from right: 0(2*0) + 0(2*1) + 1(2*2) + 1(2*3) = 0 + 0 + 4 + 8 =12
proved by VSC:
>>> 12 & 13
12

Q5, find 12 xor 13
>>> 12 ^ 13
1

True or False: A bubble sort consists of three types of loop.
- False
- True: one type of loop.
 
The followings are the key points from this module:
Boolean logic refers to the idea that all values are either true or false. 

Some boolean operations that were examined include:
and
or
Xor

Some conditional operators that were mentioned include:
Equals to which is written as ==. 
Not equals to which is written as !=. 
Greater than and Less than which are written as > and < respectively. 
Greater than or equals to which is written as >=. 
Less than or equals to which is written as <=. 

The following are the two types of Loops examined in this module: 
Iterative loop (For loop). 
Conditional loop (While loop). 

Lists are collections of similar objects and are denoted with "[  ]". 

The different operations that can be run on lists include: 
Changing character(s) of a list. 
Len (characters) -- To check the length of a list. 
character.append ('e') -- To add the character "e" to the end of a list.
character.reverse -- To reverse the order of characters in a list.

Bubble Sort refers to a simple algorithm that goes over an array and sorts it into the correct order. 



==============================================
==============================================

Dave Gray

Lesson 5/24


Kita akan mempelajari user input dan control flow

import random

print("Rock, Paper, Scissors Game")
print("1 for Rock, 2 for Paper, or 3 for Scissors")

playerchoice = input("Enter your choice (1/2/3): ")
player = int(playerchoice)

if player < 1 or player > 3:
    sys.exit("You must enter 1, 2, or 3.")

computerchoice = random.choice(["1", "2", "3"])
computer = int(computerchoice)

print("\nYou chose:", playerchoice)
print("Python chose:", computerchoice)
Run Start Debugging:

Rock, Paper, Scissors Game
1 for Rock, 2 for Paper, or 3 for Scissors
Enter your choice (1/2/3): 1

You chose: 1
Python chose: 3







JJJJJJJJJJJJJJJJJJ


JJJJJJJJJJJJJJJJJJ

Tuesday, May 7, 2024

Python Beginner - Module 2 - Dave & Alison 01

 Kita sudah mempelajari module 1 (Up Grade Live: Python Beginner - Module 1 - Dave & Alison 01) dan video 1&2 dari Dave Gray.


Image Beginner (credit to Google).

Sekarang kita akan mempelajari Module 2 dan video 3 & 4 (Python Operators for Beginners | Python tutorial - YouTube) dari Dave Gray).

Anda juga bisa belajar dari sumber ini:  freeCodeCamp.org - YouTube. Sebagai tambahan.

Module 2, Chapter 1
First Program

In Python, which of these functions will display the phrase "Hello John" to the user? Choose one.
* print("Hello John")
-------------------------------------

Module 2, Chapter 2
Variables ---> somethings can change

What term refers to a reserved memory location to store value(s) and serves as a reference or pointer to the value(s) stored in it? Choose one.
- Variables
---------------------------------------

Data type: 

Integer: 0, 1, 2, -1, 12, 34
12.0 ...> not integer, but float
12.0 ...> anything with decimal is not integer.

Float ...> Anything with decimal: 12.0, 3.14, 23.1, -3.68

String ...> collection of different characters
"12" ...> string, not integer.
"name", 'John', 

Boolean ...> values, either True or False

Which of these are data types available in Python? Choose three.
- floats
- strings
- integers
-----------------------------------------

Module 2, Chapter 4


Create variable:
True or False: To create a variable, you just declare it by assigning a value to it.
- True
-------------------------------------------------

Module 2, Chapter 5

number = "12"
print(type(number))
Run Python File:
<class 'str'>
Note: 12..> integer, but "12"..>String

Change from String to Integer
number = "12"
print(type(number))
number = int(number)
print(type(number))
Run Python File:
<class 'str'>
<class 'int'>

Change from string to integer to float
number = "12"
print(type(number))
number = int(number)
print(type(number))
number = float(number)
print(type(number),number)
Run Python File:
<class 'str'>
<class 'int'>
<class 'float'> 12.0

A representation such as "12" with the quotation marks in Python will be classified under what kind of data? Choose one.
- String
-------------------------------------------

Module 2, Chapter 6
User Input

age = input('enter your age : ')

print('you are ' + str(age) + ' years old')
Run Python File:
enter your age : 59
you are 59 years old

name = input('enter your name : ')
print('Hello, ' + name)
Run Python File:
enter your name : Atun
Hello, Atun

True or False: The Input() function is the one used to receive data from users.
- True
------------------------------------------------------------------

Module 2, Chapter 7

a = 9
b = 2
a/b = 4.5
a//b = 4 
Note: // is "floor division": 3//1.6 = 1.88 = 1

a**b = 9**2 = 81

% = module = mod...> reminder after division.
9%2 = 4+1 .....> reminder = 1
8%2 = 0 ...> reminder = 0

print('welcome to super simple calculator')
a = float(input('enter first number : '))
b = float(input('enter second number : '))
print('your answer is', a + b)
Run Python File:
enter first number : 1.5
enter second number : 19.5
your answer is 21.0


In Python calculations when a = 5, and b = 2. What value will a//b return? Choose one.
- answer: 2


The followings are the key points from this module:

Functions are predefined procedures in a programming language where you can pass certain arguments to them and they will carry out the instructions from the arguments. 

'.py' is the extension that all Python files carry. 

Variables are data holders that you can use as containers to save data which you can refer to later in programing instead of actually writing such specific data several times. 

The different types of data mentioned in the module include:
Integers - These are whole numbers that don't carry decimals. e.g. 1, 6, 52, 105, etc.
Floats - These are the numbers with decimals. e.g. 12.0, 20.351, 15.105112, 2.05, etc.
Strings - These are collections of any and/or different characters. e.g. 0, 52, ABC, *, &, #, John, etc. 
Boolean - This is a value that is either true or false.

=======================================
=======================================

Dave Gray : Python for Beginner


We start with assignment operators
Di new terminal> python3, maka akan muncul: >>> ....> sign of REPL

>>> meaning = 42
>>> meaning
42

>>> 24%5
4 ...> reminder : 24%5 = 4+4

>>> 24%3
0 ...> reminder: 24%3 = 8 + 0 

>>> 2 ** 3 ---> two power 3
8

sign equal to: ==
42 == 42
True

sign not equal to: !=
42 !=42
False

42 != 43
True

Value of meaning = 42
meaning = 42
print('')

if meaning > 10:
    print('Right on!')
else:
    print('Not today!')
Run Python File:
Right on!

Changed value of meaning to be 8
meaning = 8
print('')

if meaning > 10:
    print('Right on!')
else:
    print('Not today!')
Run Python File:
Not today!
-------------------------------------------------------------------

Dave Gray : Python for Beginner


We start with data type:
# literal assignment
first = "Dave"
last = "Gray"

print(type(first))
Run Python File:
<class 'str'>

# Escaping Special Characters
sentence = 'I\'m back at work!\tHey!\n\nwhere\'s this at\\located?'
print(sentence)
Run Python File:
I'm back at work!       Hey!

where's this at\located?


# String Methods
print(first)
print(first.lower())
print(first.upper())
print(first)
Run Python File:
Dave
dave
DAVE
Dave

# build a menu
title = "menu".upper()
print(title.center(20, "="))
Run Python File:
========MENU========




JJJJJJJ

Monday, May 6, 2024

Python Beginner - Module 1 - Dave & Alison 01

Posting ini hanya summary dari kursus online yang diadakan oleh Alison dan Dave Gray. Anda bisa mengakses dua kursus ini, silahkan searching melalui Google


Image - Beginner (credit to Google)

Module 1, The Basic of Phyton.

Python is high level programming language....> Universal language.
- can be used to do almost many tasks.
- python developer -----> US$ 120,000

True/False: Python is a non-universal programming language.
- False

Which of these are examples of what Python can be used for? Choose three.
- automation
- game development
- data analysis
-------------------------------------------------

Module 1, Chapter 2
What is coding?

Computer can't understand "code," but understand "binary" such as 010101 ......

Compiler .....> executed all codes (all lines of codes).
Interpreter ....> just execute true codes ....> true lines.

What do you call a set of instructions that a computer follows to perform a certain task, at a certain time, and in a certain way? Choose one.
- program

Which of these are the kinds of programs? Drag the correct answer into the space provided.
- compiler and interpreter program
-------------------------------------------------------------

Module 1, Chapter 3
Basic set up

True/False: Python has several versions and you have to choose one that matches the operating system of your computer.
- True

The following are the key points from this module are:
Python is a dynamically typed, high level, interpreted programming language which has easy syntax.

The following are some of the things Python can be used for:
Game development.
Data analysis.
Automation.

Python is a universal programming language.
A Program is a set of instructions for the computer telling it to do a certain task at a certain time and in a certain way. 

The two different kinds of programs mentioned include: 
Compiler programs.
Interpreters program. 
====================================

Module 2, Chapter 1


===========================================
===========================================


Tutorial 1/24: 
>>> ...> command prompt

Low level language ...> Machine oriented
High level language ...> use interpreter ...> Python

>>> name = 'Dave'
>>> name
>>> 'Dave'
>>> quit()
----------------------------------------------------------------


Welcome file: 
Shif+Alt+down arrow ...> Copy
line01 = "********************"
line02 = "*                  *"
line03 = "*     WELCOME!     *"

print('')
print(line01)
print(line02)
print(line03)
print(line02)
print(line01)
Run Python File:
*********************
*                           *
*    WELCOME!   *
*                           *
*********************



           
JJJJJJJ
JJJJJJJJJ

Sunday, May 5, 2024

Ethical Hacking Diploma - Module 01 - Alison 02

 Ethical hacking adalah parktik untuk men-testing system komputer, network atau software sehingga diketahui dimana letak kelemahannya yang bisa ditembus oleh "hacker." 


Image - Ethical Hacking (credit to Google)

JJJJJJJJJJJ
Ethical hacking is the practice of testing a computer system, a network or an application to find security vulnerabilities that could be exploited by criminal hackers. Ethical hackers u
ion from the owner of the system being tested.



JJJJJJJJJJJJJJJJ

JJJJJJJJJJJJJJJJJ