Professional Documents
Culture Documents
Laboratory Work
using Python
Praktikum Komputasi
Minggu I
Semester II – Tahun Ajaran 2021/2022
Tujuan Instruksional Umum
• Menyusun program komputer untuk menghitung kasus-kasus teknik kimia.
Mampu menggunakan metode data processing
15 Tugass 10
Teori & coding penyelesaian persamaan non
linier multi variabel
Pengantar Tugas 11 persamaan non linier
multivariabel
16 Penutup Tugas 11
17
Ujian Akhir Semester
Penilaian
• Praktikum pemrograman: 11 tugas
• UTS dan UAS
• Presensi kuliah 75% (ketentuan UGM)
Our python is not a snake, but …
What is Python?
Interpreter Compiler
Translate program one statement at a Scans the entire program and translates it
time. as a whole into machine code.
It takes less amount to analyze the source It takes large amount of time to analyze
code but the overall execution time is the source code but the overall execution
slower. time is comparatively faster.
16 12 MATLAB 0.794%
Who use Python?
• Large organizations that use Python include CERN (the European Organization
for Nuclear Research), NASA, Wikipedia, Google, Yahoo!, Facebook, Amazon,
Instagram, Spotify.
• The social news networking site Reddit is written entirely in Python.
The Python platform: Spyder on Anaconda
(‘Hello World!’)
Python installation …
• Sebagai perangkat lunak berbasis OPEN SOURCE, tersedia berbagai alternatif
aplikasi untuk menjalankan bahasa pemrograman Python.
• Untuk keperluan komputasi ilmiah, aplikasi yang direkomendasikan adalah
ANACONDA.
• ANACONDA merupakan paket aplikasi lengkap, di mana berbagai library Python
untuk komputasi ilmiah sudah tersedia dalam satu wadah.
Python on Anaconda installation …
• Unduh installer dari Anaconda Distribution (The World's Most Popular Python/R
Data Science Platform)
• Buka website: anaconda.com
• Klik Download
Pilih 64-Bit atau 32-Bit tergantung jenis komputernya. Komputer baru biasanya 64 bit, namun
kalau tidak yakin, pilih saja 32-Bit (Anaconda 32 bit bisa jalan di komputer 32/64 bit namun
Anaconda 64 bit hanya bisa jalan di komputer 64 bit).
Anaconda installation …
• Install Anaconda.
• Selesai instalasi, jalankan Anaconda Navigator
Spyder launching …
Editor:
Tempat menuliskan kode
pemrograman
Console:
Tempat menampilkan output program.
Spyder Editor
Tanda # untuk
komentar
np.pi =
np.sin( ) =
Trigonometric functions
Numpy Function Trigonometric function
sin( ) Trigonometric sine
cos( ) Trigonometric cosine
tan( ) Trigonometric tangent
arcsin( ) Inverse trigonometric sine
arccos( ) Inverse trigonometric cosine
arctan( ) Inverse trigonometric tangent
degrees( ) Convert angles from radians to degrees
radians( ) Convert angles from degrees to radians
pi 3.141592653589793
Exponents and logarithms
Numpy Function Exp & log function
exp( ) Calculate the exponential
log( ) Natural logarithm
log10( ) Return the base 10 logarithm
log2( ) Base-2 logarithm
e 2.718281828459045
Miscellaneous functions
Numpy Function Function
sqrt( ) Return the positive square-root
absolute( ) Calculate the absolute value
square( ) Return the square value
round( ) Round an array to the given number of decimals
fix( ) Round to nearest integer towards zero
floor( ) Return the floor of the input (rounded downwards)
ceil( ) Return the ceiling of the input (rounded upwards)
Variables
a. ingat
Kunci:
a. 0.42261826174069944; b. 0.6745085168424266
c. -0.15051499783199057; d. 1.3671101706955464
Contoh coding 01
• Buatlah program untuk menghitung konversi suhu 40F ke Celcius!
Contoh coding 02
• Seorang mahasiswa pergi ke kampus dengan sepeda motor berkecepatan rata-rata
39 km/j. Jarak dari rumahnya ke kampus 21 km. Jika ia berangkat dari rumah
pukul 06:27, hitunglah pukul berapa ia sampai di kampus. Hitung sampai dua
angka desimal untuk detiknya.
Matplotlib
Plotting in Python
Plotting with matplotlib
• Matplotlib is probably the most popular Python plotting library
• If you are familiar with Matlab plotting then matplotlib is very easy to learn!
• Plots can be made from lists, tuples, numpy arrays, etc.
Contoh coding 03: Simple plot
• Buatlah grafik untuk
Contoh coding 04
• Buatlah grafik dan untuk dalam satu gambar.
Contoh coding 05
• Buatlah grafik dan untuk dalam gambar terpisah.
Matplotlib is a very powerfull plotting tool!
Complete tutorial : https://matplotlib.org/
Referensi