def main(): sys.setExecutionLimit(120000) # keep program from timing out lifts = ["squat", "bench", "deadlift"] weight = 0 for extrasize in list(lifts): yes = input("""Keep doing the""" extrasize"""? If so, type "yes".""") workout_coach(extrasize, weight+10)
def __init__(self): sys.setExecutionLimit(1000000) self.amt_turtles = None self.turtles = [] self.draw_turtle = turtle.Turtle() self.screen = self.draw_turtle.getscreen() self.colors = ('black', 'red', 'green', 'blue', 'purple', 'gray', 'pink', 'brown') self.main_loop()
def main(): sys.setExecutionLimit(120000) lifts = ["squat", "bench", "deadlift"] for lift in lifts: keep_lifting = "yes" weight = 0 input_prompt = "Keep doing the " + lift + "? Enter yes for the next set." while keep_lifting == "yes": weight = weight + 10 if lift == "bench" and weight > 200: break else: workout_coach(lift, weight) keep_lifting = input(input_prompt)
def main(): sys.setExecutionLimit(60000) inst = createLSystem(6, "YF") # create the string # print(inst) t = turtle.Turtle() # create the turtle wn = turtle.Screen() t.up() t.back(180) t.down() t.speed(0) drawLsystem(t, inst, 60, 5) # draw the picture # angle 60, segment length 5 wn.exitonclick()
def main(): sys.setExecutionLimit(120000) # keep program from timing out lifts = ["squat", "bench", "deadlift"] for lift in lifts: print() weight = 10 answer = 'yes' while answer == 'yes': if lift == 'bench' and weight > 200: print("Sorry, you need to move on to something different.") break workout_coach(lift, weight) input_prompt = "Keep doing the " + lift \ + "? Enter yes for the next set. " answer = input(input_prompt) weight += 10
def main(): sys.setExecutionLimit(40000) inst = createLSystem(5, "FXF--FF--FF") # create the string # print(inst) t = turtle.Turtle() # create the turtle wn = turtle.Screen() t.penup() t.back(200) t.right(90) t.forward(100) t.left(90) t.pendown() t.speed(0) drawLsystem(t, inst, 60, 5) # draw the picture # angle 60, segment length 5 wn.exitonclick()
def main(): sys.setExecutionLimit(120000) # keep program from timing out lifts = ["squat", "bench", "deadlift"] # Your code here for lift_name in lifts: wt = 10 input_prompt = "Keep doing the " + lift_name + "? Enter yes for the next set." keep_going = 'yes' while keep_going == 'yes': workout_coach(lift_name, wt) keep_going = input(input_prompt) wt += 10 if lift_name == 'bench' and wt > 200: break elif keep_going != 'yes': break else: continue
def main(): sys.setExecutionLimit(120000) # keep program from timing out lifts = ["squat", "bench", "deadlift"] # Your code here for lift in lifts: weight = 10 stop = False while(stop == False): workout_coach(lift, weight) ans = input("Keep doing the " + lift + "? Enter yes for the next set.") if((ans != "yes") and (ans != "Yes")): stop = True else: weight += 10 if((weight > 200) and (lift == "bench")): stop = True
return len(self.book_libray) ebook1 = Ebook('math', 'ali', 2) paperbook1 = paperbook('chem', 'aftab', 500) lib1 = library() lib1.add_book(ebook1) lib1.add_book(paperbook1) print(lib1.total_number_books()) # Tamagotchi game import sys sys.setExecutionLimit(60000) from random import randrange class Pet(object): boredom_decrement = 4 hunger_decrement = 6 boredom_threshold = 5 hunger_threshold = 10 sounds = ['Mrrp'] def __init__(self, name="Kitty"): self.name = name self.hunger = randrange(self.hunger_threshold) self.boredom = randrange(self.boredom_threshold) self.sounds = self.sounds[:] # copy the class attribute, so that when we make changes to it, we won't affect the other Pets in the class
if move == True: for x in self.SORTED_FREQUENCIES: if x not in guessed: lst2.append(x) if VOWEL_COST == 250: for x in lst2: if x in VOWELS: lst2.remove(x) return lst2[-1] else: return random.choice(lst) import sys sys.setExecutionLimit(600000) # let this take up to 10 minutes import json import random import time LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' VOWELS = 'AEIOU' VOWEL_COST = 250 # Repeatedly asks the user for a number between min & max (inclusive) def getNumberBetween(prompt, min, max): userinp = input(prompt) # ask the first time while True:
def main(): sys.setExecutionLimit(120000) # keep program from timing out lifts = ["squat", "bench", "deadlift"] weight = 0 for extrasize in list lifts: workout_coach(extrasize, weight + 10)
import turtle import sys sys.setExecutionLimit(35000) def draw_spiral(t, angle): ''' takes a turtle, t, and an angle in degrees ''' length = 1 for i in range(84): t.forward(length) t.right(angle) length = length + 2 def main(): wn = turtle.Screen() # Set up the window and its attributes wn.bgcolor("lightgreen") guido = turtle.Turtle() # create guido guido.color('blue') guido.speed(10) ## draw the first spiral ## # position guido guido.penup() guido.backward(110) guido.pendown() # draw the spiral using a 90 degree turn angle draw_spiral(guido, 90)
import image import sys sys.setExecutionLimit(200000) #runs long, so be patient def photo_median_replace(filename): img = image.Image(filename) win = image.ImageWin(img.getWidth(), img.getHeight()) img.setDelay(0) for row in range(img.getHeight()): for col in range(img.getWidth()): p = img.getPixel(col, row) oldpixel = image.Pixel(p.getRed(), p.getGreen(), p.getBlue()) nearred = 0 neargreen = 0 nearblue = 0 if ((col and row) > 0) and (col + 1 < img.getWidth()) and ( row + 1 < img.getHeight() ): #smoothing all but the edges for simplicity for nearrow in range(col - 1, col + 2): for nearcol in range(row - 1, row + 2): nearp = img.getPixel(nearrow, nearcol) nearred = nearred + 0.13 * nearp.getRed() neargreen = neargreen + 0.13 * nearp.getGreen() nearblue = nearblue + 0.13 * nearp.getBlue() newpixel = image.Pixel(nearred - 0.13 * p.getRed(), neargreen - 0.13 * p.getGreen(), nearblue - 0.13 * p.getBlue()) img.setPixel(col, row, newpixel) else: img.setPixel(col, row, oldpixel)
newim.draw(win) win.exitonclick() # Q15 Sobel edge detection import image import math import sys # Code adapted from http://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/image-processing/edge_detection.html # Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. # this algorithm takes some time for larger images - this increases the amount of time # the program is allowed to run before it times out sys.setExecutionLimit(20000) img = image.Image("luther.jpg") newimg = image.EmptyImage(img.getWidth(), img.getHeight()) win = image.ImageWin() for x in range(1, img.getWidth()-1): # ignore the edge pixels for simplicity (1 to width-1) for y in range(1, img.getHeight()-1): # ignore edge pixels for simplicity (1 to height-1) # initialise Gx to 0 and Gy to 0 for every pixel Gx = 0 Gy = 0 # top left pixel p = img.getPixel(x-1, y-1) r = p.getRed()
import sys msecs = 200000 sys.setExecutionLimit(msecs) #increase the run time ############################# punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@'] def strip_punctuation(strWord): for x in punctuation_chars: strWord = strWord.replace(x, "") return strWord #list of positive words: pos_words = list() with open("positive_words.txt") as p_file: for line in p_file: if line[0] != ';' and line[0] != '\n': pos_words.append(line.strip()) #list of negative words: neg_words = list() with open("negative_words.txt") as n_file: for line in n_file: if line != ':' and line[0] != '\n': neg_words.append(line.strip()) #get Positive words counts:
# Write the WOFPlayer class definition (part A) here # Write the WOFHumanPlayer class definition (part B) here # Write the WOFComputerPlayer class definition (part C) here Putting it together: Wheel of Python Below is the game logic for the rest of the “Wheel of Python” game. We have implemented most of the game logic. Start by carefully reading this code and double checking that it all makes sense. Then, paste your code from the previous code window in the correct places below. Note 1: we added the following code to ensure that the Python interpreter gives our game time to run: import sys sys.setExecutionLimit(600000) sys.setExecutionLimit(ms) says that we should be able to run our program for ms milliseconds before it gets stopped automatically. Note 2: As you play, you will need to keep scrolling down to follow the game. # PASTE YOUR WOFPlayer CLASS (from part A) HERE # PASTE YOUR WOFHumanPlayer CLASS (from part B) HERE # PASTE YOUR WOFComputerPlayer CLASS (from part C) HERE import sys sys.setExecutionLimit(600000) # let this take up to 10 minutes import json import random