diff --git a/CountMillionCharacter.py b/CountMillionCharacter.py index 41a85fed0fb..9060c3c5ab7 100644 --- a/CountMillionCharacter.py +++ b/CountMillionCharacter.py @@ -1,10 +1,11 @@ -'''Simple million word count program. - main idea is Python pairs words - with the number of times - that number appears in the triple quoted string. - Credit to William J. Turkel and Adam Crymble for the word - frequency code used below. I just merged the two ideas. -''' +""" +Simple million word count program. +main idea is Python pairs words +with the number of times +that number appears in the triple quoted string. +Credit to William J. Turkel and Adam Crymble for the word +frequency code used below. I just merged the two ideas. +""" wordstring = '''SCENE I. Yorkshire. Gaultree Forest. Enter the ARCHBISHOP OF YORK, MOWBRAY, LORD HASTINGS, and others diff --git a/Credit_Card_Validator.py b/Credit_Card_Validator.py index 209688b4b24..89bad20b76d 100644 --- a/Credit_Card_Validator.py +++ b/Credit_Card_Validator.py @@ -1,15 +1,15 @@ -#luhn algorithm +# luhn algorithm + class CreditCard: def __init__(self,card_no): self.card_no = card_no - @property def company(self): - comp =None + comp = None if str(self.card_no).startswith('4'): - comp = 'Visa Card' + comp = 'Visa Card' elif str(self.card_no).startswith(('50', '67', '58','63',)): comp = 'Maestro Card' elif str(self.card_no).startswith('5'): @@ -27,69 +27,57 @@ def company(self): return 'Company : '+comp - - def first_check(self): - if 13<=len(self.card_no)<=19: + if 13 <= len(self.card_no) <= 19: message = "First check : Valid in terms of length." else: message = "First chek : Check Card number once again it must be of 13 or 16 digit long." return message - - - def validate(self): - #double every second digit from right to left - sum_=0 + # double every second digit from right to left + sum_ = 0 crd_no = self.card_no[::-1] for i in range(len(crd_no)): - if i%2==1: + if i % 2 == 1: double_it = int(crd_no[i])*2 - if len(str(double_it))==2: + if len(str(double_it)) == 2: sum_ += sum([eval(i) for i in str(double_it)]) else: - sum_+=double_it + sum_ += double_it else: - sum_+=int(crd_no[i]) + sum_ += int(crd_no[i]) - - - if sum_%10==0: + if sum_ % 10 == 0: response = "Valid Card" else: response = 'Invalid Card' return response - - @property def checksum(self): return '#CHECKSUM# : '+self.card_no[-1] - @classmethod def set_card(cls,card_to_check): return cls(card_to_check) - -card_number = input() +card_number = input() card = CreditCard.set_card(card_number) print(card.company) -print('Card : ',card.card_no) +print('Card : ', card.card_no) print(card.first_check()) print(card.checksum) print(card.validate()) - # 79927398713 -#4388576018402626 -#379354508162306 +# 4388576018402626 +# 379354508162306 diff --git a/Cricket_score.py b/Cricket_score.py index e3604b0890a..75b6d30758b 100644 --- a/Cricket_score.py +++ b/Cricket_score.py @@ -7,17 +7,17 @@ url = "http://www.cricbuzz.com/cricket-match/live-scores" sauce = request.urlopen(url).read() -soup = bs.BeautifulSoup(sauce,"lxml") -#print(soup) +soup = bs.BeautifulSoup(sauce, "lxml") +# print(soup) score = [] results = [] -#for live_matches in soup.find_all('div',attrs={"class":"cb-mtch-lst cb-col cb-col-100 cb-tms-itm"}): +# for live_matches in soup.find_all('div',attrs={"class":"cb-mtch-lst cb-col cb-col-100 cb-tms-itm"}): for div_tags in soup.find_all('div', attrs={"class": "cb-lv-scrs-col text-black"}): - score.append(div_tags.text) + score.append(div_tags.text) for result in soup.find_all('div', attrs={"class": "cb-lv-scrs-col cb-text-complete"}): - results.append(result.text) + results.append(result.text) -print(score[0],results[0]) -toaster.show_toast(title=score[0],msg=results[0]) +print(score[0], results[0]) +toaster.show_toast(title=score[0], msg=results[0]) diff --git a/backup_automater_services.py b/backup_automater_services.py index 916aea771fc..0addf2ce257 100644 --- a/backup_automater_services.py +++ b/backup_automater_services.py @@ -12,21 +12,21 @@ import os # Load the library module import shutil # Load the library module -today = datetime.date.today() # Get Today's date +today = datetime.date.today() # Get Today's date todaystr = today.isoformat() # Format it so we can use the format to create the directory -confdir = os.getenv("my_config") # Set the variable by getting the value from the OS setting -dropbox = os.getenv("dropbox") # Set the variable by getting the value from the OS setting -conffile = ('services.conf') # Set the variable as the name of the configuration file -conffilename = os.path.join(confdir, conffile) # Set the variable by combining the path and the file name -sourcedir = os.path.expanduser('~/Library/Services/') # Source directory of where the scripts are located -destdir = os.path.join(dropbox, "My_backups" + "/" + - "Automater_services" + todaystr + "/") # Combine several settings to create +confdir = os.getenv("my_config") # Set the variable by getting the value from the OS setting +dropbox = os.getenv("dropbox") # Set the variable by getting the value from the OS setting +conffile = 'services.conf' # Set the variable as the name of the configuration file +conffilename = os.path.join(confdir, conffile) # Set the variable by combining the path and the file name +sourcedir = os.path.expanduser('~/Library/Services/') # Source directory of where the scripts are located +# Combine several settings to create +destdir = os.path.join(dropbox, "My_backups" + "/" + "Automater_services" + todaystr + "/") - # the destination backup directory -for file_name in open(conffilename): # Walk through the configuration file - fname = file_name.strip() # Strip out the blank lines from the configuration file - if fname: # For the lines that are not blank - sourcefile = os.path.join(sourcedir, fname) # Get the name of the source files to backup - destfile = os.path.join(destdir, fname) # Get the name of the destination file names - shutil.copytree(sourcefile, destfile) # Copy the directories +# the destination backup directory +for file_name in open(conffilename): # Walk through the configuration file + fname = file_name.strip() # Strip out the blank lines from the configuration file + if fname: # For the lines that are not blank + sourcefile = os.path.join(sourcedir, fname) # Get the name of the source files to backup + destfile = os.path.join(destdir, fname) # Get the name of the destination file names + shutil.copytree(sourcefile, destfile) # Copy the directories diff --git a/batch_file_rename.py b/batch_file_rename.py index ac5b6a600e7..c540a687a87 100644 --- a/batch_file_rename.py +++ b/batch_file_rename.py @@ -1,22 +1,25 @@ # batch_file_rename.py # Created: 6th August 2012 -''' +""" This will batch rename a group of files in a given directory, once you pass the current and new extensions -''' -#just checking +""" + + +# just checking __author__ = 'Craig Richards' __version__ = '1.0' import os import argparse + def batch_rename(work_dir, old_ext, new_ext): - ''' + """ This will batch rename a group of files in a given directory, once you pass the current and new extensions - ''' + """ # files = os.listdir(work_dir) for filename in os.listdir(work_dir): # Get the file extension @@ -33,6 +36,7 @@ def batch_rename(work_dir, old_ext, new_ext): os.path.join(work_dir, newfile) ) + def get_parser(): parser = argparse.ArgumentParser(description='change extension of files in a working directory') parser.add_argument('work_dir', metavar='WORK_DIR', type=str, nargs=1, help='the directory where to change extension') @@ -40,10 +44,11 @@ def get_parser(): parser.add_argument('new_ext', metavar='NEW_EXT', type=str, nargs=1, help='new extension') return parser + def main(): - ''' + """ This will be called if the script is directly invoked. - ''' + """ # adding command line argument parser = get_parser() args = vars(parser.parse_args()) diff --git a/calculator.py b/calculator.py index e48c72ffda1..5423be4b823 100644 --- a/calculator.py +++ b/calculator.py @@ -46,10 +46,10 @@ def calc(term): # This part is for reading and converting function expressions. term = term.lower() - for function in functions: - if function in term: - withmath = 'math.' + function - term = term.replace(function, withmath) + for func in functions: + if func in term: + withmath = 'math.' + func + term = term.replace(func, withmath) try: diff --git a/chaos.py b/chaos.py index ea57f02c26d..ba6313c91ca 100644 --- a/chaos.py +++ b/chaos.py @@ -1,5 +1,6 @@ # A simple program illustrating chaotic behaviour + def main(): print ("This program illustrates a chaotic function") @@ -17,5 +18,6 @@ def main(): x = 3.9 * x * (1-x) print (x) + if __name__ == '__main__': main() diff --git a/check_file.py b/check_file.py index 003eb511937..7d3152180ff 100644 --- a/check_file.py +++ b/check_file.py @@ -22,23 +22,24 @@ def usage(): # Readfile Functions which open the file that is passed to the script def readfile(filename): with open(filename, 'r') as f: # Ensure file is correctly closed under - file = f.read() # all circumstances - print(file) + read_file = f.read() # all circumstances + print(read_file) print() print('#'*80) print() + def main(): # Check the arguments passed to the script if len(sys.argv) >= 2: filenames = sys.argv[1:] - filteredfilenames_1 = list(filenames) #To counter changing in the same list which you are iterating + filteredfilenames_1 = list(filenames) # To counter changing in the same list which you are iterating filteredfilenames_2 = list(filenames) # Iterate for each filename passed in command line argument for filename in filteredfilenames_1: if not os.path.isfile(filename): # Check the File exists print('[-] ' + filename + ' does not exist.') - filteredfilenames_2.remove(filename) #remove non existing files from fileNames list + filteredfilenames_2.remove(filename) # remove non existing files from fileNames list continue # Check you can read the file @@ -55,7 +56,7 @@ def main(): readfile(filename) else: - usage() # Print usage if not all parameters passed/Checked + usage() # Print usage if not all parameters passed/Checked if __name__ == '__main__': diff --git a/check_for_sqlite_files.py b/check_for_sqlite_files.py index 7df00858a8a..fe09b3c86d0 100644 --- a/check_for_sqlite_files.py +++ b/check_for_sqlite_files.py @@ -11,6 +11,7 @@ from __future__ import print_function import os + def isSQLite3(filename): from os.path import isfile, getsize @@ -28,13 +29,14 @@ def isSQLite3(filename): else: return False -log=open('sqlite_audit.txt','w') -for r,d,f in os.walk(r'.'): - for files in f: - if isSQLite3(files): - print(files) - print("[+] '%s' **** is a SQLITE database file **** " % os.path.join(r,files)) - log.write("[+] '%s' **** is a SQLITE database file **** " % files+'\n') - else: - log.write("[-] '%s' is NOT a sqlite database file" % os.path.join(r,files)+'\n') - log.write("[-] '%s' is NOT a sqlite database file" % files+'\n') \ No newline at end of file + +log = open('sqlite_audit.txt','w') +for r, d, f in os.walk(r'.'): + for files in f: + if isSQLite3(files): + print(files) + print("[+] '%s' **** is a SQLITE database file **** " % os.path.join(r, files)) + log.write("[+] '%s' **** is a SQLITE database file **** " % files+'\n') + else: + log.write("[-] '%s' is NOT a sqlite database file" % os.path.join(r, files)+'\n') + log.write("[-] '%s' is NOT a sqlite database file" % files+'\n') diff --git a/check_input.py b/check_input.py index edbc0309858..1eb19d9eb0d 100644 --- a/check_input.py +++ b/check_input.py @@ -11,17 +11,17 @@ def get_user_input(start,end): while input invalid asks user again """ - loop = True # controls while-loop + loop = True # controls while-loop - while (loop): + while loop: try: # reads and converts the input from the console. - userInput = int(input("Enter Your choice: ")) + user_input = int(input("Enter Your choice: ")) # checks whether input is in the given bounds. - if userInput > end or userInput < start: + if user_input > end or user_input < start: # error case print("Please try again. Not in valid bounds.") @@ -36,11 +36,11 @@ def get_user_input(start,end): # error case print("Please try again. Only numbers") - return userInput + return user_input x = get_user_input(1,6) print(x) -###Asks user to enter something, ie. a number option from a menu. -###While type != interger, and not in the given range, -###Program gives error message and asks for new input. +# Asks user to enter something, ie. a number option from a menu. +# While type != interger, and not in the given range, +# Program gives error message and asks for new input. diff --git a/chicks_n_rabs.py b/chicks_n_rabs.py index 1b4dabb9cce..046c637f598 100644 --- a/chicks_n_rabs.py +++ b/chicks_n_rabs.py @@ -1,22 +1,25 @@ -'''Author Anurag Kumar(mailto:anuragkumarak95@gmail.com) +""" +Author Anurag Kumar(mailto:anuragkumarak95@gmail.com) Module to solve a classic ancient Chinese puzzle: We count 35 heads and 94 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have? +""" -''' -def solve(numheads,numlegs): - ns='No solutions!' - for i in range(numheads+1): - j=numheads-i - if 2*i+4*j==numlegs: - return i,j - return ns,ns -if __name__=="__main__": - numheads=35 - numlegs=94 +def solve(num_heads, num_legs): + ns = 'No solutions!' + for i in range(num_heads+1): + j = num_heads-i + if 2*i+4*j == num_legs: + return i, j + return ns, ns - solutions=solve(numheads,numlegs) + +if __name__ == "__main__": + numheads = 35 + numlegs = 94 + + solutions = solve(numheads, numlegs) print(solutions) diff --git a/create_dir_if_not_there.py b/create_dir_if_not_there.py index 458773d53e0..a24e01f5ab1 100644 --- a/create_dir_if_not_there.py +++ b/create_dir_if_not_there.py @@ -21,4 +21,4 @@ print(MESSAGE) except Exception as e: print(e) - + diff --git a/cricket_live_score.py b/cricket_live_score.py index 537dd687a42..7bdc85f31ea 100644 --- a/cricket_live_score.py +++ b/cricket_live_score.py @@ -2,20 +2,20 @@ from bs4 import BeautifulSoup as soup from urllib.request import urlopen as uReq -my_url="http://www.cricbuzz.com/" -Client=uReq(my_url) +my_url = "http://www.cricbuzz.com/" +Client = uReq(my_url) -html_page=Client.read() +html_page = Client.read() Client.close() -soup_page=soup(html_page,"html.parser") +soup_page = soup(html_page,"html.parser") -score_box=soup_page.findAll("div",{"class":"cb-col cb-col-25 cb-mtch-blk"}) -l = len(score_box) -print(l) -for i in range(l): +score_box = soup_page.findAll("div", {"class": "cb-col cb-col-25 cb-mtch-blk"}) +score_box_len = len(score_box) +print(score_box_len) +for i in range(score_box_len): print(score_box[i].a["title"]) print(score_box[i].a.text) print() diff --git a/daily_checks.py b/daily_checks.py index 91dd11e9a4a..8ab0e6ea3ed 100644 --- a/daily_checks.py +++ b/daily_checks.py @@ -3,15 +3,15 @@ # Created : 07th December 2011 # Last Modified : 01st May 2013 # Version : 1.5 -# -# Modifications : 1.1 Removed the static lines for the putty sessions, it now reads a file, loops through and makes the connections. -# : 1.2 Added a variable filename=sys.argv[0] , as when you use __file__ it errors when creating an exe with py2exe. -# : 1.3 Changed the server_list.txt file name and moved the file to the config directory. -# : 1.4 Changed some settings due to getting a new pc -# : 1.5 Tidy comments and syntax -# -# Description : This simple script loads everything I need to carry out the daily checks for our systems. - +""" +Modifications : 1.1 Removed the static lines for the putty sessions, it now reads a file, loops through and makes the connections. + : 1.2 Added a variable filename=sys.argv[0] , as when you use __file__ it errors when creating an exe with py2exe. + : 1.3 Changed the server_list.txt file name and moved the file to the config directory. + : 1.4 Changed some settings due to getting a new pc + : 1.5 Tidy comments and syntax + +Description : This simple script loads everything I need to carry out the daily checks for our systems. +""" import platform # Load Modules import os import subprocess @@ -28,24 +28,28 @@ def clear_screen(): # Function to clear the screen def print_docs(): # Function to print the daily checks automatically - print ("Printing Daily Check Sheets:") - # The command below passes the command line string to open word, open the document, print it then close word down - subprocess.Popen(["C:\\Program Files (x86)\Microsoft Office\Office14\winword.exe", "P:\\\\Documentation\\Daily Docs\\Back office Daily Checks.doc", "/mFilePrintDefault", "/mFileExit"]).communicate() + print ("Printing Daily Check Sheets:") + # The command below passes the command line string to open word, open the document, print it then close word down + subprocess.Popen(["C:\\Program Files (x86)\Microsoft Office\Office14\winword.exe", + "P:\\\\Documentation\\Daily Docs\\Back office Daily Checks.doc", + "/mFilePrintDefault", "/mFileExit"]).communicate() def putty_sessions(conffilename): # Function to load the putty sessions I need - for server in open(conffilename): # Open the file server_list.txt, loop through reading each line - 1.1 -Changed - 1.3 Changed name to use variable conffilename - subprocess.Popen(('putty -load '+server)) # Open the PuTTY sessions - 1.1 + # Open the file server_list.txt, loop through reading each line + # 1.1 -Changed - 1.3 Changed name to use variable conffilename + for server in open(conffilename): + subprocess.Popen(('putty -load '+server)) # Open the PuTTY sessions - 1.1 def rdp_sessions(): - print ("Loading RDP Sessions:") - subprocess.Popen("mstsc eclr.rdp") # Open up a terminal session connection and load the euroclear session + print ("Loading RDP Sessions:") + subprocess.Popen("mstsc eclr.rdp") # Open up a terminal session connection and load the euroclear session def euroclear_docs(): - # The command below opens IE and loads the Euroclear password document - subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe"' '"file://fs1\pub_b\Pub_Admin\Documentation\Settlements_Files\PWD\Eclr.doc"') + # The command below opens IE and loads the Euroclear password document + subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe"' '"file://fs1\pub_b\Pub_Admin\Documentation\Settlements_Files\PWD\Eclr.doc"') # End of the functions @@ -54,11 +58,13 @@ def euroclear_docs(): def main(): filename = sys.argv[0] # Create the variable filename confdir = os.getenv("my_config") # Set the variable confdir from the OS environment variable - 1.3 - conffile = ('daily_checks_servers.conf') # Set the variable conffile - 1.3 - conffilename = os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together - 1.3 + conffile = 'daily_checks_servers.conf' # Set the variable conffile - 1.3 + # Set the variable conffilename by joining confdir and conffile together - 1.3 + conffilename = os.path.join(confdir, conffile) clear_screen() # Call the clear screen function - # The command below prints a little welcome message, as well as the script name, the date and time and where it was run from. + # The command below prints a little welcome message, as well as the script name, + # the date and time and where it was run from. print ("Good Morning " + os.getenv('USERNAME') + ", "+ filename, "ran at", strftime("%Y-%m-%d %H:%M:%S"), "on",platform.node(), "run from",os.getcwd()) diff --git a/dec_to_hex.py b/dec_to_hex.py index ce358712db7..2f93f25ed99 100644 --- a/dec_to_hex.py +++ b/dec_to_hex.py @@ -1,2 +1,2 @@ -dec_num=input('Enter the decimal number\n') +dec_num = input('Enter the decimal number\n') print(hex(int(dec_num))) diff --git a/dice.py b/dice.py index 068128ed4e4..f6adc1bf94a 100644 --- a/dice.py +++ b/dice.py @@ -6,28 +6,32 @@ # Modifications : -# Description : This will randomly select two numbers, like throwing dice, you can change the sides of the dice if you wish +# Description : This will randomly select two numbers, like throwing dice, +# you can change the sides of the dice if you wish import random + + class Die(object): - #A dice has a feature of number about how many sides it has when it's established,like 6. - def __init__(self): - self.sides=6 - - """because a dice contains at least 4 planes. - So use this method to give it a judgement when you need to change the instance attributes.""" - def set_sides(self, sides_change): - if sides_change>=4: - if sides_change != 6: - print("change sides from 6 to ",sides_change," !") - else: # added else clause for printing a message that sides set to 6 - print ("sides set to 6") - self.sides = sides_change - else: - print("wrong sides! sides set to 6") - - def roll(self): - return random.randint(1, self.sides) + # A dice has a feature of number about how many sides it has when it's established,like 6. + def __init__(self): + self.sides = 6 + + """because a dice contains at least 4 planes. + So use this method to give it a judgement when you need to change the instance attributes.""" + def set_sides(self, sides_change): + if sides_change >= 4: + if sides_change != 6: + print("change sides from 6 to ", sides_change, " !") + else: # added else clause for printing a message that sides set to 6 + print ("sides set to 6") + self.sides = sides_change + else: + print("wrong sides! sides set to 6") + + def roll(self): + return random.randint(1, self.sides) + d = Die() d1 = Die() diff --git a/diceV2_dynamic.py b/diceV2_dynamic.py index 2e0f373486a..8fcb66e74a7 100644 --- a/diceV2_dynamic.py +++ b/diceV2_dynamic.py @@ -1,10 +1,8 @@ +import random - - -import random -#Class that that holds dice-functions. You can set the amount of sides and roll with each dice object. -class Dice(): +# Class that that holds dice-functions. You can set the amount of sides and roll with each dice object. +class Dice: def __init__(self): self.sideCount=6 @@ -12,21 +10,22 @@ def setSides(self, sides): if sides > 3: self.sides = sides else: - print("This absolutely shouldn't ever happen. The programmer sucks or someone has tweaked with code they weren't supposed to touch!") + print("This absolutely shouldn't ever happen. The programmer sucks or someone " + "has tweaked with code they weren't supposed to touch!") def roll(self): return random.randint(1, self.sides) -###===================================================================== +# ===================================================================== -#Checks to make sure that the input is actually an integer. -#This implementation can be improved greatly of course. +# Checks to make sure that the input is actually an integer. +# This implementation can be improved greatly of course. def checkInput(sides): try: if int(sides) != 0: - if (float(sides)%int(sides) == 0): #excludes the possibility of inputted floats being rounded. + if float(sides) % int(sides) == 0: # excludes the possibility of inputted floats being rounded. return int(sides) else: return int(sides) @@ -36,27 +35,27 @@ def checkInput(sides): return None -#Picks a number that is at least of a certain size. -#That means in this program, the dices being possible to use in 3 dimensional space. -def pickNumber(item, questionString, lowerlimit): +# Picks a number that is at least of a certain size. +# That means in this program, the dices being possible to use in 3 dimensional space. +def pickNumber(item, question_string, lower_limit): while True: - item = input(questionString) + item = input(question_string) item = checkInput(item) if type(item) == int: - if item <= lowerlimit: + if item <= lower_limit: print("Input too low!") continue else: return item -#Main-function of the program that sets up the dices for the user as they want them. +# Main-function of the program that sets up the dices for the user as they want them. def getDices(): dices = [] sides = None diceAmount = None - sideLowerLimit = 3 #Do Not Touch! - diceLowerLimit = 1 #Do Not Touch! + sideLowerLimit = 3 # Do Not Touch! + diceLowerLimit = 1 # Do Not Touch! sides = pickNumber(sides, "How many sides will the dices have?: ", sideLowerLimit) diceAmount = pickNumber(diceAmount, "How many dices will do you want?: ", diceLowerLimit) @@ -69,10 +68,9 @@ def getDices(): return dices - dices = getDices() -#================================================================= -#Output section. +# ================================================================= +# Output section. rollOutput = "" diff --git a/dice_rolling_simulator.py b/dice_rolling_simulator.py index 3ee0332ffb0..e3f6fa237b1 100644 --- a/dice_rolling_simulator.py +++ b/dice_rolling_simulator.py @@ -1,39 +1,42 @@ -#Made on May 27th, 2017 -#Made by SlimxShadyx -#Editted by CaptMcTavish, June 17th, 2017 -#Comments edits by SlimxShadyx, August 11th, 2017 +# Made on May 27th, 2017 +# Made by SlimxShadyx +# Editted by CaptMcTavish, June 17th, 2017 +# Comments edits by SlimxShadyx, August 11th, 2017 -#Dice Rolling Simulator +# Dice Rolling Simulator import random global user_exit_checker -user_exit_checker="exit" +user_exit_checker = "exit" + +# Our start function (What the user will first see when starting the program) + -#Our start function (What the user will first see when starting the program) def start(): print "Welcome to dice rolling simulator: \nPress Enter to proceed" raw_input(">") - #Starting our result function (The dice picker function) + # Starting our result function (The dice picker function) result() -#Our exit function (What the user will see when choosing to exit the program) + +# Our exit function (What the user will see when choosing to exit the program) def bye(): print "Thanks for using the Dice Rolling Simulator! Have a great day! =)" -#Result function which is our dice chooser function -def result(): - #user_dice_chooser No idea how this got in here, thanks EroMonsterSanji. +# Result function which is our dice chooser function +def result(): + # user_dice_chooser No idea how this got in here, thanks EroMonsterSanji. print "\r\nGreat! Begin by choosing a die! [6] [8] [12]?\r\n" user_dice_chooser = raw_input(">") user_dice_chooser = int(user_dice_chooser) - #Below is the references to our dice functions (Below), when the user chooses a dice. + # Below is the references to our dice functions (Below), when the user chooses a dice. if user_dice_chooser == 6: dice6() @@ -43,15 +46,15 @@ def result(): elif user_dice_chooser == 12: dice12() - #If the user doesn't choose an applicable option + # If the user doesn't choose an applicable option else: print "\r\nPlease choose one of the applicable options!\r\n" result() -#Below are our dice functions. +# Below are our dice functions. def dice6(): - #Getting a random number between 1 and 6 and printing it. + # Getting a random number between 1 and 6 and printing it. dice_6 = random.randint(1,6) print "\r\nYou rolled a " + str(dice_6) + "!\r\n" @@ -73,14 +76,14 @@ def dice12(): def user_exit_checker(): - #Checking if the user would like to roll another die, or to exit the program + # Checking if the user would like to roll another die, or to exit the program user_exit_checker_raw = raw_input("\r\nIf you want to roll another die, type [roll]. To exit, type [exit].\r\n?>") user_exit_checker = (user_exit_checker_raw.lower()) - if user_exit_checker=="roll": + if user_exit_checker == "roll": start() else: bye() -#Actually starting the program now. +# Actually starting the program now. start()