SKA#1 Dasar | Python

This entry is part 3 of 12 in the series SK A Grade Mahasiswa

Contoh kasus A artikel ke-2 untuk bahasa pemrograman python

Berikut adalah contoh kode dalam bahasa pemrograman python untuk menghitung grade nilai seorang mahasiswa berdasarkan Studi Kasus A.

bobot_hadir = 0.15
bobot_tugas = 0.25
bobot_uts = 0.3
bobot_uas = 0.3

nilai_hadir = 100
nilai_tugas = 82
nilai_uts = 60
nilai_uas = 55

nilai_akhir = bobot_hadir * nilai_hadir + bobot_tugas * nilai_tugas + bobot_uts * nilai_uts + bobot_uas * nilai_uas

grade = 'E'
if nilai_akhir >= 85:
    grade = 'A'
elif nilai_akhir >= 70:
    grade = 'B'
elif nilai_akhir >= 50:
    grade = 'C'
elif nilai_akhir >= 40:
    grade = 'D'

print('Nilai akhir= {}, grade= {}'.format(nilai_akhir,grade))

Penjelasan

Berikut adalah beberapa penjelasan tentang cuplikan kode program di atas:

  • Bagian awal (baris 1-4) berisi deklarasi variabel untuk menampung bobot penilaian untuk setiap komponen penilaian
  • Bagian berikutnya (baris 6-9) berisi deklarasi variabel untuk menampung nilai mahasiswa pada masing-masing komponen
  • Baris 11 berisi kalkulasi nilai akhir mahasiswa
  • Bagian sisanya berisi kode untuk menentukan grade yang sesuai dengan nilai akhir mahasiswa
Series Navigation<< SKA#1 Dasar | JavaSKA#2 Method | Java >>

You may also like...

Berikan komentar

Belajar koding untuk pemula
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.