index
int64
0
100k
blob_id
stringlengths
40
40
code
stringlengths
7
7.27M
steps
listlengths
1
1.25k
error
bool
2 classes
3,200
7c004cb0c9eefa5e88f5085fb3b2878db98d2b20
""" This class runs the RL Training """ from __future__ import division import logging import numpy as np from data.data_provider import DataProvider from episode.episode import Episode from tracker import TrainingTracker from tqdm import tqdm class RLTrainer(object): """ Creates RL training object """ ...
[ "\"\"\"\nThis class runs the RL Training\n\"\"\"\n\nfrom __future__ import division\nimport logging\nimport numpy as np\nfrom data.data_provider import DataProvider\nfrom episode.episode import Episode\nfrom tracker import TrainingTracker\nfrom tqdm import tqdm\n\n\nclass RLTrainer(object):\n \"\"\"\n Creates...
false
3,201
120021e44f6df9745db35ea2f38f25acecca9252
# Copyright 2014 Rackspace Hosting # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
[ "# Copyright 2014 Rackspace Hosting\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtain\n# a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n...
false
3,202
09aedd6cab0b8c6a05bbee5b336fcd38aea1f7b9
# animation2.py # multiple-shot cannonball animation from math import sqrt, sin, cos, radians, degrees from graphics import * from projectile import Projectile from button import Button class Launcher: def __init__(self, win): """Create inital launcher with angle 45 degrees and velocity 40 win i...
[ "# animation2.py\n\n# multiple-shot cannonball animation\n\nfrom math import sqrt, sin, cos, radians, degrees\nfrom graphics import *\nfrom projectile import Projectile\nfrom button import Button\n\nclass Launcher:\n\n def __init__(self, win):\n \"\"\"Create inital launcher with angle 45 degrees and veloc...
false
3,203
4fbe4d474e10e08eafee3bcc6173f8cd6b797dde
def swap(a,b): print(a,b) a=input("enter a value 1 : ") b=input("enter b value 2 : ") a,b=b,a print("the vaalues after swaping the variables are below:") print("the value of a is : ",a) print("the value of b is : ",b)
[ "def swap(a,b):\n print(a,b)\na=input(\"enter a value 1 : \")\nb=input(\"enter b value 2 : \")\na,b=b,a\nprint(\"the vaalues after swaping the variables are below:\")\nprint(\"the value of a is : \",a)\nprint(\"the value of b is : \",b)\n", "def swap(a, b):\n print(a, b)\n\n\na = input('enter a value 1 : ')\nb...
false
3,204
501614f9c7df3c862c9951ea343964b6ed47e74a
import requests import json base_url = f"https://api.telegram.org/bot" def get_url(url): response = requests.get(url) content = response.content.decode("utf8") return content def get_json_from_url(url): content = get_url(url) js = json.loads(content) return js def get_updates(TOKEN): ...
[ "import requests\nimport json\n\nbase_url = f\"https://api.telegram.org/bot\"\n\n\ndef get_url(url):\n response = requests.get(url)\n content = response.content.decode(\"utf8\")\n return content\n\n\ndef get_json_from_url(url):\n content = get_url(url)\n js = json.loads(content)\n return js\n\n\nd...
false
3,205
63182a8708729606f96794cddb163f707252ba61
from people.models import Medium, Profile, Staff, Instructor, Student, Alumni, Donation, Address, Award, Reference, Experience, Skill, Education, ImporterUsers from anonymizer import Anonymizer class MediumAnonymizer(Anonymizer): model = Medium attributes = [ ('medium_id', "integer"), ('descr...
[ "from people.models import Medium, Profile, Staff, Instructor, Student, Alumni, Donation, Address, Award, Reference, Experience, Skill, Education, ImporterUsers\nfrom anonymizer import Anonymizer\n\nclass MediumAnonymizer(Anonymizer):\n\n model = Medium\n\n attributes = [\n ('medium_id', \"integer\"),\...
false
3,206
d2e8c95dc144aa83128cc815ad145982f64b1819
#!/usr/bin/env python from math import factorial F = [factorial(i) for i in range(10)] #F[9] * 8 = 2903040 > this means no 8 digit numbers #F[9] * 7 = 2540160 < this is the maximum that I could think of total = 0 for i in xrange(10, 2540160): if sum([F[int(d)] for d in str(i)]) == i: total = total + i p...
[ "#!/usr/bin/env python\n\nfrom math import factorial\n\nF = [factorial(i) for i in range(10)]\n#F[9] * 8 = 2903040 > this means no 8 digit numbers\n#F[9] * 7 = 2540160 < this is the maximum that I could think of\n\ntotal = 0\nfor i in xrange(10, 2540160):\n if sum([F[int(d)] for d in str(i)]) == i:\n tota...
true
3,207
4193fa992d06890afb660c072842cf1b85a43774
import glob import logging import os import sqlite3 from aiogram import Bot, Dispatcher, executor, types TOKEN = '1772334389:AAE5wv8gssOFOgxQjQwKk7rUSKQHr6NTjus' logging.basicConfig(level=logging.INFO) bot = Bot(token=TOKEN) dp = Dispatcher(bot) path1 = 'C:\\Users\\const\\PycharmProjects\\t' conn = sqlite3.connect('...
[ "import glob\nimport logging\nimport os\nimport sqlite3\n\nfrom aiogram import Bot, Dispatcher, executor, types\n\nTOKEN = '1772334389:AAE5wv8gssOFOgxQjQwKk7rUSKQHr6NTjus'\nlogging.basicConfig(level=logging.INFO)\nbot = Bot(token=TOKEN)\ndp = Dispatcher(bot)\npath1 = 'C:\\\\Users\\\\const\\\\PycharmProjects\\\\t'\n...
false
3,208
d04506e67071abf36d43a828d90fbe0f14230103
# filename: cycle_break.py # for i in range(1, 101): # if i % 3 == 0 and i % 8 == 0: # print(i) # break num = 1 while num <= 100: if num % 4 == 0 and num % 6 == 0: print(num) break num += 1
[ "# filename: cycle_break.py\n\n# for i in range(1, 101):\n# if i % 3 == 0 and i % 8 == 0:\n# print(i)\n# break\n\nnum = 1\nwhile num <= 100:\n if num % 4 == 0 and num % 6 == 0:\n print(num)\n break\n num += 1", "num = 1\nwhile num <= 100:\n if num % 4 == 0 and num % 6 ==...
false
3,209
e7699bb3f6080c78517f11445e2c48a0e40f3332
class MedianFinder: def __init__(self): """ initialize your data structure here. """ self.minheap = [] self.maxheap = [] def addNum(self, num: int) -> None: heapq.heappush (self.maxheap ,-heapq.heappushpop(self.minheap , num) ) if len(self.maxheap) > len...
[ "class MedianFinder:\n\n def __init__(self):\n \"\"\"\n initialize your data structure here.\n \"\"\"\n self.minheap = []\n self.maxheap = []\n\n def addNum(self, num: int) -> None:\n heapq.heappush (self.maxheap ,-heapq.heappushpop(self.minheap , num) )\n if l...
false
3,210
af7af5d1048d2b0968e831aad89d5baf30cab608
''' Copyright (c) 2021, Štěpán Beneš The purpose of this script it to take the 5 BSE and 5 SE hand-picked prototype images and turn them into the same shape and format as the rest of the data. Prototype images are resized to 768x768, the info bar is cropped off. Afterwards the images are normalized to float32 in ran...
[ "'''\nCopyright (c) 2021, Štěpán Beneš\n\n\nThe purpose of this script it to take the 5 BSE and 5 SE hand-picked prototype\nimages and turn them into the same shape and format as the rest of the data.\n\nPrototype images are resized to 768x768, the info bar is cropped off. Afterwards\nthe images are normalized to f...
false
3,211
007cce815f3ad4e47593ff00ff2e73d5d9961d9e
#!/usr/bin/env python # Copyright (c) 2019, University of Stuttgart # All rights reserved. # # Permission to use, copy, modify, and distribute this software for any purpose # with or without fee is hereby granted, provided that the above copyright # notice and this permission notice appear in all copies. # # THE ...
[ "#!/usr/bin/env python\n\n# Copyright (c) 2019, University of Stuttgart\n# All rights reserved.\n#\n# Permission to use, copy, modify, and distribute this software for any purpose\n# with or without fee is hereby granted, provided that the above copyright\n# notice and this permission notice appear in all copi...
false
3,212
0a3e0eeda14e42bfff7797b3c42a0aebd9a72ade
import numpy as np print(np.random.binomial(10,0.5,1))
[ "import numpy as np\n\nprint(np.random.binomial(10,0.5,1))", "import numpy as np\nprint(np.random.binomial(10, 0.5, 1))\n", "<import token>\nprint(np.random.binomial(10, 0.5, 1))\n", "<import token>\n<code token>\n" ]
false
3,213
80be5f49a179eebc4915bf734a8e362cc2f2ef7c
# # @lc app=leetcode id=14 lang=python3 # # [14] Longest Common Prefix # # https://leetcode.com/problems/longest-common-prefix/description/ # # algorithms # Easy (34.95%) # Likes: 2372 # Dislikes: 1797 # Total Accepted: 718.5K # Total Submissions: 2M # Testcase Example: '["flower","flow","flight"]' # # Write a f...
[ "#\n# @lc app=leetcode id=14 lang=python3\n#\n# [14] Longest Common Prefix\n#\n# https://leetcode.com/problems/longest-common-prefix/description/\n#\n# algorithms\n# Easy (34.95%)\n# Likes: 2372\n# Dislikes: 1797\n# Total Accepted: 718.5K\n# Total Submissions: 2M\n# Testcase Example: '[\"flower\",\"flow\",\"...
false
3,214
f7f96b19bdc20f732566709a7801002fe49d49eb
''' Character class ''' import pygame from time import sleep class Character: def __init__(self, screen, side_length, border_width, valid_points, start_point, end_point, current_position, a_colour, na_colour,\ keys=None, k_colour=None): self.screen = screen # pygame screen self.side_length = side_length # ...
[ "'''\nCharacter class\n'''\n\nimport pygame\nfrom time import sleep\n\nclass Character:\n\n\tdef __init__(self, screen, side_length, border_width, valid_points, start_point, end_point, current_position, a_colour, na_colour,\\\n\t\t\t\tkeys=None, k_colour=None):\n\n\t\tself.screen = screen # pygame screen\n\t\tself....
false
3,215
b5949b40d731178bdbab776af8877921dcdfbf15
class _ProtectedClass: pass class MyClass: pass class OtherClass(MyClass): pass def _protected_fun() -> MyClass: return variable # noqa: F821 def my_fun() -> MyClass: return variable # noqa: F821 def my_fun2() -> MyClass: return variable # noqa: F821 variable: MyClass variable_wit...
[ "class _ProtectedClass:\n pass\n\n\nclass MyClass:\n pass\n\n\nclass OtherClass(MyClass):\n pass\n\n\ndef _protected_fun() -> MyClass:\n return variable # noqa: F821\n\n\ndef my_fun() -> MyClass:\n return variable # noqa: F821\n\n\ndef my_fun2() -> MyClass:\n return variable # noqa: F821\n\n\nv...
false
3,216
4f19eed272c12be137df92bfd3c72e978408c974
#!/usr/bin/python3 __author__ = "yang.dd" """ example 090 """ # list # 新建list testList = [10086, "中国移动", [1, 2, 3, 4]] # 访问列表长度 print("list len: ", len(testList)) # 切片 print("切片(slice):", testList[1:]) # 追加 print("追加一个元素") testList.append("i'm new here!"); print("list len: ", len(testLi...
[ "#!/usr/bin/python3\r\n\r\n__author__ = \"yang.dd\"\r\n\r\n\"\"\"\r\n example 090\r\n\"\"\"\r\n# list\r\n# 新建list\r\ntestList = [10086, \"中国移动\", [1, 2, 3, 4]]\r\n\r\n# 访问列表长度\r\nprint(\"list len: \", len(testList))\r\n\r\n# 切片\r\nprint(\"切片(slice):\", testList[1:])\r\n\r\n# 追加\r\n\r\nprint(\"追加一个元素\")\r\ntestLi...
false
3,217
daa287eeb967d47c9a8420beccf531d9c157e925
from setuptools import setup setup(name='discord-ext-menus', author='TierGamerpy', url='https://github.com/TierGamerpy/discord-ext-menus', version= 0.1, packages=['discord.ext.menus'], description='An extension module to make reaction based menus with discord.py', install_requires=['...
[ "from setuptools import setup\nsetup(name='discord-ext-menus',\n author='TierGamerpy',\n url='https://github.com/TierGamerpy/discord-ext-menus',\n version= 0.1,\n packages=['discord.ext.menus'],\n description='An extension module to make reaction based menus with discord.py',\n install...
false
3,218
4c43c181dbba1680e036750a2a2ea1185bbe91da
from django.shortcuts import render from rest_framework import generics from rest_framework import mixins from django.contrib.auth.models import User from rest_framework import permissions from rest_framework.decorators import api_view from rest_framework.response import Response from rest_framework.request import Req...
[ "from django.shortcuts import render\nfrom rest_framework import generics\nfrom rest_framework import mixins\nfrom django.contrib.auth.models import User\nfrom rest_framework import permissions\n\nfrom rest_framework.decorators import api_view\nfrom rest_framework.response import Response\nfrom rest_framework.reque...
false
3,219
c8dc143c09aa7f677167a4942ae1c4a0fbf75128
from django import forms from .models import GetInTouch class GetInTouchForm(forms.ModelForm): class Meta: model = GetInTouch fields = '__all__'
[ "from django import forms\nfrom .models import GetInTouch\n\n\nclass GetInTouchForm(forms.ModelForm):\n class Meta:\n model = GetInTouch\n fields = '__all__'", "from django import forms\nfrom .models import GetInTouch\n\n\nclass GetInTouchForm(forms.ModelForm):\n\n\n class Meta:\n model...
false
3,220
3eaced9609c7adfa5457d7dcad8b2dfaeb697b16
############################################## # Binary Tree # # by Vishal Nirmal # # # # A Binary Tree ADT implementation. # ############################################## class BinaryTree: def __init_...
[ "##############################################\n# Binary Tree #\n# by Vishal Nirmal #\n# #\n# A Binary Tree ADT implementation. #\n##############################################\n\n\n\n\nclass BinaryTree:\n...
false
3,221
56c5c515de8490f2e3516563e037c375aba03667
#!/usr/bin/python # ~~~~~============== HOW TO RUN ==============~~~~~ # 1) Configure things in CONFIGURATION section # 2) Change permissions: chmod +x bot.py # 3) Run in loop: while true; do ./bot.py; sleep 1; done from __future__ import print_function import sys import socket import json import time # ~~~~~==...
[ "#!/usr/bin/python\n\n# ~~~~~============== HOW TO RUN ==============~~~~~\n# 1) Configure things in CONFIGURATION section\n# 2) Change permissions: chmod +x bot.py\n# 3) Run in loop: while true; do ./bot.py; sleep 1; done\n\nfrom __future__ import print_function\n\nimport sys\nimport socket\nimport json\nimpor...
false
3,222
59596c69df6a2c453fd147a9c8a2c7d47ed79fb3
# Generated by Django 2.1.2 on 2018-10-26 12:40 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('core', '0007_auto_20181010_0852'), ('accounts', '0004_playercards'), ] operations = [ migrations.RenameModel( old_name='PlayerCa...
[ "# Generated by Django 2.1.2 on 2018-10-26 12:40\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('core', '0007_auto_20181010_0852'),\n ('accounts', '0004_playercards'),\n ]\n\n operations = [\n migrations.RenameModel(\n ...
false
3,223
18689741a33e6d17e694ee0619a1f36d8d178cbb
from django.shortcuts import * from shop.models import * from django.db import transaction from django.core.exceptions import * @transaction.atomic def computers(request): ctx = {} computer = Computer.objects.all() ctx['brand'] = Brand.objects.all() if request.method == 'POST': if request.POST['computer_i...
[ "from django.shortcuts import *\nfrom shop.models import *\nfrom django.db import transaction\nfrom django.core.exceptions import *\n\n@transaction.atomic\ndef computers(request):\n ctx = {}\n computer = Computer.objects.all()\n ctx['brand'] = Brand.objects.all()\n\n if request.method == 'POST':\n if request...
false
3,224
4989db28db0f823a54ff0942fbc40fc4640da38f
#!/usr/bin/python # Copyright 2014 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
[ "#!/usr/bin/python\n# Copyright 2014 Google Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unle...
false
3,225
098488fd10bcf81c4efa198a44d2ff87e4f8c130
# 約分して、互いに素な(1,3) (3,1)のようなペアを作りカウントする # 正のグループと負のグループを別々に管理 # 正のグループの相手が負のグループに存在した場合、 # どちらかのグループから好きなだけ選ぶか、どちらも選ばないかしかない # 誰ともペアにならなかったグループの個数を全て足してP個だとして、2^P通りを掛ける # (0,0)については、その中から1つ選ぶか、選ばないかしかない import sys readline = sys.stdin.readline N = int(readline()) import math zeropair = 0 zeroa = 0 zerob = 0 from coll...
[ "# 約分して、互いに素な(1,3) (3,1)のようなペアを作りカウントする\n# 正のグループと負のグループを別々に管理\n# 正のグループの相手が負のグループに存在した場合、\n# どちらかのグループから好きなだけ選ぶか、どちらも選ばないかしかない\n# 誰ともペアにならなかったグループの個数を全て足してP個だとして、2^P通りを掛ける\n# (0,0)については、その中から1つ選ぶか、選ばないかしかない\n\nimport sys\nreadline = sys.stdin.readline\n\nN = int(readline())\nimport math\n\nzeropair = 0\nzeroa = 0\...
false
3,226
7d6196268b85861e76efaa53e14976f2eae09405
import pandas as pd df1 = pd.read_csv('Tweets1.csv', names=['tweet']) df2 = pd.read_csv('Tweets2.csv', names=['tweet']) df3 = pd.read_csv('Tweets3.csv', names=['tweet']) df = pd.concat([df1,df2,df3], axis=0, join='outer', ignore_index=False, keys=None,levels=None, names=None, verify_integrity=False, copy=True)...
[ "import pandas as pd \r\n\r\ndf1 = pd.read_csv('Tweets1.csv', names=['tweet'])\r\ndf2 = pd.read_csv('Tweets2.csv', names=['tweet'])\r\ndf3 = pd.read_csv('Tweets3.csv', names=['tweet'])\r\n\r\ndf = pd.concat([df1,df2,df3], axis=0, join='outer', ignore_index=False, keys=None,levels=None, names=None, verify_integrity=...
false
3,227
72ce7c48c9d1a7bcdbaead12648d03970663a11e
import tornado.web import tornado.escape from torcms.core.base_handler import BaseHandler from owslib.csw import CatalogueServiceWeb from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox class DirectorySearchHandler(BaseHandler): def initialize(self): super(DirectorySearchHandler, self).initializ...
[ "import tornado.web\nimport tornado.escape\nfrom torcms.core.base_handler import BaseHandler\nfrom owslib.csw import CatalogueServiceWeb\nfrom owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox\n\n\nclass DirectorySearchHandler(BaseHandler):\n def initialize(self):\n super(DirectorySearchHandler, s...
false
3,228
bae4eb94d561f7aa810718840ff7c2de52cb0d6f
import os import unittest import json from flask_sqlalchemy import SQLAlchemy from app import create_app from models import * from dotenv import load_dotenv, find_dotenv load_dotenv(find_dotenv()) # auth tokens should be updated before running tests, # make sure update the tokens in setup.sh # read the README to kno...
[ "import os\nimport unittest\nimport json\nfrom flask_sqlalchemy import SQLAlchemy\n\nfrom app import create_app\nfrom models import *\nfrom dotenv import load_dotenv, find_dotenv\n\nload_dotenv(find_dotenv())\n\n# auth tokens should be updated before running tests,\n# make sure update the tokens in setup.sh\n# read...
false
3,229
53cf6e97c3b71b1063d5b6bce5aa444933b69809
from dagster import job, op @op def do_something(): return "foo" @job def do_it_all(): do_something()
[ "from dagster import job, op\n\n\n@op\ndef do_something():\n return \"foo\"\n\n\n@job\ndef do_it_all():\n do_something()\n", "from dagster import job, op\n\n\n@op\ndef do_something():\n return 'foo'\n\n\n@job\ndef do_it_all():\n do_something()\n", "<import token>\n\n\n@op\ndef do_something():\n r...
false
3,230
9cc64edc81ab39b0ab2cd47661c9809545b03ac6
''' Twitter settings Input your app credentials below https://apps.twitter.com ''' # consumer key CONSUMER_KEY = '' # consumer secret CONSUMER_SECRET = '' ''' App settings ''' # Where to save tokens (JSON) TOKENS_PATH = '/tmp/twitter-tokens.json' # Redirect-back to URL after authenticated (optional) REDIRECT_TO = ''...
[ "'''\nTwitter settings\nInput your app credentials below\nhttps://apps.twitter.com\n'''\n\n# consumer key\nCONSUMER_KEY = ''\n# consumer secret\nCONSUMER_SECRET = ''\n\n'''\nApp settings\n'''\n# Where to save tokens (JSON)\nTOKENS_PATH = '/tmp/twitter-tokens.json'\n\n# Redirect-back to URL after authenticated (opti...
false
3,231
8bd5eff12e68f7145676f5e089b51376a82ab489
_base_ = "../model.py" model = dict( type="ImageClassifier", task="classification", pretrained=None, backbone=dict(), head=dict(in_channels=-1, loss=dict(type="CrossEntropyLoss", loss_weight=1.0), topk=(1, 5)), ) checkpoint_config = dict(type="CheckpointHookWithValResults")
[ "_base_ = \"../model.py\"\n\nmodel = dict(\n type=\"ImageClassifier\",\n task=\"classification\",\n pretrained=None,\n backbone=dict(),\n head=dict(in_channels=-1, loss=dict(type=\"CrossEntropyLoss\", loss_weight=1.0), topk=(1, 5)),\n)\n\ncheckpoint_config = dict(type=\"CheckpointHookWithValResults\"...
false
3,232
36257340ebbc6bd2c7fa5995511b2c859f58f8e5
from keras.layers import Dense, Activation, Dropout from keras.utils.visualize_util import plot from keras.models import Sequential from emotions import FER2013Dataset _deep_models = {} def deep_model(model_name): def wrapper(cls): _deep_models[model_name] = cls return cls return wrapper ...
[ "from keras.layers import Dense, Activation, Dropout\nfrom keras.utils.visualize_util import plot\nfrom keras.models import Sequential\n\nfrom emotions import FER2013Dataset\n\n\n_deep_models = {}\n\n\ndef deep_model(model_name):\n def wrapper(cls):\n _deep_models[model_name] = cls\n return cls\n ...
false
3,233
cc99811321083147540a00e8029b792c8afc2ada
import json import requests import random import boto3 from email.parser import BytesParser, Parser from email.policy import default ################################## endpoint = 'https://5295t8jcs0.execute-api.us-east-1.amazonaws.com/Prod' ################################## def get_msg_body(msg): type = msg.get_...
[ "import json\nimport requests\nimport random\nimport boto3\nfrom email.parser import BytesParser, Parser\nfrom email.policy import default\n\n##################################\nendpoint = 'https://5295t8jcs0.execute-api.us-east-1.amazonaws.com/Prod'\n##################################\n\ndef get_msg_body(msg):\n ...
false
3,234
8f311e15c15fe3309218dfaed5eefa4a8fc3f453
# GERALDO AMELIO DE LIMA JUNIOR # UNIFIP - Patos # 05 de março de 2020 # Questão 08 - Escreva um programa que leia um valor inteiro e calcule o seu cubo. n = int(input('Digite um numero:')) t = n*3 print('O triplo de {} vale {}.'.format(n, t))
[ "# GERALDO AMELIO DE LIMA JUNIOR\n# UNIFIP - Patos\n# 05 de março de 2020\n# Questão 08 - Escreva um programa que leia um valor inteiro e calcule o seu cubo.\n\nn = int(input('Digite um numero:'))\nt = n*3\nprint('O triplo de {} vale {}.'.format(n, t))\n", "n = int(input('Digite um numero:'))\nt = n * 3\nprint('O...
false
3,235
d443e9054481984d5372343170254268dca8a3b1
#!/usr/local/bin/python3 import time, json, os, sqlite3, uuid, json, base64, sys import requests as http import numpy as np from os.path import isfile, join from datetime import date, datetime from argparse import ArgumentParser PRINTER_IP = "" FRAMERATE = 30 TIMELAPSE_DURATION = 60 TIMELAPSE_PATH = "timelapses" DATA...
[ "#!/usr/local/bin/python3\nimport time, json, os, sqlite3, uuid, json, base64, sys\nimport requests as http\nimport numpy as np\nfrom os.path import isfile, join\nfrom datetime import date, datetime\nfrom argparse import ArgumentParser\n\nPRINTER_IP = \"\"\n\nFRAMERATE = 30\nTIMELAPSE_DURATION = 60\nTIMELAPSE_PATH ...
false
3,236
33ec822f6149a57244edf6d8d99a5b3726600c2e
'Attempts to use <http://countergram.com/software/pytidylib>.' try: import tidylib def tidy(html): html, errors = tidylib.tidy_document(html, options={'force-output': True, 'output-xhtml': True, 'tidy-mark': False}) return html except ImportError: def tidy(html): return html
[ "'Attempts to use <http://countergram.com/software/pytidylib>.'\n\ntry:\n import tidylib\n\n def tidy(html):\n html, errors = tidylib.tidy_document(html, options={'force-output': True,\n 'output-xhtml': True, 'tidy-mark': False})\n return html\n \nexcept ImportError:\n def tidy(html):\n return htm...
false
3,237
14761cc2593556f58a7dc4e499db71456d7c7048
import numpy as np import cv2 from matplotlib import pyplot as plt from matplotlib import cm import imageio # # Backpack values # fx = 7190.247 # lense focal length # baseline = 174.945 # distance in mm between the two cameras (values from middlebury) # units = 0.001 # depth units...
[ "import numpy as np\nimport cv2 \nfrom matplotlib import pyplot as plt\nfrom matplotlib import cm\nimport imageio\n\n# # Backpack values\n# fx = 7190.247 # lense focal length\n# baseline = 174.945 # distance in mm between the two cameras (values from middlebury)\n# units = 0.001 ...
false
3,238
4572e243f75ad92c04f5cdc0b454df7389183a6a
import urllib.request def get_html(url): """ Returns the html of url or None if status code is not 200 """ req = urllib.request.Request( url, headers={ 'User-Agent': 'Python Learning Program', 'From': 'hklee310@gmail.com' } ) resp = urllib.reques...
[ "import urllib.request\n\n\ndef get_html(url):\n \"\"\"\n Returns the html of url or None if status code is not 200\n \"\"\"\n req = urllib.request.Request(\n url,\n headers={\n 'User-Agent': 'Python Learning Program',\n 'From': 'hklee310@gmail.com'\n }\n )\...
false
3,239
f100757fcb1bef334f9f8eacae83af551d2bac5b
from chalicelib.utilities import * def Error(app): @app.route('/errors', cors=True, methods=['POST']) @printError def errors(): request = app.current_request data = request.json_body print(data) return data
[ "from chalicelib.utilities import *\n\ndef Error(app):\n @app.route('/errors', cors=True, methods=['POST'])\n @printError\n def errors():\n request = app.current_request\n data = request.json_body\n \n print(data)\n\n return data", "from chalicelib.utilities import *\n\n\ndef Error(app):\n\n ...
false
3,240
082e3350c5827ff2ca909084f2d6a206ae21a7e6
#!/usr/bin/env python # coding=utf-8 operators = ['-', '~', '++', '--', '*', '!', '/', '*', '%', '+', '-', '>', '>=', '<', '<=', '==', '!=', '&&', '||', '='] types = ['int ', 'double ', 'float ', 'char '] toDelete = types + ['struct '] toRepleace = [('printf(', 'print('), ('++', ' += 1'), ('--', ' -= 1')...
[ "#!/usr/bin/env python\n# coding=utf-8\n\noperators = ['-', '~', '++', '--', '*', '!', '/', '*', '%', '+', '-', \n '>', '>=', '<', '<=', '==', '!=', '&&', '||', '=']\ntypes = ['int ', 'double ', 'float ', 'char ']\ntoDelete = types + ['struct ']\ntoRepleace = [('printf(', 'print('), ('++', ' += 1'), ('-...
false
3,241
f253816d08407950caad28f1ce630ac2b099aa70
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
[ "# coding=utf-8\n# Copyright 2019 The Google Research Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless requ...
false
3,242
69721dca0f5d8396e330696cde52bfabad33c895
from sikuli import * import logging import myTools from datetime import date import reports_Compare #---------------------------------------------------# def fSet_BillDate(pMonth): #---------------------------------------------------# if pMonth == 13: pMonth = 12 logging.debug('- change bill dat...
[ "from sikuli import *\nimport logging\nimport myTools\nfrom datetime import date\nimport reports_Compare\n\n#---------------------------------------------------#\ndef fSet_BillDate(pMonth):\n#---------------------------------------------------#\n\n if pMonth == 13:\n pMonth = 12 \n\n logging.debug(...
false
3,243
9c935e9ef298484d565256a420b867e800c3df55
""" Contains different comparator classes for model output data structures. """ import copy def tuple_to_string(tuptup): """ Converts a tuple to its string representation. Uses different separators (;, /, |) for different depths of the representation. Parameters ---------- tuptup : list ...
[ "\"\"\" Contains different comparator classes for model output data structures.\n\n\"\"\"\n\nimport copy\n\ndef tuple_to_string(tuptup):\n \"\"\" Converts a tuple to its string representation. Uses different separators (;, /, |) for\n different depths of the representation.\n\n Parameters\n ----------\n...
false
3,244
a7a219e9ea5cdec004ef936958994ed1f5a96103
import xlrd def get_rosters_from_excel(django_file): workbook = xlrd.open_workbook(file_contents=django_file.read()) worksheet = workbook.sheet_by_name('Match_Rosters') num_rows = worksheet.nrows - 1 cur_row = -1 rosters = [] while cur_row < num_rows: cur_row += 1 if workshe...
[ "import xlrd\n\ndef get_rosters_from_excel(django_file):\n workbook = xlrd.open_workbook(file_contents=django_file.read())\n worksheet = workbook.sheet_by_name('Match_Rosters')\n\n num_rows = worksheet.nrows - 1\n cur_row = -1\n\n rosters = []\n\n while cur_row < num_rows:\n cur_row += 1\n\...
false
3,245
e7060658ae1838b0870b2a3adb61c9f8d78c93c7
#!/usr/bin/env python3 import sys all_neighbors_coord = [] for i in range(-1, 2): for j in range(-1, 2): for k in range(-1, 2): if i != 0 or j != 0 or k != 0: all_neighbors_coord.append((i, j, k)) def add_coord(c1, c2): return (c1[0] + c2[0], c1[1] + c2[1], c1[2] + c2[2]) ...
[ "#!/usr/bin/env python3\n\nimport sys\n\nall_neighbors_coord = []\nfor i in range(-1, 2):\n for j in range(-1, 2):\n for k in range(-1, 2):\n if i != 0 or j != 0 or k != 0:\n all_neighbors_coord.append((i, j, k))\n\ndef add_coord(c1, c2):\n return (c1[0] + c2[0], c1[1] + c2[1]...
false
3,246
e28cca2273e1c3ad4b8a955843e7dfb45c00694c
# -*- coding:utf-8 -*- import math r = float(input()) print("{0:f} {1:f}".format(r*r*math.pi,2*r*math.pi))
[ "# -*- coding:utf-8 -*-\nimport math\nr = float(input())\nprint(\"{0:f} {1:f}\".format(r*r*math.pi,2*r*math.pi))", "import math\nr = float(input())\nprint('{0:f} {1:f}'.format(r * r * math.pi, 2 * r * math.pi))\n", "<import token>\nr = float(input())\nprint('{0:f} {1:f}'.format(r * r * math.pi, 2 * r * math.pi)...
false
3,247
1d314a04625cfadf574f122b95577c1e677a8b35
#! /usr/bin/env python from thor.tree import TreeNode class Solution(object): def postorder_traversal(self, root: TreeNode): if not root: return [] else: return self.postorder_traversal(root.left) + self.postorder_traversal(root.right) + [root.val]
[ "#! /usr/bin/env python\nfrom thor.tree import TreeNode\n\n\nclass Solution(object):\n\tdef postorder_traversal(self, root: TreeNode):\n\t\tif not root:\n\t\t\treturn []\n\t\telse:\n\t\t\treturn self.postorder_traversal(root.left) + self.postorder_traversal(root.right) + [root.val]\n", "from thor.tree import Tree...
false
3,248
f680503488a2780624b28e49b045aad75506d8c5
class SensorReadings: def __init__(self, sense_hat): self.temprerature_humidity_sensor = sense_hat.get_temperature_from_humidity() self.temperature_pressure_sensor = sense_hat.get_temperature_from_pressure() self.humidity = sense_hat.get_humidity() self.pressure = sense_hat.get_pressure() def prin...
[ "class SensorReadings:\n\n def __init__(self, sense_hat):\n self.temprerature_humidity_sensor = sense_hat.get_temperature_from_humidity()\n self.temperature_pressure_sensor = sense_hat.get_temperature_from_pressure()\n self.humidity = sense_hat.get_humidity()\n self.pressure = sense_hat.get_pressure()\...
false
3,249
b791afec1c9fb214d1f3b4ec0ec67f905d96aabf
# link https://deeplizard.com/learn/video/QK_PP_2KgGE import gym import numpy as np import random import time from IPython.display import clear_output # setup the env env = gym.make("FrozenLake8x8-v0", is_slippery=False) observation = env.reset() # setup the q-table action_space_size = env.action_space.n state_space_...
[ "# link https://deeplizard.com/learn/video/QK_PP_2KgGE\nimport gym\nimport numpy as np\nimport random\nimport time\nfrom IPython.display import clear_output\n\n# setup the env\nenv = gym.make(\"FrozenLake8x8-v0\", is_slippery=False)\nobservation = env.reset()\n\n# setup the q-table\naction_space_size = env.action_s...
false
3,250
d0a6bfb729a150863303621a136ae80e96ae32d0
from tilBackend.celery import app import smtplib import email import ssl #librerias pruebas from celery.task.schedules import crontab from celery.decorators import periodic_task from celery.utils.log import get_task_logger from celery import Celery @app.task def correo(): try: port = 587 smtp_serve...
[ "from tilBackend.celery import app\nimport smtplib\nimport email\nimport ssl\n#librerias pruebas\nfrom celery.task.schedules import crontab\nfrom celery.decorators import periodic_task\nfrom celery.utils.log import get_task_logger\nfrom celery import Celery\n\n@app.task\ndef correo():\n try:\n port = 587\...
false
3,251
8dae8a89d08bc522f9a5fdde8aeb9e322fafcbec
import pymongo import os,sys import re from db_User import * from db_Event import * class ClassRoom: # 链接本地客户端 __myclient = pymongo.MongoClient("mongodb://localhost:27017") # 创建数据库 __mydb = __myclient["MMKeyDB"] # 创建新的集合 __mycol = __mydb["ClassRoom"] # 判断是否输入id或是输入name,如果有输入则转译 def ...
[ "import pymongo\nimport os,sys\nimport re\n\n\nfrom db_User import *\nfrom db_Event import *\n\n\nclass ClassRoom:\n # 链接本地客户端\n __myclient = pymongo.MongoClient(\"mongodb://localhost:27017\")\n # 创建数据库\n __mydb = __myclient[\"MMKeyDB\"]\n # 创建新的集合\n __mycol = __mydb[\"ClassRoom\"]\n\n # 判断是否输入...
false
3,252
049950bd4bbf7903218bb8fb3a4c91492d6af17b
# Copyright 2015 gRPC authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing...
[ "# Copyright 2015 gRPC authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agree...
false
3,253
55df8d13ddf28f7b0477329bee743471a0780f24
import os from app_web import sg from sendgrid.helpers.mail import * import pdfkit from models.user import User from models.expense import Expense from models.statement import Statement from models.category import Category import tempfile import subprocess from .aws_uploader import upload_image_to_s3 import datetime fr...
[ "import os\nfrom app_web import sg\nfrom sendgrid.helpers.mail import *\nimport pdfkit\nfrom models.user import User\nfrom models.expense import Expense\nfrom models.statement import Statement\nfrom models.category import Category\nimport tempfile\nimport subprocess\nfrom .aws_uploader import upload_image_to_s3\nim...
false
3,254
b09d0806dfc6f4badfd9f2ac9c3f6d17d3df8e8c
from features.steps.web.test_home_page import * from features.steps.mobile.test_home_page import * from features.steps.web.test_login_page import *
[ "from features.steps.web.test_home_page import *\nfrom features.steps.mobile.test_home_page import *\nfrom features.steps.web.test_login_page import *", "from features.steps.web.test_home_page import *\nfrom features.steps.mobile.test_home_page import *\nfrom features.steps.web.test_login_page import *\n", "<im...
false
3,255
4e98ebd040297cb9472368478452bc484e0aaa04
water = 400 milk = 540 coffee = 120 cups = 9 money = 550 def buying(): global water global coffee global cups global milk global money choice_coffee = input("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:") if choice_coffee == "1": ...
[ "water = 400\r\nmilk = 540\r\ncoffee = 120\r\ncups = 9\r\nmoney = 550\r\n\r\n\r\ndef buying():\r\n global water\r\n global coffee\r\n global cups\r\n global milk\r\n global money\r\n choice_coffee = input(\"What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:\")\r...
false
3,256
9543992e1b115f83640a07c4d4372be0fb465199
# Reddit API feed import praw import sys import os def main(): if os.getenv("REDDIT_CLIENT_ID") is None: print "Set your Reddit environment variables:" print "REDDIT_CLIENT_ID and REDDIT_CLIENT_SECRET" sys.exit() client_id = os.environ['REDDIT_CLIENT_ID'] client_secret = os.environ...
[ "# Reddit API feed\n\nimport praw\nimport sys\nimport os\n\ndef main():\n if os.getenv(\"REDDIT_CLIENT_ID\") is None:\n print \"Set your Reddit environment variables:\"\n print \"REDDIT_CLIENT_ID and REDDIT_CLIENT_SECRET\"\n sys.exit()\n client_id = os.environ['REDDIT_CLIENT_ID']\n cli...
true
3,257
29dc940292a6805aabfa5bed22bb75d31140c83f
def check_bit4(input): mas=0b1000 desired=input & mas if desired>0: return "om" else : return "off"
[ "def check_bit4(input):\n\tmas=0b1000\n\tdesired=input & mas\n\tif desired>0:\n\t\treturn \"om\"\n\telse :\n\t\treturn \"off\"\n\n\n", "def check_bit4(input):\n mas = 8\n desired = input & mas\n if desired > 0:\n return 'om'\n else:\n return 'off'\n", "<function token>\n" ]
false
3,258
846a42a997539a45576d3ecbe0bd290e00b55935
from output.models.sun_data.ctype.content_type.content_type00401m.content_type00401m_xsd.content_type00401m import ( A1, A, ) __all__ = [ "A1", "A", ]
[ "from output.models.sun_data.ctype.content_type.content_type00401m.content_type00401m_xsd.content_type00401m import (\n A1,\n A,\n)\n\n__all__ = [\n \"A1\",\n \"A\",\n]\n", "from output.models.sun_data.ctype.content_type.content_type00401m.content_type00401m_xsd.content_type00401m import A1, A\n__all_...
false
3,259
4c42bad4197b51be0e9d18307c7b954a29281fe1
#Exercise 5 #Define with names stair1, stair2, and stair3 (from bottom up to top), and insert within the building model, the 3 stair models of the building.
[ "#Exercise 5\n#Define with names stair1, stair2, and stair3 (from bottom up to top), and insert within the building model, the 3 stair models of the building.", "" ]
false
3,260
6829f7bcbc1b12500795eec19829ff077502e270
import os import math def get_datas(): filename = None while True: filename = input('Please enter filename:') if not filename.strip(): print('Filename is empty!') continue if not os.path.exists(filename): print('File is not exists!') conti...
[ "import os\nimport math\n\ndef get_datas():\n filename = None\n while True:\n filename = input('Please enter filename:')\n if not filename.strip():\n print('Filename is empty!')\n continue\n if not os.path.exists(filename):\n print('File is not exists!')\n...
false
3,261
50fa8852f74f4d2428fb238a86dd1feedb210877
# Umut Cakan Computer Science S006742 # Fibonacci list. First and second terms are static. fib_list = [0, 1] # Current index. CURRENT_INDEX = 2 # Function for the checking input is a Fibonacci number or not. def check_fibonacci_number(): global CURRENT_INDEX # Get the fibonacci numbers that are less or equal ...
[ "# Umut Cakan Computer Science S006742\n\n# Fibonacci list. First and second terms are static.\nfib_list = [0, 1]\n# Current index.\nCURRENT_INDEX = 2\n\n# Function for the checking input is a Fibonacci number or not.\ndef check_fibonacci_number():\n global CURRENT_INDEX\n # Get the fibonacci numbers that are...
false
3,262
8981d53641d22430efb2dd43401fab562b8a95ed
import socket comms_socket1 = socket.socket() comms_socket2 = socket.socket() comms_socket1.bind(("120.79.26.97",55000)) comms_socket2.bind(("120.79.26.97",55001)) comms_socket1.listen() user1,address1 = comms_socket1.accept() comms_socket2.listen() user2,address2 = comms_socket2.accept() while True: send_date = ...
[ "import socket\n\ncomms_socket1 = socket.socket()\ncomms_socket2 = socket.socket()\ncomms_socket1.bind((\"120.79.26.97\",55000))\ncomms_socket2.bind((\"120.79.26.97\",55001))\ncomms_socket1.listen()\nuser1,address1 = comms_socket1.accept()\ncomms_socket2.listen()\nuser2,address2 = comms_socket2.accept()\n\nwhile Tr...
false
3,263
1c0f194bbdc6f7e3e4feb114e521aa958f11e83e
from typing import List from pydantic import BaseModel class BinBase(BaseModel): name: str = None title: str = None class BinCreate(BinBase): owner_id: int password: str class Bin(BinBase): id: int # TODO: token? class Config(): orm_mode = True class UserBase(BaseModel): ...
[ "from typing import List\nfrom pydantic import BaseModel\n\nclass BinBase(BaseModel):\n name: str = None\n title: str = None\n\n\nclass BinCreate(BinBase):\n owner_id: int\n password: str\n\n\nclass Bin(BinBase):\n id: int\n # TODO: token?\n\n class Config():\n orm_mode = True\n\n\nclass...
false
3,264
5261ae90a67e2df8dd1c679a8046ee3e0cbc6221
''' Module for handling configurable portions of tools ''' from json import load default_file_loc = 'config.json' config = None def loadConfiguration(fileloc): '''Loads configuration from file location''' global config with open(fileloc, 'r') as file_: conf = load(file_) if config is None: ...
[ "'''\nModule for handling configurable portions of tools\n'''\n\nfrom json import load\n\ndefault_file_loc = 'config.json'\nconfig = None\n\ndef loadConfiguration(fileloc):\n '''Loads configuration from file location'''\n global config\n with open(fileloc, 'r') as file_:\n conf = load(file_)\n if...
false
3,265
838279b4f8d9e656c2f90ff06eaff3bd9c12bbef
import pygame from math import sqrt, sin, cos from numpy import arctan from os import path # try these colors or create your own! # each valid color is 3-tuple with values in range [0, 255] BLACK = (0, 0, 0) WHITE = (255, 255, 255) WHITEGRAY = (192, 192, 192) RED = (255, 0, 0) MIDRED = (192, 0, 0) DARKRED = (128, 0, 0...
[ "import pygame\nfrom math import sqrt, sin, cos\nfrom numpy import arctan\nfrom os import path\n\n# try these colors or create your own!\n# each valid color is 3-tuple with values in range [0, 255]\nBLACK = (0, 0, 0)\nWHITE = (255, 255, 255)\nWHITEGRAY = (192, 192, 192)\nRED = (255, 0, 0)\nMIDRED = (192, 0, 0)\nDAR...
false
3,266
624027373f53f62ededc40bfc859f28b5a83ca04
#!/use/bin/python import os, sys from io import BytesIO from pathlib import Path from flask_config import app from flask import send_file from PyPDF2 import PdfFileReader, PdfFileWriter def rotate_pdf(working_dir, filename, rotation): os.chdir(working_dir) output_name = 'pages' rotate_pdf_pages(filename, rotati...
[ "#!/use/bin/python\n\nimport os, sys\nfrom io import BytesIO\nfrom pathlib import Path\nfrom flask_config import app\nfrom flask import send_file\nfrom PyPDF2 import PdfFileReader, PdfFileWriter\n\ndef rotate_pdf(working_dir, filename, rotation):\n os.chdir(working_dir)\n output_name = 'pages'\n rotate_pdf_pages...
false
3,267
1fc1d2e1a7d18b1ef8ee6396210afe47a63ab09f
import sys import os from pyparsing import * import csv def parse_cave_details(details): ########################################################################## # Define the Bretz Grammar. # Sample cave description: # Boring Caverns SE1/4 NW1/4 sec. 16, T. 37 N., R. 10 W., Pulaski County ...
[ "import sys\r\nimport os\r\nfrom pyparsing import *\r\nimport csv\r\n\r\n\r\ndef parse_cave_details(details):\r\n ##########################################################################\r\n # Define the Bretz Grammar.\r\n # Sample cave description:\r\n # Boring Caverns SE1/4 NW1/4 sec. 16, T. 37 N., ...
false
3,268
4524dd5f5cddd475ca39fea7ec94fa3c1df6bd2e
from sharpie import Sharpie class SharpieSet(): def __init__(self): self.sharpies = [] self.usable_sharpies = [] self.usable_sharpies_count = 0 def add_sharpie(self, sharpie: Sharpie): self.sharpies.append(sharpie) def count_usable(self): for i in self.sharpies: ...
[ "from sharpie import Sharpie\n\n\nclass SharpieSet():\n def __init__(self):\n self.sharpies = []\n self.usable_sharpies = []\n self.usable_sharpies_count = 0\n\n def add_sharpie(self, sharpie: Sharpie):\n self.sharpies.append(sharpie)\n\n def count_usable(self):\n for i i...
false
3,269
846682072a125c76fc9ffa011109abce7c3bb5d7
from bs4 import BeautifulSoup, CData import requests,sys,csv,json,os, urllib.request, re import json url2 = "http://ufm.edu/Estudios" def estudios(Minisoup): print("2.Estudios") #now navigate to /Estudios (better if you obtain href from the DOM) try: html_content = requests.get(url2).text except: print(...
[ "from bs4 import BeautifulSoup, CData\nimport requests,sys,csv,json,os, urllib.request, re\nimport json\n\n\nurl2 = \"http://ufm.edu/Estudios\"\ndef estudios(Minisoup):\n print(\"2.Estudios\")\n\n#now navigate to /Estudios (better if you obtain href from the DOM)\ntry:\n html_content = requests.get(url2).tex...
false
3,270
446c438b79f9957289fa85f21516c13d67e2cfaf
from mesa import Model from mesa.space import SingleGrid from mesa.time import BaseScheduler, RandomActivation, SimultaneousActivation from pdpython_model.fixed_model.agents import PDAgent from mesa.datacollection import DataCollector class PDModel(Model): schedule_types = {"Sequential": BaseScheduler, ...
[ "from mesa import Model\nfrom mesa.space import SingleGrid\nfrom mesa.time import BaseScheduler, RandomActivation, SimultaneousActivation\nfrom pdpython_model.fixed_model.agents import PDAgent\n\nfrom mesa.datacollection import DataCollector\n\n\nclass PDModel(Model):\n\n schedule_types = {\"Sequential\": BaseSc...
false
3,271
2fb95fa2b7062085f31c6b1dbb8c1336c3871e93
# # PySNMP MIB module CISCO-L2NAT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-L2NAT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:47:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
[ "#\n# PySNMP MIB module CISCO-L2NAT-MIB (http://snmplabs.com/pysmi)\n# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-L2NAT-MIB\n# Produced by pysmi-0.3.4 at Mon Apr 29 17:47:06 2019\n# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4\n# Using Python version 3.7.3 (defau...
false
3,272
ceab21e41adf171e99e6c3c8541c418d82db6168
class Figure: area = 0 def __new__(cls, *args): if cls is Figure: return None return object.__new__(cls) def add_area(self, other): if isinstance(other, Figure): return self.area + other.area else: raise ValueError("Should pass Figure as...
[ "class Figure:\n area = 0\n\n def __new__(cls, *args):\n if cls is Figure:\n return None\n return object.__new__(cls)\n\n def add_area(self, other):\n if isinstance(other, Figure):\n return self.area + other.area\n else:\n raise ValueError(\"Shou...
false
3,273
5a5b2d0ade5b66981218b4ecf15a2253b7d665f9
#!/usr/bin/python # -*- coding: utf-8 -*- ''' Script for converting the new csv files to the desirable json format ''' import codecs import json import re def creeper(): ''' Settings for creeper file ''' ccPrefix = False inFilename = u'creeper.csv' outFilename = u'Creeper.json' mappingFil...
[ "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n'''\nScript for converting the new csv files to the desirable json format\n'''\nimport codecs\nimport json\nimport re\n\n\ndef creeper():\n '''\n Settings for creeper file\n '''\n ccPrefix = False\n inFilename = u'creeper.csv'\n outFilename = u'Creeper...
false
3,274
d8ea396ff8514cc10e02072ea478f0276584153d
def heapify(lst, index, heap_size): largest = index left_index = 2 * index + 1 right_index = 2 * index + 2 if left_index < heap_size and lst[left_index] > lst[largest]: largest = left_index if right_index < heap_size and lst[right_index] > lst[largest]: largest = right_index if...
[ "def heapify(lst, index, heap_size):\n largest = index\n left_index = 2 * index + 1\n right_index = 2 * index + 2\n if left_index < heap_size and lst[left_index] > lst[largest]:\n largest = left_index\n\n if right_index < heap_size and lst[right_index] > lst[largest]:\n largest = right_...
false
3,275
860908126d473e6c4ed070992a1b518683fd4c27
############################################################### ## File Name: 11_exercise.py ## File Type: Python File ## Author: surge55 ## Course: Python 4 Everybody ## Chapter: Chapter 11 - Regular Expressions ## Excercise: n/a ## Description: Code walkthrough from book ## Other References: associated files...
[ "###############################################################\r\n## File Name: 11_exercise.py\r\n## File Type: Python File\r\n## Author: surge55\r\n## Course: Python 4 Everybody\r\n## Chapter: Chapter 11 - Regular Expressions\r\n## Excercise: n/a\r\n## Description: Code walkthrough from book \r\n## Other Referen...
false
3,276
8cd234c2ec1b36abd992cc1a46147376cc241ede
def non_dupulicates_lette(word): text = list(word); print(text) i=0 for i in range(len(text)): for k in text: print(c) def has_dupulicates(word): d= dict() for c in word: if c not in d: d[c]=1 else: d[c]+=1 ...
[ "def non_dupulicates_lette(word):\n text = list(word);\n print(text)\n i=0\n for i in range(len(text)):\n for k in text:\n print(c)\n \ndef has_dupulicates(word):\n d= dict()\n for c in word:\n if c not in d:\n d[c]=1\n \n else:\n ...
false
3,277
dee7b12862d02837fbb0f2310b136dd768ca7bab
import time import pickle class BayesNetClassifier: def __init__(self, train_file, out_file): self.train_file = train_file self.out_file = out_file self.word_count_loc = {} self.word_probs = {} self.l_probs = {} self.word_counts = {} self.common_wo...
[ "import time\r\nimport pickle\r\n\r\nclass BayesNetClassifier:\r\n def __init__(self, train_file, out_file):\r\n self.train_file = train_file\r\n self.out_file = out_file\r\n self.word_count_loc = {}\r\n self.word_probs = {}\r\n self.l_probs = {}\r\n self.word_counts = {...
false
3,278
86177dfa9b8bed5916703edcc16ea4d01cbabf84
import tkinter as tk import random import numpy as np import copy import time ################################################################################# # # Données de partie NbSimulation = 20000 Data = [ [1,1,1,1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,0,0...
[ "import tkinter as tk\nimport random\nimport numpy as np\nimport copy \nimport time\n\n#################################################################################\n#\n# Données de partie\nNbSimulation = 20000\nData = [ [1,1,1,1,1,1,1,1,1,1,1,1,1],\n [1,0,0,0,0,0,0,0,0,0,0,0,1],\n [1,0,...
false
3,279
4b3664153940b064b424bd77de473a6409437f88
import sys ''' Given a string, does the string contain an equal number of uppercase and lowercase letters? Ignore whitespace, numbers, and punctuation. Return the string “true” if balanced or the string “false” if not balanced. ''' for line in sys.stdin: lower = 0 upper = 0 # Count number of lowercase a...
[ "import sys\n\n'''\nGiven a string, does the string contain an equal number of uppercase and \nlowercase letters? Ignore whitespace, numbers, and punctuation. Return the \nstring “true” if balanced or the string “false” if not balanced.\n'''\nfor line in sys.stdin:\n lower = 0\n upper = 0\n\n # Count numbe...
false
3,280
8cec6778f530cb06e4f6cb2e6e9b6cb192d20f97
# Generated by Django 3.2.6 on 2021-10-10 17:17 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import uuid class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ...
[ "# Generated by Django 3.2.6 on 2021-10-10 17:17\n\nfrom django.conf import settings\nfrom django.db import migrations, models\nimport django.db.models.deletion\nimport uuid\n\n\nclass Migration(migrations.Migration):\n\n initial = True\n\n dependencies = [\n migrations.swappable_dependency(settings.AU...
false
3,281
bf8f7b51b685f0e9131cb4d8a0bfc16ee5ad1263
import os from flask import Flask,request from flask_restful import Resource,Api,reqparse from flask_jwt import JWT,jwt_required from resources.Users import UserRegister from security import authenticate,identity from resources.items import Item, ItemList from resources.stores import Store, StoreList app = Flask(__nam...
[ "import os\nfrom flask import Flask,request\nfrom flask_restful import Resource,Api,reqparse\nfrom flask_jwt import JWT,jwt_required\nfrom resources.Users import UserRegister\nfrom security import authenticate,identity\nfrom resources.items import Item, ItemList\nfrom resources.stores import Store, StoreList\n\napp...
false
3,282
ae3198e68d9479605327b729c01fb15eae87ab98
#!/usr/bin/env python # -*- coding: utf-8 -*- """ test_visual_coding_2p_analysis ---------------------------------- Tests for `visual_coding_2p_analysis` module. """ import pytest @pytest.fixture def decorated_example(): """Sample pytest fixture. See more at: http://doc.pytest.org/en/latest/fixture.html ...
[ "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ntest_visual_coding_2p_analysis\n----------------------------------\n\nTests for `visual_coding_2p_analysis` module.\n\"\"\"\nimport pytest\n\n\n@pytest.fixture\ndef decorated_example():\n \"\"\"Sample pytest fixture.\n See more at: http://doc.pytest.o...
false
3,283
9dbadb2421b04961e8e813831d06abc1ff301566
# -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentation in: # https://doc.scrapy.org/en/latest/topics/items.html import scrapy class JiayuanItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() person_id = scrapy.Field(...
[ "# -*- coding: utf-8 -*-\r\n\r\n# Define here the models for your scraped items\r\n#\r\n# See documentation in:\r\n# https://doc.scrapy.org/en/latest/topics/items.html\r\n\r\nimport scrapy\r\n\r\n\r\nclass JiayuanItem(scrapy.Item):\r\n # define the fields for your item here like:\r\n # name = scrapy.Field()\r...
false
3,284
9a539fd3ce4e3ff75af82407150ab4b550b255c1
class Solution(object): def canWinNim(self, n): """ :type n: int :rtype: bool """ if(n % 4 != 0): return True; return False; """main(): sol = Solution(); sol.canWinNim(4); """
[ "class Solution(object):\n def canWinNim(self, n):\n \"\"\"\n :type n: int\n :rtype: bool\n \"\"\"\n\tif(n % 4 != 0):\n\t\treturn True;\n\treturn False;\n\"\"\"main():\n\tsol = Solution();\n\tsol.canWinNim(4);\n\"\"\"\n" ]
true
3,285
39b07f1a515787e80a1fb822e67e19e2301b894a
import pynucastro as pyna rl = pyna.ReacLibLibrary() h_burn = rl.linking_nuclei(["h1", "he4", "c12", "c13", "n13", "n14", "n15", "o14", "o15", "o16","o17","o18", "f17", "f18","f19", ...
[ "import pynucastro as pyna\n\nrl = pyna.ReacLibLibrary()\n\nh_burn = rl.linking_nuclei([\"h1\", \"he4\",\n \"c12\", \"c13\",\n \"n13\", \"n14\", \"n15\",\n \"o14\", \"o15\", \"o16\",\"o17\",\"o18\",\n \"f17\"...
false
3,286
682495fec200ddad5a68f06bb0ec24e59036e66b
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None ####################### # Iterative solution ####################### class Solution: def reverseList(self, head: ListNode) -> ListNode: if head is None: return h...
[ "# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, x):\n# self.val = x\n# self.next = None\n\n#######################\n# Iterative solution\n#######################\nclass Solution:\n def reverseList(self, head: ListNode) -> ListNode:\n if head is None:\n ...
false
3,287
fbab5826f47163cf82b534d311eae572c5fcd128
import re import pandas as pd import pandas.io.formats.excel from configparser import ConfigParser from datetime import datetime from termcolor import cprint import os import shutil from openpyxl import load_workbook import numpy as np class pairtron(): def affiliation_cleaner(self, affiliation): # print(...
[ "import re\nimport pandas as pd\nimport pandas.io.formats.excel\nfrom configparser import ConfigParser\nfrom datetime import datetime\nfrom termcolor import cprint\nimport os\nimport shutil\nfrom openpyxl import load_workbook\nimport numpy as np\n\nclass pairtron():\n\n def affiliation_cleaner(self, affiliation)...
false
3,288
8bbc929e2ff2321b97195031fa675fbdab269fcb
""" SUMMARY Auxiliary functions, provided here to avoid clutter """ """ Transforms a point (P = [x, y]) using the x, y intervals (Δxy = [Δx, Δy]) into the corresponding discrete point (D = [xd, yd]) loc_min = [x_min, y_min] """ def discretize_location(P, loc_min, Δxy): x_from_start = P[0] - loc_min[0] y_from...
[ "\"\"\"\nSUMMARY\n\nAuxiliary functions, provided here to avoid clutter\n\"\"\"\n\n\n\"\"\"\nTransforms a point (P = [x, y]) using the x, y intervals (Δxy = [Δx, Δy]) into the corresponding discrete point (D = [xd, yd])\nloc_min = [x_min, y_min]\n\"\"\"\ndef discretize_location(P, loc_min, Δxy):\n x_from_start =...
false
3,289
e99c158e54fd86b00e4e045e7fb28d961089800d
import os import hashlib import argparse def hashfile(path, blocksize=65536): afile = open(path, 'rb') hasher = hashlib.md5() buf = afile.read(blocksize) while len(buf) > 0: hasher.update(buf) buf = afile.read(blocksize) afile.close() return hasher.hexdigest() def make_duplic...
[ "import os\nimport hashlib\nimport argparse\n\n\ndef hashfile(path, blocksize=65536):\n afile = open(path, 'rb')\n hasher = hashlib.md5()\n buf = afile.read(blocksize)\n while len(buf) > 0:\n hasher.update(buf)\n buf = afile.read(blocksize)\n afile.close()\n return hasher.hexdigest()...
false
3,290
a8f2d527e9824d3986f4bb49c3cc75fd0d999bf7
from .personal_questions import * from .survey_questions import *
[ "from .personal_questions import *\nfrom .survey_questions import *\n", "<import token>\n" ]
false
3,291
55986f6c2dafe650704660142cf85640e763b26d
#case1 print("My name is Jia-Chi. \nI have an older sister. \nI prefer Coke.\nMy favorite song is \"Amazing Grace\"") #case2 print('''Liang, Jia-Chi 1 Coke Amazing Grace''')
[ "#case1\nprint(\"My name is Jia-Chi. \\nI have an older sister. \\nI prefer Coke.\\nMy favorite song is \\\"Amazing Grace\\\"\")\n#case2\nprint('''Liang, Jia-Chi\n1\nCoke\nAmazing Grace''')\n\n", "print(\n \"\"\"My name is Jia-Chi. \nI have an older sister. \nI prefer Coke.\nMy favorite song is \"Amazing Grace...
false
3,292
6ec39aa712c8abe610418e410883ff168d73126d
from sys import stdin Read = stdin.readline INF = int(1e9) n, m = map(int, Read().split()) graph = [[INF] * (n+1) for _ in range(n+1)] for i in range(1, n+1): for j in range(1, n+1): if i == j: graph[i][j] = 0 for _ in range(m): a, b = map(int, Read().split()) graph[a][b] = 1 for k i...
[ "from sys import stdin\nRead = stdin.readline\nINF = int(1e9)\n\nn, m = map(int, Read().split())\ngraph = [[INF] * (n+1) for _ in range(n+1)]\n\nfor i in range(1, n+1):\n for j in range(1, n+1):\n if i == j:\n graph[i][j] = 0\n\nfor _ in range(m):\n a, b = map(int, Read().split())\n graph...
false
3,293
d2f77afd0d282b1fa4859c5368c9d2c745a5625e
#!/usr/bin/python # # Copyright 2017 Steven Watanabe # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) from MockProgram import * command('strip', '-S', '-x', input_file('bin/darwin-4.2.1/release/target-os-darwin/t...
[ "#!/usr/bin/python\n#\n# Copyright 2017 Steven Watanabe\n#\n# Distributed under the Boost Software License, Version 1.0.\n# (See accompanying file LICENSE_1_0.txt or copy at\n# http://www.boost.org/LICENSE_1_0.txt)\n\nfrom MockProgram import *\n\ncommand('strip', '-S', '-x', input_file('bin/darwin-4.2.1/release/tar...
false
3,294
7413c06a990894c34ee5174d84f0e3bd20abf51f
import sys import numpy as np #################################################################################################### ### These functions all perform QA checks on input files. ### These should catch many errors, but is not exhaustive. #####################################################################...
[ "import sys\nimport numpy as np\n\n####################################################################################################\n### These functions all perform QA checks on input files. \n### These should catch many errors, but is not exhaustive. \n##########################################################...
false
3,295
d7c4bee7245dab1cbb90ee68b8e99994ce7dd219
class Solution: # @param num, a list of integer # @return an integer def longestConsecutive(self, num): sted = {} n = len(num) for item in num: if item in sted: continue sted[item] = item if item-1 in sted: sted[item...
[ "class Solution:\n # @param num, a list of integer\n # @return an integer\n def longestConsecutive(self, num):\n sted = {}\n n = len(num)\n for item in num:\n if item in sted:\n continue\n sted[item] = item\n if item-1 in sted:\n ...
false
3,296
0aec3fbc9f4b9f33aee021fa417c43f0feb0e3d1
import math import time t1 = time.time() # n(3n-1)/2 def isPentagon(item): num = math.floor(math.sqrt(item*2//3))+1 if num*(3*num-1)//2 == item: return True return False # n(2n-1) def isHexagon(item): num = math.floor(math.sqrt(item//2))+1 if num*(2*num-1) == item: return True ...
[ "import math\nimport time\n\nt1 = time.time()\n\n# n(3n-1)/2\ndef isPentagon(item):\n num = math.floor(math.sqrt(item*2//3))+1\n if num*(3*num-1)//2 == item:\n return True\n return False\n\n# n(2n-1)\ndef isHexagon(item):\n num = math.floor(math.sqrt(item//2))+1\n if num*(2*num-1) == item:\n ...
false
3,297
0d14534b210b13ede4a687e418d05d756d221950
from twisted.internet import reactor from scrapy.crawler import Crawler from scrapy.settings import CrawlerSettings from scrapy import log, signals from spiders.songspk_spider import SongsPKSpider from scrapy.xlib.pydispatch import dispatcher def stop_reactor(): reactor.stop() dispatcher.connect(stop_reactor, sig...
[ "from twisted.internet import reactor\nfrom scrapy.crawler import Crawler\nfrom scrapy.settings import CrawlerSettings\nfrom scrapy import log, signals\nfrom spiders.songspk_spider import SongsPKSpider\nfrom scrapy.xlib.pydispatch import dispatcher\n\ndef stop_reactor():\n reactor.stop()\n\ndispatcher.connect(st...
true
3,298
8650e0f1e7f2ac42c3c78191f79810f5befc9f41
import pygame, states, events from settings import all as settings import gui def handleInput(world, event): if event == events.btnSelectOn or event == events.btnEscapeOn: bwd(world) if event%10 == 0: world.sounds['uiaction'].play(0) # world.shouldRedraw = True def bwd(world): if wor...
[ "import pygame, states, events\r\nfrom settings import all as settings\r\n\r\nimport gui\r\n\r\ndef handleInput(world, event):\r\n if event == events.btnSelectOn or event == events.btnEscapeOn:\r\n bwd(world)\r\n\r\n if event%10 == 0:\r\n world.sounds['uiaction'].play(0)\r\n # world.shouldRedraw = True\r\n...
false
3,299
f2786e445bdf66cf6bb66f4cde4c7b2bf819d8aa
# coding: utf-8 # In[1]: import pandas as pd import numpy as np import itertools # Save a nice dark grey as a variable almost_black = '#262626' import matplotlib import seaborn as sns import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap sns.set() get_ipython().magic('matplotlib inline') # I...
[ "\n# coding: utf-8\n\n# In[1]:\n\nimport pandas as pd\nimport numpy as np\nimport itertools\n# Save a nice dark grey as a variable\nalmost_black = '#262626'\nimport matplotlib\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom matplotlib.colors import ListedColormap\nsns.set()\nget_ipython().magic('matpl...
false