Tutorial Python untuk bukan pengatur cara/Hello, World: Perbezaan antara semakan

Kandungan dihapus Kandungan ditambah
Algazel (bincang | sumb.)
Tiada ringkasan suntingan
Algazel (bincang | sumb.)
Tiada ringkasan suntingan
Baris 99:
 
<!-- Sorok sementara -->
 
<!--
Dalam contoh ini, perintah <tt>print</tt> disusuli dua argumen, dengan setiap argumen dipisahkan dengan tanda koma. Jadi dengan baris pertama program
In this example, the print command is followed by two arguments, with each of the arguments separated by a comma. So with the first line of the program
 
<source lang="python">
print "2 + 2 isialah", 2 + 2
</source>
 
TheArgumen firstpertama argument is theialah string <code>"2 + 2 isialah"</code> anddan theargumen secondkedua argument is theialah ''mathematical expression'' (ungkapan matematik) <code>2 + 2</code>, whichyang islazimnya commonly referred to as andisebut ''expression'' atau ungkapan.
 
Apa yang perlu diperhatikan ialah sebuah <tt>string</tt> dicetak seperti yang tertulis (string ialah apa yang terkandung dalam kurungan dua tanda petikan tetapi tidak termasuk tanda petikan itu sendiri. Jadi string dicetak tanpa tanda petikan berganda). Akan tetapi, sebuah ''ungkapan'' akan dinilai (dalam kata lain, ditukar) kepada nilai sebenarnya.
What is important to note is that a string is printed as is (the string is what is within the double quotes but doesn't include the double quotes themselves. So the string is printed without the enclosing double quotes.) But an ''expression'' is ''evaluated'', (in other words, converted) to its actual value.
 
Python hasmempunyai sixenam basicoperasi operationsasas forbagi numbersnombor:
 
{| class="wikitable"
! Operasi
! Operation
! SymbolSimbol
! ExampleContoh
|-
|Kuasa (eksponen)
|Power (exponentiation)
| <code>**</code>
| <code>5 ** 2 == 25</code>
|-
|Darab
|Multiplication
| <code>*</code>
|<code>2 * 3 == 6</code>
|-
|Bahagi
|Division
| <code>/</code>
| <code>14 / 3 == 4</code>
|-
|RemainderBaki (''modulo'')
| <code>%</code>
| <code>14 % 3 == 2</code>
|-
|Tambahan
|Addition
| <code>+</code>
| <code>1 + 2 == 3</code>
|-
|Penolakan
|Subtraction
| <code>-</code>
| <code>4 - 3 == 1</code>