Anaconda
adalah salah satu distribusi Python dan R yang paling populer untuk komputasi
ilmiah dan analisis data. Dengan Anaconda, kamu mendapatkan paket-paket yang
berguna untuk machine learning, data science, serta berbagai library yang
mempermudah pekerjaan pemrograman. Pada artikel ini, kita akan membahas
langkah-langkah untuk menginstal Anaconda di Windows, Mac, dan Linux.
1. Apa itu Anaconda?
Anaconda
adalah platform open-source yang menyediakan semua yang kamu butuhkan untuk
bekerja dengan data, termasuk Python atau R, Jupyter Notebook, dan banyak paket
serta tool lainnya. Anaconda sangat memudahkan untuk membuat lingkungan virtual
dan mengelola paket dengan conda, manajer paket dan lingkungan dari Anaconda.
2. Tahapan Instalasi Anaconda di Windows
Langkah 1: Unduh Anaconda
- Buka website resmi Anaconda.
- Klik tombol Download
sesuai dengan sistem operasi yang kamu gunakan (Windows).
- Pilih versi Python (biasanya
versi terbaru disarankan) dan klik Download untuk Windows.
Langkah 2: Jalankan File Installer
- Setelah file installer
diunduh, buka file installer (.exe).
- Di jendela instalasi, pilih Install
for: Just Me (tidak memerlukan hak admin).
- Klik Next dan pilih
lokasi instalasi. Biasanya, biarkan pengaturan default.
- Pastikan kamu mencentang
opsi Add Anaconda to my PATH environment variable (opsional namun
berguna), lalu klik Install.
Langkah 3: Verifikasi Instalasi
- Buka Anaconda Navigator
atau Anaconda Prompt dari menu Start.
- Ketik perintah berikut di Anaconda Prompt untuk memastikan instalasi berjalan dengan baik:
3. Tahapan Menjalankan Jupyter Notebook pada Anaconda
1. Buka Anaconda Navigator
Setelah menginstal Anaconda, langkah pertama untuk menjalankan Jupyter Notebook adalah membuka Anaconda Navigator atau Anaconda Prompt. Keduanya memberikan akses langsung ke Jupyter.
- Cari Anaconda Navigator
di menu Start (Windows) atau Launchpad (Mac).
- Setelah Anaconda Navigator terbuka, kamu akan melihat beberapa aplikasi. Cari ikon Jupyter Notebook dan klik tombol Launch.
2. Buat atau Pilih Direktori Kerja
Setelah
Jupyter Notebook terbuka di browser, kamu akan dibawa ke halaman yang
menunjukkan struktur file di komputermu. Di sini, kamu bisa memilih direktori
kerja atau folder tempat kamu ingin menyimpan proyek.
- Pilih direktori di sidebar atau klik folder
yang sudah ada.
- Untuk membuat folder baru,
klik tombol New di pojok kanan atas dan pilih Folder.
Jupyter
Notebook akan bekerja dalam direktori yang kamu pilih, jadi pastikan folder
tersebut adalah tempat yang tepat untuk menyimpan file proyekmu.
3. Buat Notebook Baru dan Mulai Coding
Setelah
berada di direktori yang benar, saatnya membuat notebook baru untuk menulis dan
menjalankan kode Python.
Langkah-langkah Membuat Notebook Baru:
- Klik tombol New di
pojok kanan atas halaman.
- Pilih Python 3 (atau
versi Python yang kamu gunakan) dari daftar pilihan kernel.
Notebook
baru akan terbuka dalam tab baru di browser, dan kamu bisa langsung mulai
menulis kode di cell pertama.
tugas Big Data & Business Intelligence
Variable & Data Type
1- Saving Values
In the first mission, we learned the basics of Python programming and performed a few arithmetical operations using Python. In this mission, we'll learn how to save values, and how to work with numerical and text data.
Let's say we want to save the result of an arithmetical operation for later work. For instance, (8 + 2) * 2 equals 20, and we want to save 20. This is the code we need to run to save 20:
If we print the name result, the output is 20:
We can also save directly (8 + 2) * 2 instead of saving 20.
Notice, however, that print(result) outputs 20, not (8 + 2) * 2. This is because the computer first calculates (8 + 2) * 2 and then saves the result 20 to result.
Now let's do a quick exercise and resume this discussion in the next screen.
Instructions
Save the result of (42 - 11) * 22 to result.
Print result.
2. Variables
Previously, we saved 20 to result.
When we run the code result = 20, the value 20 is saved in the computer memory. The computer memory has many storage locations, and 20 is saved to one particular location.
The storage location to which we saved 20 has a unique identifier, and we can use it to access 20. The identifier is named result, and we named it that way when we ran the code result = 20. We can use the identifier result to access 20 in other lines of code:
The storage location for 20 is more commonly known as a variable. When we ran the code result = 20, we stored 20 in a variable (storage location) named result — so result is a variable name.
Note that we need to write the variable name to the left of the = operator and the value we want to store to the right. So if we want to store the value 20 to a variable named result, we must write result = 20, not 20 = result.
We chose the name result arbitrarily, but we could have chosen something different:
Now let's get more practice with variables.
Instructions
Store the value 15 in a variable named a_value.
Store the result of (25 - 7) * 17 to a variable named a_result.
Using the print() command, display the following:
The value stored in the a_value variable.
The result of adding 12 to the variable a_result.
The result of adding a_value to a_result.
Output:
- 15 (The value of
a_value) - 330 (The result of
(25 - 7) * 17 + 12) - 288 (The result of
15 + (25 - 7) * 17)
Explanation:
- a_value = 15 stores the number 15.
- a_result = (25 - 7) * 17 calculates the expression (25 - 7) * 17, which equals 306.
- Then the
print()commands display the required outputs based on the instructions.
3- Variable Names
In the last screen, we learned that we can choose different names for variables. However, the names we can use must comply with a number of syntax rules. For instance, naming a variable a result will output a syntax error because we're not allowed to use space characters in variable names.
These are the two syntax rules we need to be aware of when we're naming variables:
We must use only letters, numbers, or underscores (we can't use apostrophes, hyphens, whitespace characters, etc.). Variable names cannot start with a number.
Note that variable names are case sensitive, which means that a variable named result is different than a variable named Result:
Now let's try to correct a few variable names.
Instructions
In the code editor on the right, we attempted to store 34000 in a variable named old-income, and 40000 in a variable named new income. But both of these variable names cause syntax errors, so we commented-out the code.
Change the variable name old-income to old_income to prevent a syntax error.
Change the variable name new income to new_income to prevent a syntax error.
Remove the # from each line so that the code will run, then run the code.
Explanation:
- The original variable names
old-incomeandnew incomecaused syntax errors because variables cannot contain hyphens or spaces. - By changing
old-incometoold_incomeandnew incometonew_income, the syntax error is fixed.
4. Updating Variables
The value stored in a variable can be updated. Below, we first store 30 in the variable x, and then we update x to store 70 instead.
We can also update a variable by doing arithmetical operations:
Notice in the code above that:
The variable x initially stores a value of 30. x + 70 evaluates to 100 because x stores a value of 30 — so x + 70 becomes 30 + 70. When we run x = x + 70, x is updated to store the result of x + 70, which is 100. Running x = x + 70 is the same as running x = 30 + 70 because x stores 30. print(x) outputs 100 after we run x = x + 70. Now let's get a little practice with updating variables.
Instructions
Update the variable income by adding 6000 to its current value.
The variable income is already shown in the code editor on the right.
Print income.
Komentar
Posting Komentar