Advertisement
X-88

createtable.py

Nov 21st, 2021
828
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from os import system
  2.  
  3. """
  4. Writed by: Zephio
  5. Create Simple Table
  6. Lang: Python 3.xx
  7. https://gist.github.com/x-88
  8.  
  9. """
  10.  
  11. brd = u'\u2593'
  12. spr = '=' * 34
  13. cno = 'No '
  14. cnm = 'Nama      '
  15. ckls = 'Kelas'
  16. lnm = []
  17. lkls = []
  18.  
  19.  
  20. def reset():
  21.     system('sleep 2')
  22.     system('clear')
  23.    
  24.        
  25. def idt():
  26.     while True:
  27.         system('clear')
  28.         inm = input('Nama: ')
  29.         ikls = input('Kelas: ')
  30.         if (len(inm) < 3) or (len(inm) > 10) or (len(ikls) < 1):
  31.             print(spr + '\nWarning.\nNama Min 3, Max 10/Kelas Belum diisi!...\n' + spr)
  32.             reset()
  33.             return idt()
  34.         else:
  35.             lnm.append(inm)
  36.             lkls.append(ikls)
  37.             key = input(spr + '\nTambahkan Data?\ny = ya\nl = Lihat Data\nSembarang Tombol = Main Menu\n>>> ').lower()
  38.             if key == 'y':
  39.                 idt()
  40.             elif key == 'l':
  41.                 gdt()
  42.             else:
  43.                 main()
  44.  
  45. def gdt():
  46.     system('clear')
  47.     data = dict(zip(lnm, lkls))
  48.     print(brd * 25)
  49.     print(brd, cno, brd, cnm , brd, ckls, brd)
  50.     print(brd * 25)
  51.     for i, j in enumerate(data):
  52.         print(brd, format('%03d' % (i + 1)), brd, j + " " * (len(cnm) - len(j)), brd, data[j], " " * (len(ckls) - len(data[j]) - 1), brd)
  53.     print(brd * 25)
  54.     system('sleep 5')
  55.     main()
  56.    
  57.    
  58.  
  59. def main():
  60.     system('clear')
  61.     while True:
  62.         opsi = input('t = Tambah Data\nl = Lihat Data\nSembarang Tombol untuk Keluar\n>>> ')
  63.         if opsi == 't':
  64.             idt()
  65.         elif opsi == 'l':
  66.             gdt()
  67.         else:
  68.             exit(0)
  69.          
  70.                
  71. main()
Advertisement
RAW Paste Data Copied
Advertisement