def main(): filename = input('Type the name of a file: ') infolist = makeList(filename) graphics(infolist) simpleInfoList = editList(infolist)
def main(): while True: #If the program catches an error during the try section (string instead of number input) it will repeatedly prompt user for new value until there is no exception. try: r = float(input("Enter radius of the circle: ")) while r <= 0: #Another loop this time to check if the value greater than 0. r = float( input("Radius cannot be zero or negative.\n\n" "Enter radius of the circle: ")) break except ValueError: print("Please enter a number.") while True: #If the program catches an error during the try section (string instead of number input) it will repeatedly prompt user for new value until there is no exception. try: y = float(input("Enter y-intercept: ")) yint = y + 300 #Transformation required because the coordinates in the graphics window start at the bottom left and not at the center. break except ValueError: print("Please enter a number.") p1, p2, x = int_calc(r, y) if y > r or y < -r: #Prints coordinates of intersections, or just of one if it only intersects once. Will also print if no intersection occurs. print("No Intersection.") elif x != -x: print( "The line and circle intersect at the points: ({},{}) and ({},{})." .format(round(x, 2), round(y, 2), round(-x, 2), round(y, 2)) ) #Note that the printed coordinates are the original untransformed unlike the ones for use in the display. else: print("The line and circle intersect at the point: ({},{}).".format( round(x, 2), round(y, 2))) graphics(r, yint, y, p1, p2)
def main(): win = graphics(700, 400, "Animated Linked List") win.rectangle(0, 0, 700, 400, 'grey') array = [] for line in sys.stdin: win.update_frame(2) line = line.split() for num in line: try: num = int(num) except: continue # accounts for negative ints^ array.append(num) head = create_head(sorted(array)) linked_list = create_list(head, sorted(array)) draw_list(array, win, num) print('After insertion, the list is now:', linked_list)
def onexecute(self): # make an instance of all the functions # common.c = common() common.inventorytotal = playertotals() common.mp = morepanel() common.e = event() common.ai = ai() common.ip = infopanel() common.en = entity() common.cv = civilization() common.g = graphics() common.sounds = sounds.sounds() # initialize pygame pygame.init() # Read from config file opt = open(os.path.join(common.rootdir, "options.json"), 'r') y = json.loads(opt.read()) common.srclocation = os.path.join("texturepacks", y['texturepack']) common.enablesky = bool(y['sky']) opt.close() # load the window common.screen = pygame.display.set_mode( (common.width, common.height), RESIZABLE) pygame.display.set_caption(common.name+" v."+str(common.version)); common.running = True common.screen.fill((255,255,255)) # load all images/resources common.g.loadall() pygame.display.set_icon(civilization.buildingtextures[0]) # do cursors common.hand = pygame.cursors.compile(hand_str, 'x', '.', "o") common.grabber = pygame.cursors.compile(grabber_str, 'x', '.', "o") #Starts music common.sounds.playmusic("Into_the_Unknown") self.fromlauncher()
def main(): #dictionary for words and how many times it appears freq = {} #intro to the program win, getText = printIntro() print(getText) #gets text from user input file = getInput(getText) #list with file no punctuation fileNoCh = noJunk(file) #list with no punctuation and no stop words fileNoStop = stopWords(fileNoCh) #dictionary with most common words mostCommon = commonWords(fileNoStop, freq) g = graphics(mostCommon, win)
if(teamName=="White Sox"): return "#000000"; if(teamName=="Yankees"): return "#E4002B"; return "#000000" #Default Error ### #### #Testing.. print "Date: " + getCurrentDate() print "Time: " + getCurrentTime() print generateMLB_URL( getCurrentDate() ) testXML = getXML( generateMLB_URL( getCurrentDate() ) ) getPreGameInfo( testXML ) testList = getCompletedGameInfo( testXML ) getInProgressGameInfo( testXML ) graphics( testList )
global prints if noun in GameObject.objects: prints = "Roll for intelligence." intelligence = int(input("Roll for intelligence.")) if intelligence >= 10: return GameObject.objects[noun].get_desc() else: print("Failed!") prints = "Failed!" return "Failed!" else: prints = "There is no {} here.".format(noun) return "There is no {} here.".format(noun) graphics() prints = "New Game or Continue?" if input("New Game or Continue? ") == "New Game": start_game() else: prints = "Game File Name:" gamefile = input("Game File Name:") open_session(gamefile) verb_dict = { "say": say, "examine": examine, "attack": attack, "look": look, "move": move,
def main(intro, name): try: window = graphics() name = menu(window, intro, name) except GraphicsError: window.close()
import math from graphics import * from options import opts from NewGame import * #-globals #global black #black = (0,0,0) #from roam import roam #from blkscreen import * pygame.init() #-------------parameters----------------------------------- song = 'idea-thing.mp3' #---------display surface and clock---------------------- graph = graphics(pygame.display.set_mode((1200, 675), RESIZABLE)) graph.insert(['Menu Background.PNG', 'icon.png'], [(1200, 675), (99 / 2, 134 / 2)], [(0, 0), (120, 90)], [0, 2]) graph.resize() #graph.gdisp.set_colorkey(graph.imgs[0].img.get_colorkey()) pygame.display.set_caption('rpg') clock = pygame.time.Clock() pygame.mixer.init() pygame.mixer.music.load(song) pygame.mixer.music.play(-1) #--------interaction loop------------------------------------------------------- start = False while not start: for event in pygame.event.get():