Skip to content

Commit a435610

Browse files
committed
update
1 parent bdc97a0 commit a435610

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

.swp

12 KB
Binary file not shown.
6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"editor.fontSize": 20,
3+
"terminal.integrated.fontSize": 18,
4+
"window.zoomLevel": 2,
5+
"editor.tabSize": 4,
6+
"workbench.iconTheme": "vscode-icons",
7+
"workbench.colorTheme": "Noctis Minimus",
8+
"editor.minimap.enabled": false,
9+
"python.pythonPath": "/Users/faqihza/.pyenv/versions/3.9.1/bin/python"
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
'''Program data mahasiswa menggunakan dictionary'''
2+
import datetime
3+
import os
4+
import string
5+
import random
6+
7+
# fungsi Header
8+
def header():
9+
# os.system("cls") # untuk windows
10+
os.system("clear")
11+
print(f"{'SELAMAT DATANG':^20}")
12+
print(f"{'DATA MAHASISWA':^20}")
13+
print(f"{'TAHUN 2045':^20}")
14+
print("-"*20)
15+
16+
# template dict mahasiswa
17+
mahasiswa_template = {
18+
'nama':'nama',
19+
'nim':'00000000',
20+
'sks_lulus':0,
21+
'lahir':datetime.datetime(1111,1,11)
22+
}
23+
24+
data_mahasiswa = {}
25+
26+
while True:
27+
28+
header()
29+
mahasiswa = dict.fromkeys(mahasiswa_template.keys())
30+
mahasiswa['nama'] = input("Nama Mahasiswa: ")
31+
mahasiswa['nim'] = input("NIM Mahasiswa: ")
32+
mahasiswa['sks_lulus'] = int(input("SKS Lulus: "))
33+
TAHUN_LAHIR = int(input("Tahun lahir (YYYY): "))
34+
BULAN_LAHIR = int(input("Bulan lahir (1-12): "))
35+
TANGGAL_LAHIR = int(input("Tanggal lahir (1-31): "))
36+
mahasiswa['lahir'] = datetime.datetime(TAHUN_LAHIR,BULAN_LAHIR,TANGGAL_LAHIR)
37+
38+
KEY = ''.join((random.choice(string.ascii_uppercase) for i in range(6)))
39+
data_mahasiswa.update({KEY:mahasiswa})
40+
41+
# dari tutorial sebelumnya, hilangkan beasiswa
42+
# print(f"\n{'KEY':<6} {'Nama':<17} {'NIM':<8} {'SKS Lulus':<10} {'Tanggal Lahir':<10}")
43+
# print('-'*60)
44+
45+
for mahasiswa in data_mahasiswa:
46+
KEY = mahasiswa
47+
NAMA = data_mahasiswa[KEY]['nama']
48+
NIM = data_mahasiswa[KEY]['nim']
49+
SKS = data_mahasiswa[KEY]['sks_lulus']
50+
LAHIR = data_mahasiswa[KEY]['lahir'].strftime("%x")
51+
52+
print(f"{KEY:<6} {NAMA:<17} {NIM:<8} {SKS:^10} {LAHIR:^10}")
53+
54+
print("\n")
55+
is_done = input("Mau tambah lagi bro (y/n)? ")
56+
if is_done == "n":
57+
break
58+
59+
print("\nAkhir dari program, terima kasih")
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'''Membuat fungsi'''
2+
3+
def hello_world():
4+
'''fungsi menampilkan hello world'''
5+
print("hello world")
6+
print("Kepada Ucup Surucup")
7+
print("Dan juga kepada Otong Surotong")
8+
9+
hello_world()
10+
hello_world()
11+
12+
# fungsi()
13+
14+
def fungsi():
15+
'''pemanggilan fungsi harus setelah dibuat'''
16+
print("Ini adalah fungsi")
17+
18+
fungsi()

0 commit comments

Comments
 (0)