You are on page 1of 20

MK Algoritma dan Pemrograman

Sekolah Vokasi IPB


 Sesuatu yang diperlukan prosesor harus ditempatkan di memori
 Data yang kita gunakan di program tersimpan di memori
 Nama variabel merupakan rujukan ke alamat memori
 Konsep mutability di Python
 Mutable = isi alamat memori dapat diubah
 Immutable = isi alamat memori tidak dapat diubah

 Immutable != konstanta
Nama Literal/Nama
Variabel Variabel/Ekspresi
a 5678
_var 1.25
X1 "Berikan"
Var-1 = 'abc'
1x _var
X 1 a + 3
abc
"Hello" 5678
1234 "abc"
print( 5678 , 1234 ... )
_var 5678
a + _var _var
Variabel Prompt string
Penampung
a "Berikan masukan:"

_var = input( X1 )

X1 X1 + " masukan:"
 A comment in a computer program is text that is intended only for
the human reader - it is completely ignored by the interpreter.
 In Python, the # token starts a comment.
 Three kinds of errors can occur in a program: syntax errors, runtime
errors, and semantic errors
Semantic errors ?

Syntax errors ?
 2.1. Variables, Expressions and Statements
 2.2. Values and Data Types
 2.3. Type conversion functions
 2.4. Variables
 2.5. Variable Names and Keywords
 2.6. Statements and Expressions
 2.7. Operators and Operands
 2.8. Input
 2.9. Order of Operations
 2.10. Reassignment
 2.11. Updating Variables
 https://youtu.be/1uQM-TVlaMo
 Assisgment operator
Apa hasilnya ?
 They can contain both letters and digits
 they have to begin with a letter or an underscore
 Bruce and bruce are different variables
 Variable names can never contain spaces
 The underscore character ( _) can also appear in a name.
 It is often used in names with multiple words, such as my_name or price_of_tea_in_china

 Python keywords, cannot be used as variable names

Salah
Apa hasilnya ?
Perhatikan

07/09/2020 19
Jangan lupa berlatih lagi

https://runestone.academy/runestone/static/AlproD3/index.html

You might also like