H3NL3Y

Examplar

Nov 17th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. #---------- WRITING TO A FILE --------#
  2. def write():
  3.   gamename = input('Enter game name: ')
  4.   agerating = input('Enter age rating: ')
  5.  
  6.   gameFile = open('gamedetails.txt' , 'a')
  7.   gameFile.write(gamename + ',')
  8.   gameFile.write(agerating + ',')
  9.   gameFile.close()
  10.  
  11.  
  12. def read():
  13.   gameFile = open('gamedetails.txt' , 'r')
  14.   gameReport = gameFile.read().split(',')
  15.   print(gameReport)
  16.  
  17.   gameSearch = input('Enter search: ')
  18.  
  19.   if gameSearch in gameReport:
  20.     print('Wooo')
  21.   else:
  22.     print('u wot?')
  23.    
  24.   gameFile.close()
  25.  
  26. read()
  27.    
  28.  
  29.  
  30.  
  31. ################################################################################
  32.  
  33.  
  34. #-------- IF STATEMENTS ----------#
  35.  
  36.  
  37. def question1():
  38.  
  39.   attempts = 3
  40.  
  41.   while attempts != 0:
  42.     question = input('''What colour is the sky?
  43.    1. Blue
  44.    2. Green
  45.    3. yellow
  46.    >>> ''')
  47.    
  48.     if question == '1':
  49.       print('Correct')
  50.       attempts = 0
  51.      
  52.      
  53.     elif question == '2':
  54.       print(' U mad? ')
  55.       attempts = attempts - 1
  56.       print('You have ' , attempts , 'left')
  57.      
  58.     else:
  59.       print('Incorrect')
  60.       attempts = attempts - 1
  61.       print('You have ' , attempts , 'left')
  62.    
  63.    
  64.  
  65.  
  66.  
  67. question1()  
  68.  
  69. print('Next question')
  70.  
  71.  
  72.  
  73. #############################################################################
  74.  
  75. #-------------EMAIL CREATION -----------------#
  76. firstname = input('Enter name: ')
  77. surname = input('Enter surname: ')
  78.  
  79. l1 = firstname[0:3]
  80.  
  81. print(l1 + surname +'@bedfordacademy.co.uk')
Add Comment
Please, Sign In to add comment