Advertisement
Yesideez

QuizMaster.py

Nov 7th, 2022
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | Source Code | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. #import datetime
  4. import os
  5. import platform
  6.  
  7. # find out if we're running on Windows, Mac or Linux
  8. if platform.system()=="Windows":clsMode="cls"
  9. else:clsMode="clear" #Linux/Mac
  10.  
  11. def cls():
  12.   _=os.system(clsMode)
  13.  
  14. def txtCentre(txt):
  15.   rows,columns=os.popen('stty size','r').read().split()
  16.   pos=int(columns)/2-(len(txt)/2)
  17.   print(" "*int(pos),txt)
  18.  
  19. def terminate(txt):
  20.   print(txt)
  21.   os._exit(os.EX_CONFIG)
  22.  
  23. def init():
  24.   rows,columns=os.popen('stty size','r').read().split()
  25.   if int(rows)<20:terminate("ERROR: Console needs to be at least 20 lines high!")
  26.  
  27. def menu():
  28.   cls()
  29.   txtCentre("QuizMaster v1.oo (7th Nov 2022) by Zeb")
  30.   print("")
  31.  
  32. init()
  33. menu()
  34.  
  35. #x=datetime.datetime.now()
  36. #print(x.strftime("%d-%b-%Y %H:%M:%S (Week %W)"))
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement