blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 133 | path stringlengths 2 333 | src_encoding stringclasses 30
values | length_bytes int64 18 5.47M | score float64 2.52 5.81 | int_score int64 3 5 | detected_licenses listlengths 0 67 | license_type stringclasses 2
values | text stringlengths 12 5.47M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
3c18289032093747dca17826852aa04c11fccbbd | Python | xiaoouLi/Artificial-Intelligence-Projects | /DecisionTree/decisionTree.py | UTF-8 | 9,348 | 3.46875 | 3 | [] | no_license | import sys, math, re
import cPickle as pickle
import readARFF
import copy
import random
# import readARFF2
### takes as input a list of class labels. Returns a float
### indicating the entropy in this data.
###Entropy is, of course, about proportions of positive
###versus negative examples
def entropy(data) :
vals... | true |
044cf904e05ee611cf10f9763b8a89fa0ee44598 | Python | Raj-kar/Python | /Pattern exercise/pattern 13.py | UTF-8 | 260 | 4 | 4 | [] | no_license | # Write a Python program to construct the following pattern, using a nested loop number.
# Expected Output:
# 1
# 22
# 333
# 4444
# 55555
# 666666
# 7777777
# 88888888
# 999999999
row = int(input("Enter a range: "))
for i in range(1,row+1):
print(f"{i}"*i) | true |
b5b054ea431407ed18be42ddc45e882920161e3d | Python | magrco/zmirror | /zmirror/lru_dict.py | UTF-8 | 1,167 | 2.875 | 3 | [
"MIT"
] | permissive | # coding=utf-8
from collections import OrderedDict
class LRUDictManual(OrderedDict): # pragma: no cover
"""一个手动实现的LRUDict"""
def __init__(self, size=32):
super().__init__()
self.maxsize = size
def __getitem__(self, key):
value = super().__getitem__(key)
try:
... | true |
5754c7cdbad404ac7f31a29047b4914788d59a9f | Python | DJreyaB/Colt-Steele-Python-Aglorithms-DataStructures | /LinkedList/Doubly.py | UTF-8 | 252 | 3.015625 | 3 | [] | no_license | class Node:
def __init__(self, val) -> None:
self.val = val
self.next = None
self.prev = None
class DoublyLinkedList:
def __init__(self) -> None:
self.head = None
self.tail = None
self.length = 0 | true |
3ce01bd0d15d420779d4c570c7af445c5e695f7c | Python | NorthcoteHS/10MCOD-Vincent-CROWE | /user/hACKING THE MATRIX.py | UTF-8 | 47 | 3.421875 | 3 | [] | no_license | x = 1
while x > 0:
x = x * 2
print (x)
| true |
13fb1e63dc8329af4b57212a13d311443af7ae49 | Python | MrZhangzhg/nsd_2018 | /nsd1808/devops/day05/deploy_web.py | UTF-8 | 2,248 | 2.828125 | 3 | [] | no_license | import wget
import os
import requests
import hashlib
import tarfile
def has_new_version(live_url, live_fname):
if not os.path.isfile(live_fname):
return True # 如果本地没有版本文件,意味着有新版本
with open(live_fname) as fobj:
local_version = fobj.read()
r = requests.get(live_url)
if r.text != loca... | true |
1b5f6c942169b9a3d818474a375e378424b98a8e | Python | larsweiler/TiLDA | /progressbar.py | UTF-8 | 746 | 2.921875 | 3 | [] | no_license | ### Author: Lars Weiler
### Description: progress bar
### Category: fun
### License: THE NERD-WARE LICENSE (Revision 2)
### Appname: progressbar
import pyb
import ugfx
ugfx.init()
h = ugfx.height()
w = ugfx.width()
ugfx.clear(ugfx.BLACK)
lw = 240 # progress bar width
lh = 40 # progress bar height
m = 5 ... | true |
23cb664ba10e7d37176b4c4f904c27b07f9b7904 | Python | gbroques/cozplay-demos | /horseshoe/horse_shoe_slot.py | UTF-8 | 513 | 2.953125 | 3 | [] | no_license | '''
Horse Shoe game slot class to store current state information
@class HorseShoeSlot
@author - Team Cozplay
'''
class HorseShoeSlot:
def __init__(self, state=0, active=0):
self._state = state
self._active = active
@property
def state(self):
return self._state
@state.setter
... | true |
9b9300d6fe3944c13536f4e07a6bf2951d9a04d7 | Python | lilitotaryan/eventnet-back-end | /event_crud/errors.py | UTF-8 | 2,894 | 2.515625 | 3 | [] | no_license | from main_app.errors import MainAppException
class EventCrudException(MainAppException):
default_code = "event_crud_error"
class EventDataNotValid(EventCrudException):
def __init__(self):
super().__init__(code=16,
message='Event Data is not valid.',
... | true |
d888d843f5257ca7f265ce4654961fae643ea3b9 | Python | aliemelo/ssh-exercise | /copy_file.py | UTF-8 | 2,263 | 2.71875 | 3 | [] | no_license | import sys
import argparse
import logging
import os
import util.loggerinitializer as utl
from util import ssh_manip
# Initialize log object
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
utl.initialize_logger(os.getcwd(), logger)
def main():
parser = argparse.ArgumentParser(description="A to... | true |
32f86be1093e34746d85dae47e5d2e7729806011 | Python | Dieter97/Hashcode2021 | /streets/car.py | UTF-8 | 823 | 3.34375 | 3 | [] | no_license | from __future__ import annotations
from typing import List
from streets.street import Street
class Car:
def __init__(self, n_streets):
self.n_streets: int = n_streets
self.streets: List[Street] = []
self.time_from_end_of_street: int = 0
self.current_street_index: int = 0
de... | true |
b8bd58d2a6af62149f8987542fba618f7c674aab | Python | himl/boson | /SVM/EvaluatingEstimator.py | UTF-8 | 2,475 | 3.375 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
DEFAULT_FOLDS_NUMBER = 5
def cross_validation(estimator, data, target, folds_number=DEFAULT_FOLDS_NUMBER):
""" This function used "K-fold Cross Validation"
"KFold divides all the samples: k groups of samples, called folds
(if k = n, this is equivalent to the Leave One Out st... | true |
e3973c0573bd3bab5f512238b1a9cbb760d16aa5 | Python | tgbmangel/PersonalUPUPUP | /Meiju/mjtt.py | UTF-8 | 1,337 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Project : upupup
# @Time : 2018/5/7 17:08
# @Author :
# @File : mjtt.py
# @Software: PyCharm Community Edition
import requests
import re
import os
class Meiju():
def __init__(self,home_url):
self.home_url = home_url
self.ed2k_url = re.compile('href="(ed2k.*?)"')
... | true |
7b5e921a422b4c571b84a7df6f7bf780e8dec11e | Python | karenL-M/R1_Patrones | /R1 PATRONES/composite.py | UTF-8 | 984 | 3.15625 | 3 | [] | no_license | from abc import ABC, abstractmethod
class Pelicula(Reproducible):
def reproduccion(self):
pass
class Reproducible():
@abstractmethod
def reproduccion(self):
pass
class AlbumPelicula(Reproducible):
def __init__(self):
def reproduccion(self):
for cant in self._cantidad:... | true |
41595110062ce8fc281882964ff1e9c48c84f999 | Python | tobby-lie/Multi-Instrument-RNN-Generation | /LSTM-ABC_Notation/Music_Generator_Train.py | UTF-8 | 8,114 | 3.234375 | 3 | [] | no_license | import os
import json
import numpy as np
import pandas as pd
from keras.models import Sequential
from keras.layers import LSTM, Dropout, TimeDistributed, Dense, Activation, Embedding
import time
import numpy
import sys
numpy.set_printoptions(threshold=sys.maxsize)
data_directory = "/Users/tobbylie/Documents/CSCI_593... | true |
c5c8ce6c6e20f00b510821b1e4fc68b3837de40e | Python | teamgeek-io/dummyzarid | /dummyzarid/__init__.py | UTF-8 | 1,797 | 3.234375 | 3 | [
"MIT"
] | permissive | import re
from random import randrange, choice
from enum import Enum
class Gender(Enum):
FEMALE = "4"
MALE = "5"
class Citizenship(Enum):
CITIZEN = "0"
RESIDENT = "1"
def calculate_check_digit(digits):
digits_arr = list(re.sub(r"\D", "", digits))
num_digits = list(map(lambda d: int(d), dig... | true |
b22df407793c026e4eddfd2f117d254f0aef7057 | Python | camjohn47/tripadvisor-nlp | /nlp_pipeline.py | UTF-8 | 8,251 | 2.75 | 3 | [] | no_license | from sklearn.tree import DecisionTreeClassifier as dtc
from sklearn.ensemble import RandomForestClassifier as rfc
from sklearn.model_selection import train_test_split as split
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import LatentDirichletAllocation as LDA
from collections... | true |
34c0bff9f5735d715ed5ec4c18e8b2c60e4dc369 | Python | paulinaJaworska/lightweight-erp | /hr/hr.py | UTF-8 | 3,656 | 3.546875 | 4 | [] | no_license | """ Human resources module
Data table structure:
* id (string): Unique and random generated identifier
at least 2 special characters (except: ';'), 2 number, 2 lower and 2 upper case letters)
* name (string)
* birth_year (number)
"""
# everything you'll need is imported:
# User interface module
im... | true |
0a11fb2df0d39c6ed8cd887b54b8315f4b583db7 | Python | gameboy1024/ProjectEuler | /src/problem_17.py | UTF-8 | 1,706 | 3.890625 | 4 | [] | no_license | '''
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
NOTE: Do not count spaces or hyphens. For example, ... | true |
b79e014eda08426c93a295bf90e8b48d7eaa6a14 | Python | sethjuarez/Digitz | /LearnDigitz/pytorch_train.py | UTF-8 | 2,052 | 2.65625 | 3 | [
"MIT"
] | permissive | import os
import sys
import torch
import argparse
import numpy as np
import torch.nn as nn
import torch.optim as optim
from datetime import datetime
from misc.digits import Digits
import torch.nn.functional as F
from misc.helpers import print_info, print_args, check_dir, info, save_model
def main(args):
# digit da... | true |
d96bd59b277ee18f811e14fefad4f89b50804743 | Python | Hank-Liao-Yu-Chih/document | /OpenCV讀者資源/讀者資源/程式實例/ch12/ch12_9.py | UTF-8 | 313 | 2.953125 | 3 | [] | no_license | # ch12_9.py
import cv2
import numpy as np
src = cv2.imread("btree.jpg")
kernel = np.ones((3,3),np.uint8) # 建立3x3內核
dst = cv2.morphologyEx(src,cv2.MORPH_OPEN,kernel) # 開運算
cv2.imshow("src",src)
cv2.imshow("after Opening 3 x 3",dst)
cv2.waitKey(0)
cv2.destroyAllWindows()
| true |
ef756b533a6e12dcf7d202cbacb818241daf539e | Python | javaTheHutts/Java-the-Hutts | /src/unittest/python/test_blur_manager.py | UTF-8 | 4,057 | 2.9375 | 3 | [
"BSD-3-Clause"
] | permissive | """
----------------------------------------------------------------------
Authors: Stephan Nell
----------------------------------------------------------------------
Unit tests for the Blur Manager
----------------------------------------------------------------------
"""
import pytest
import cv2
import os
from hutts... | true |
0d2a0733deaf7b3bff8948a8712c40964e2e4262 | Python | SamHashemiCA/image-registration-cnn | /utils/dataset.py | UTF-8 | 597 | 2.5625 | 3 | [] | no_license | from torch.utils.data import Dataset
import os
class CTScanDataset(Dataset):
'''
__getitem__ returns the 3D numpy arrays pair (source,target)
for the given index after applying the specified transforms.
Waiting for data access approval from
NCTN/NCORP Data Archive to implement the function.
''... | true |
d7b01c27e12d35434e8c0063f42294aac8abe2e1 | Python | Amit006/Python-competitive | /practice/dog.py | UTF-8 | 218 | 2.671875 | 3 | [] | no_license | from pet import pet;
class dog(pet):
def __init__(self,name,chases_cats):
pet.__init__(self,name,"dog")
self.chases_cats=chases_cats
def chasesCats(self):
return self.chases_cats
| true |
cfa5665ee8b91a455a1e279a6fb8423124c8030d | Python | rhosse/Team-Lyrical | /data_lemmatization.py | UTF-8 | 2,071 | 3.140625 | 3 | [] | no_license | '''
data_lemmatization.py
Data lemmatization generator
keeps only noun, adj, verb, adverb
1. read in Data.csv
2. tokenize using gensim
3. run function to lemmatize using SpaCy
4. send lemmatization to output for input to topic modeling code (e.g., Script_TM_30.py)
'''
import numpy as np
import pandas as p... | true |
6361cfec83834818df703d6824955eff69ebcb8c | Python | frankbreetz/RealEstateScraping | /Scrape.py | UTF-8 | 2,547 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | import requests
from bs4 import BeautifulSoup
import pandas as pd
input = pd.read_csv('search_results.csv')
df = pd.DataFrame(columns=['Parcel Number',
'Name',
'Address',
'Sale Date',
'Sale Price',
... | true |
3196906c610ece84990ed1ab7772ddea2570c8f7 | Python | Manisha3112/Python-programs | /overloading.py | UTF-8 | 674 | 3.890625 | 4 | [] | no_license | class Welcome:
def wish(self, user_name=None):
if user_name is not None:
print('Hi ' + user_name)
else:
print('Hi')
def product(self,a=None,b=None):
if a!=None and b!=None:
print("Product= ",(a*b))
elif a!=None:
num=i... | true |
76e33f74a5a163aefc9f6a933423c6eb35c83e2c | Python | krishna07210/com-python-core-repo | /src/main/py/04-Loops/For-Loop.py | UTF-8 | 298 | 3.109375 | 3 | [] | no_license | #!/usr/bin/python3
def main():
fh = open('lines.txt')
for line in fh.readlines():
print(line, end='')
print('\n')
for line in [1, 2, 3, 4, 5, 6]:
print(line, end='')
print('\n')
for line in 'string':
print(line)
if __name__ == "__main__": main()
| true |
862b4236619e88d0a6f1087198bb334e97233473 | Python | webdagger/rfrp | /BE/Face/face/face.py | UTF-8 | 1,997 | 2.59375 | 3 | [] | no_license | import os
import pickle
import sys
import tempfile
from exceptions import ImageManipulationError, FaceRecognitionExeption
import face_encodings
import face_locations
import face_recognition
import numpy as np
from image_manipulation import oriented_thumbnail
from PIL import Image
# Load face encodings
try:
with ... | true |
906a337d1bd5a427696ceadba3e27e4d3076f101 | Python | vanessmeyer/quizproject | /quiz/views.py | UTF-8 | 4,342 | 3.15625 | 3 | [] | no_license | from django.shortcuts import render
#This import pulls in Quiz models so we can connect views to database data
from quiz.models import Quiz
from django.shortcuts import redirect
# Create your views here. These are view functions.
def startpage(request):
context = {
"quizzes": Quiz.objects.all(),
}
return re... | true |
1f6d5c4ddf4bee22da572d1d29605502b8fcff46 | Python | MarcioPorto/rlib | /rlib/algorithms/maddpg/agent.py | UTF-8 | 10,969 | 2.6875 | 3 | [
"MIT"
] | permissive | import copy
import os
import random
from collections import namedtuple, deque
import numpy as np
import torch
import torch.nn.functional as F
import torch.optim as optim
from rlib.algorithms.base import Agent
from rlib.algorithms.maddpg.model import Actor, Critic
from rlib.shared.noise import OUNoise
from rlib.shared... | true |
686d24820e3134cac7a74bf9859e80e5521405c6 | Python | Le-Bot/cerebro | /cerebro/neuron/manager.py | UTF-8 | 1,233 | 2.671875 | 3 | [
"MIT"
] | permissive | import abc
import constants as const
class AbstractManager(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def get_all(self):
raise NotImplementedError()
@abc.abstractmethod
def add(self, obj):
raise NotImplementedError()
@abc.abstractmethod
def is_valid(self, ... | true |
7c33994fd688d2659d19ca672c12940695f79826 | Python | LinSiCong/smallTools | /dealImage/PngToJpg.py | UTF-8 | 741 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2018/9/20
# @Time : 13:14
# @Author : LinSicong
# @File : PngToJpg.py
"""
将同目录下所有png文件保存为jpg文件
"""
import os
import cv2
if __name__ == '__main__':
work_dir = os.getcwd()
convert_dir = os.path.join(work_dir, "convertFile")
if not os.path.ex... | true |
b95dc321385fa68846c6b58bad3bb5bf6e668c6f | Python | gensyu/Mirai-con | /debug_comm.py | UTF-8 | 6,741 | 2.734375 | 3 | [] | no_license | import serial
import time
import construct as cs
from enum import Enum
RES_SIZE = 26 #byte
class ResponceError(Exception):
pass
class MOTORDIR(Enum):
CW = 0x01
CCW = 0x00
class DRIVINGMODE(Enum):
Disable: 0
LINETRACE: 1
TOF: 2
sendfmt = cs.BitStruct(
"header" / cs.Bytewise(cs.Const(b"\x... | true |
7e0d169aa60813c22e164af1ee2f429d081a2b3b | Python | izgebayyurt/asteroids | /ship.py | UTF-8 | 7,488 | 3.28125 | 3 | [] | no_license | # Template by Bruce A Maxwell
# Fall 2018
# CS 152 Project 11
#
# Make an Asteroids-like ship move around
#
# slightly modified by Eric Aaron, Fall 2018
#
# import useful packages
import math
import time
import graphics as gr
import physics_objects as pho
# make a ship object, treat it as a ball
# but it needs to be a... | true |
629f37285b5ea58b2ded9c4c670a11813975afec | Python | junzhang19/CS7641 | /HW3/DimensionReduction.py | UTF-8 | 6,504 | 2.609375 | 3 | [] | no_license | import pandas as pd
import numpy as np
import scipy.sparse as sps
import matplotlib.pyplot as plt
from collections import defaultdict
from itertools import product
from matplotlib.ticker import MaxNLocator
from scipy.linalg import pinv
from sklearn.base import TransformerMixin, BaseEstimator
from sklearn.d... | true |
af7925bea472facfc1ddf44780cb1a0f7c22122a | Python | movermeyer/nicedjango | /tests/a3/models.py | UTF-8 | 896 | 2.546875 | 3 | [
"MIT"
] | permissive | """
Multiple inheritance sample 2 from docs.
Notes:
* not more than one review per book looks like a wrong example.
* have to define review differently for 1.7, despite docs say this is for 1.7:
CommandError: System check identified some issues:
ERRORS:
a3.BookReview: (models.E005) The field 'piece_ptr' ... | true |
21ff94594cb23c9fc1987415f0cb8e83efed119a | Python | jdvpl/Python | /Universidad Nacional/monitorias/Ejercicios/diccionarios/diccionario.py | UTF-8 | 89 | 2.546875 | 3 | [] | no_license | ports={22:"ssh",23:"telner",80:"http"}
for k,v in ports.items():
print(f"{k} => {v}") | true |
2e8283f9091b5196020bcdcafd0b55536e129799 | Python | JunhoKim94/HEVEN_Path_Planning | /Database/Platform.py | UTF-8 | 7,262 | 2.53125 | 3 | [] | no_license | import time
import sys
import os
sys.path.append(os.path.dirname(__file__))
from Flag import Flag
import serial
class Platform:
def __init__(self, port, baud, flag: Flag):
self.__recv_data = SerialPacket()
self.__send_data = SerialPacket()
self.flag = flag
self.__platform_initiali... | true |
9acb3381ed62b1ee3a91ebdf9a2a60df33e6c020 | Python | cyrilwelschen/reservationen_package | /reservationen_package/push_to_dropbox.py | UTF-8 | 718 | 2.96875 | 3 | [
"MIT"
] | permissive | import dropbox
import os
from dropbox.files import WriteMode
class TransferData:
def __init__(self, access_token):
self.access_token = access_token
def upload_file(self, file_from, file_to):
"""upload a file to Dropbox using API v2
"""
dbx = dropbox.Dropbox(self.access_token)
... | true |
9b4edb7c1d7cdb170de7b66731ff123906625eea | Python | brunopace/metaevo | /simples/artificial.py | UTF-8 | 10,169 | 2.65625 | 3 | [] | no_license | import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
import math
import random as rndm
import time
ta = time.time()
N = 5000
numyears = 20000
eps = 0.05 #acima de 0.26 nao eh estavel
alpha = 0.06
T1 = 4
T2 = 3
L = 8
l = 3
deg = 1
method = 'fraction'
landscape = nx.Graph()
rho = {}
for ... | true |
1e03e30383d19fde111ea88c3b65f75401ed88ef | Python | goldader/lbypl | /json_iter.py | UTF-8 | 2,433 | 2.71875 | 3 | [] | no_license | """module to unpack Truelayer json responses into arrays or individual items"""
def depth(x):
if type(x) is dict and x:
return 1 + max(depth(x[a]) for a in x)
if type(x) is list and x:
return 1 + max(depth(a) for a in x)
return 0
def dict_generator2(indict, pre=None):
pre = pre[:] if pr... | true |
de5119b010591ca59fdb6c7eae7ecdf04de441c8 | Python | bhyun/daily-algorithm | /2021/BOJ18290_NM과 K(1).py | UTF-8 | 1,172 | 2.859375 | 3 | [] | no_license | import sys
input = sys.stdin.readline
def dfs(x, y, cnt, summary):
global answer
if cnt == k:
if summary > answer:
answer = summary
return
dx = [-1, 1, 0, 0]
dy = [0, 0, -1, 1]
for i in range(x, n):
for j in range(y if i == x else 0, m):
# (i, j)에서... | true |
209c5a5a55e3d94ea267f93497054988b519ce2c | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2591/60705/255349.py | UTF-8 | 215 | 3.375 | 3 | [] | no_license | n = int(input())
a = [51, 105, 917]
b = [102, 109, 893, 103]
for i in range(0, n):
line = int(input())
if line in a:
print("Yes")
elif line in b:
print("No")
else:
print(line) | true |
a68ab8568991239b49fae17b229875886c0378ed | Python | daniel-reich/ubiquitous-fiesta | /39utPCHvtWqt5vaz9_10.py | UTF-8 | 161 | 3.109375 | 3 | [] | no_license |
def direction(lst):
nlst = []
for item in lst:
nlst.append(item.replace("e", "w").replace("E", "W").replace("a", "e").replace("A", "E"))
return nlst
| true |
029ebfaf5f827711536c3f63aa4de8bd82ef6a0f | Python | g-d-l/project_euler | /done/068.py | UTF-8 | 1,151 | 2.921875 | 3 | [] | no_license | import itertools
from sets import Set
def main():
ngon = 5
values = range(1, 11)
triples = [[0, 0, 0] for _ in xrange(ngon)]
result = ''
for assignment in itertools.permutations(range(1, 10), ngon):
for i in xrange(ngon - 1):
triples[i][1], triples[i][2] = assignment[i], assignment[i + 1]
triples[ngon - ... | true |
65025e476f6cbbaf0a043dd74deacd4fa7011f8a | Python | danieldis/CS_3580_Data_Science_Algorithms | /CS_3580_Assignments/A2/assign2.py | UTF-8 | 6,853 | 3.265625 | 3 | [] | no_license | #!/usr/bin/env python3
print("\nDaniel Salmond")
import csv
states = frozenset([
'Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana',
'Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michi... | true |
7040127ebb729980fb94d2658d79158119ddf9a7 | Python | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/exercism/exercism-python-master/binary-search-tree/binary_search_tree.py | UTF-8 | 1,178 | 3.578125 | 4 | [] | no_license | class TreeNode(object):
def __init__(self, data, left, right):
self.data = data
self.left = left
self.right = right
def __str__(self):
fmt = 'TreeNode(data={}, left={}, right={})'
return fmt.format(self.data, self.left, self.right)
class BinarySearchTree(object):
d... | true |
f7f6f7f87499b17db8c3fec1d87637c7470998ce | Python | dryan9/Database-Management | /week13__2.py | UTF-8 | 1,042 | 2.515625 | 3 | [] | no_license | import csv
import pymysql
import configparser
config = configparser.ConfigParser()
config.read_file(open('credentials.py'))
dbhost = config['csc']['dbhost']
dbuser = config['csc']['dbuser']
dbpw = config['csc']['dbpw']
dbschema = 'dryan16'
dbconn = pymysql.connect(host=dbhost,
... | true |
a2737b57994be57cbe9530f174a5eb1e98942fca | Python | z0x010/medusa | /medusacode/rabbitmq_pika_demo/02_work_queues/worker.py | UTF-8 | 3,143 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env python
# coding:utf-8
import pika
import datetime
import time
HOST = '192.168.100.100'
PORT = 5672
QUEUE_NAME = 'task_queue'
print '----------------------------------------------------------------------------------------------------'
connection = pika.BlockingConnection(
parameters=pika.Connection... | true |
14ecd62924921c1741964b5148c0d552de668b56 | Python | gharv222/labs | /lab9.py | UTF-8 | 466 | 3.5 | 4 | [] | no_license | """
George Harvey]
COMP 525
Lab 9
"""
def count_words(file_in):
"""
Counts how many times each word in a text files appears
file_in: txt file
returns: a dictionary that keys are each word in the
txt file and their value is how many times it appears
"""
fin = open(file_in, 'r')
word_dict = {}
for line in fin... | true |
0244af02405fd80db091f65da15f4cf3a259f2ab | Python | luguoxiang/level_pgserver | /test/query_test.py | UTF-8 | 2,378 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | import sqlite3
import psycopg2
from random import randint
conn = sqlite3.connect("reference.db")
myconn = psycopg2.connect(database="test", user="", password="", host="127.0.0.1", port="5433")
cur = conn.cursor()
mycur = myconn.cursor()
cur.execute('DROP TABLE IF EXISTS querytest')
cur.execute('CREATE TABLE queryte... | true |
871a24321296216b1344e461ee2aa9f71ee9f3ad | Python | MunskyGroup/rSNAPsim | /build/lib/rsnapsim/intensity_modifier.py | UTF-8 | 4,802 | 2.859375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Created on Thu Sep 17 09:24:35 2020
@author: willi
"""
import pandas as pd
import matplotlib.pyplot as plt
import time
import numpy as np
def modify_intensity(intensity_vector, SNR, noise_type='AGWN'):
'''
given an intensity vector and signal to noise ratio this will add noise... | true |
951e322def932a4d7951f3fcd72ece9606cd8c49 | Python | michelleweii/Leetcode | /06_链表/142-环形链表 II.py | UTF-8 | 3,336 | 3.921875 | 4 | [] | no_license | """
middle 2021-12-23 链表
题目:判断环链表的入口位置——快慢指针
(推导+动图)https://leetcode-cn.com/problems/linked-list-cycle-ii/solution/linked-list-cycle-ii-kuai-man-zhi-zhen-shuang-zhi-/
"""
# a:起点到环入口的节点数(不包括入口)
# b:环节点数
# 根据: f=2s (快指针每次2步,路程刚好2倍)
# f=s+nb (相遇时,刚好多走了n圈), =>推出:s = nb。
# 从head结点走到入环点需要走:a+nb, 而slow已经走了nb,那么slow再走... | true |
34cac449904f9f523788f2f93c780bfd4a7c28d9 | Python | AdolphGirL/Tensorflow-CNN-Model | /Vgg16-CiFar10-Training.py | UTF-8 | 2,282 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
from model.Vgg import VGG16
import datetime
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.keras import datasets
from tensorflow.keras.utils import to_categorical
logger_name = '[Vgg16-CiFar10-Training.py]: '
(x_train, y_train), (x_test, y_test) = ... | true |
9b69ea894f8892673924bf4f71d9581e52c30174 | Python | kotabrog/K_DeZero | /kdezero/functions/basic_calc_functions.py | UTF-8 | 2,655 | 2.78125 | 3 | [
"MIT"
] | permissive | import kdezero
from kdezero import Function
from kdezero import as_array
class Add(Function):
def forward(self, x0, x1):
self.x0_shape, self.x1_shape = x0.shape, x1.shape
y = x0 + x1
return y
def backward(self, gy):
gx0, gx1 = gy, gy
if self.x0_shape != self.x1_shape:
... | true |
c621a90e6240fb4810a17f29dfe6d137bf0f0ff1 | Python | kses1010/algorithm | /baekjoon/bronze/Number.py | UTF-8 | 192 | 3.375 | 3 | [] | no_license | # 10093
n1, n2 = map(int, input().split())
a = min(n1, n2)
b = max(n1, n2)
if a == b or a + 1 == b:
print(0)
else:
print(b - a - 1)
for i in range(a + 1, b):
print(i, end=' ')
| true |
5ecef39c78febba46d551ccb35df884a5c4b877a | Python | SingukMun/Python_Practice | /`21.07.28 입력한 변수 합계 프로그램.py | UTF-8 | 214 | 3.046875 | 3 | [] | no_license | aa=[]
for i in range(0, 4):
aa.append(0)
hap = 0
for i in range(0, 4) :
aa[i] = int(input( str(i + 1) + "번째 숫자 : "))
hap = aa[0] + aa[1] + aa[2] + aa[3]
print(" 합계 --> %d " % hap)
| true |
95de6c88595be1b3c186288c5e62766dd0dcce3c | Python | spweps/Day-1-Python | /dojos_and_ninjas/flask_app/models/dojo.py | UTF-8 | 1,442 | 2.640625 | 3 | [] | no_license | from flask_app.config.mysqlconnection import connectToMySQL
from .ninja import Ninja
class Dojo:
def __init__(self, data):
self.id = data['id']
self.name = data['name']
self.created_at = data['created_at']
self.updated_at = data['updated_at']
self.ninjas = []
@classme... | true |
00f4fce34bf050608a420877558998751258d860 | Python | mqinbin/python_leetcode | /1175.质数排列.py | UTF-8 | 832 | 2.796875 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=1175 lang=python3
#
# [1175] 质数排列
#
# @lc code=start
class Solution:
def numPrimeArrangements(self, n: int) -> int:
def A(up,down):
answer = 1
for _ in range(up):
answer *= down
down -= 1
return answer
... | true |
b3268193a4d73c47c25cff31cd581948080d2251 | Python | Maegereg/CryptoChallenges | /20.py | UTF-8 | 4,065 | 2.703125 | 3 | [] | no_license | import aes
import convert
repeatXor = __import__('6')
import xor
def generateCiphertexts():
plaintextFile = open("20.txt")
ciphertexts = []
key = aes.generateRandomKey()
for line in plaintextFile:
ciphertexts.append(aes.aesCTREncrypt(convert.b64ToByteString(line), key, 0))
plaintextFile.close()
return cipherte... | true |
0db0ded497fac7e2bb584d63526480759c552c21 | Python | danielthiel/thielbots | /kit/codejail.py | UTF-8 | 1,754 | 2.78125 | 3 | [] | no_license | import imp
from RestrictedPython.Guards import safe_builtins
import random
class SecurityError:
def __init__(self, player_id, message):
self.player_id = player_id
self.message = message
class PlayerCodeJail:
allowed_imports = []
allowed_magic = []
def __init__(self, player_id, code):
... | true |
b58447cb4a46adc3586c87cf852738d5eba3c24c | Python | ArtrixTech/AppleStockMonitor | /data_parser.py | UTF-8 | 4,282 | 2.703125 | 3 | [] | no_license | from os import getenv
import requests
import json
HEADERS = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
# Format {0} as partNbrs
BASE_URI = "https://www.apple.com/hk-zh/shop/fulfillment-messages?pl=true&mt=compact{0}&... | true |
e3cc439f68a9d7d14d90f764bfc189f43c6a454b | Python | daniel-ntr/Python | /CursoEmVideo/desafio073.py | UTF-8 | 776 | 4.125 | 4 | [] | no_license | # RETORNA NUMERO POR EXTENSO
extenso = ('Zero', 'Um', 'Dois', 'Três', 'Quatro', 'Cinco', 'Seis', 'Sete',
'Oito', 'Nove', 'Dez', 'Onze', 'Doze', 'Treze', 'Quatorze',
'Quinze', 'Dezesseis', 'Dezessete', 'Dezoito', 'Dezenove', 'Vinte')
num = int(input('Digite um número entre 0 e 20: ').strip())
wh... | true |
eedacc0f35bffa1274dfd07ad69efc171f2cd635 | Python | ericosur/ericosur-snippet | /python3/os_path_join.py | UTF-8 | 429 | 3.265625 | 3 | [] | no_license | #!/usr/bin/python
# coding: utf-8
#
'''
demo how to use os.path.join()
It will take care the dir seperator from different OS.
'''
import os.path
def main():
''' main '''
print('demo os.path.join()')
folder_output_name = 'output'
for frame_number in range(6):
fn = f'frame_{frame_number:05d}.p... | true |
0a024b7d404787f2b34658ad60e586228bd7946e | Python | XxdpavelxX/HackerRank | /30daysOfCode/Loops5.py | UTF-8 | 168 | 3.40625 | 3 | [] | no_license | #https://www.hackerrank.com/challenges/30-loops/problem
import sys
n = int(raw_input().strip())
i = 1
while i <= 10:
print "%s x %s = %s"%(n, i, i*n)
i += 1
| true |
0d20402977a800d257d2908ef1ce7e6b8e62e2a4 | Python | HDPark95/algorithm | /greedy/number_card_game.py | UTF-8 | 775 | 3.078125 | 3 | [] | no_license | """
여 개의 숫자 카드 중에서 가장 높은 숫자가 쓰인 카드 한 장을 뽑는 겡미이다.
단, 게임의 룰을 지키며 카드를 뽑아야 하고 룰은 다음과 같다.
1. 숫자가 쓰인 카드들이 N x M 형태로 놓여있다. 이때 N은 행의 개수를 의미하여, M은 열의 개수를 의미한다.
2. 먼저 뽑고자 하는 카드가 포함되어 있는 행을 선택한다.
3. 그다음 선택된 행에 포함된 카드들 중 가장 숫자가 낮은 카드를 뽀아야 한다.
4. 따라서 처음에 카드를 골라낼 행을 선택할 때, 이후에 해당 행에서 가장 숫자가 낮은 카드를 뽑을 것을 고려하여 최종적으로 가장 높은 숫자의 카드를
뽑을 수... | true |
f92062e2e71a58f7c20ee860a3f9c19aca5c8037 | Python | Ruijan/flask_companies | /src/cache/local_history_cache.py | UTF-8 | 22,160 | 2.609375 | 3 | [] | no_license | import math
import os
import time
from datetime import datetime, timedelta
import yfinance as yf
import fmpsdk
from urllib.request import urlopen
import json
import pandas as pd
from src.currency import Currency
Y_M_D = "%Y-%m-%d"
FINANCE_KEY_ = os.environ["FINANCE_KEY"]
def get_range(end_date, period, start_date):... | true |
ddf2812a93e012004c98ebf1d6c100d6ac194d49 | Python | ercris990/_curso_gg_py_3 | /_aula/aula016c_tuplas.py | UTF-8 | 247 | 4.3125 | 4 | [] | no_license | a = (2, 5, 4)
b = (5, 8, 1, 2)
c = a + b
print(f'Elementos da tupla por ordem alfabetica: {sorted(c)}')
print(f'Quantas veses aparece o numero 5: {c.count(5)}')
print(f'Tupla: {c}')
print(c.index(5)) # mostra a posição do número na tupla
| true |
1a58833fcf9384020aee19fa75661ef38e7c00d8 | Python | sumit-kushwah/Python-stuff | /argparse/subcommand.py | UTF-8 | 2,376 | 2.53125 | 3 | [] | no_license | import argparse
parser = argparse.ArgumentParser(prog="todo", description='A smart command line todo application.')
subparsers = parser.add_subparsers(title="subcommands", description='Available subcommands', help='commands', dest="subcommand")
# parser for add sub-command
parser_add = subparsers.add_parser('add', h... | true |
f4213133305c5fd5d3447e211e47ccc5db11e041 | Python | azamatkb/Function | /7may_1.py | UTF-8 | 659 | 4.09375 | 4 | [] | no_license | #7may_1 Создайте функцию которая берет лист делит его пополам и разворачивает...
def revers():
list_1 = ['name', 'age', '1', '19']
a = list(reversed(list_1[len(list_1)//2:]))
b = list(reversed(list_1[:len(list_1)//2]))
print(b + a)
revers()
#7may_1 - 2 версия Создайте функцию которая берет лист де... | true |
27fc5a08499fbea6bfaf8e3822a5eb2395e9c781 | Python | andrewfhou/advent-of-code-2018 | /day06/daySix.py | UTF-8 | 1,139 | 3.359375 | 3 | [] | no_license | from collections import defaultdict
with open("input.txt") as file:
inputs = file.read().splitlines()
xPoints = defaultdict(int)
yPoints = defaultdict(int)
maxX = 0
maxY = 0
count = 0
for a in inputs:
x = int(a[:a.find(',')])
y = int(a[a.find(',') + 2:])
xPoints[count] = x
yPoints[count] = y
... | true |
294c9c5a647e1dbf20a047ef2adfc7738f67143a | Python | felixbosco/specklepy | /specklepy/reduction/filter.py | UTF-8 | 1,967 | 3.4375 | 3 | [
"MIT"
] | permissive | import numpy as np
def hot_pixel_mask(image, threshold=5):
"""Identify hot pixels via a 2nd derivative method and create a hot pixel mask with hot pixels `True`.
Arguments:
image (np.ndarray):
Image for which the mask shall be created.
threshold (int or float, optional):
... | true |
7b4f6b08c1df986d3e6fcbd99299b06e24985392 | Python | small-west/eASCs | /0_Clean_Python_Scripts/2_dicty_fourth_t.py | UTF-8 | 5,682 | 2.609375 | 3 | [] | no_license | ### IMPORTS ###
import os
import numpy as np
import csv
### CHOOSE SOURCE FILES ###
source_dicty = '2_Development/sociality_genes.csv'
source_fasta = '2_Development/Dictyostelium_ac.fa'
### MAIN ###
def main():
csv_total = []
#Get gene ids
raw_data = open(source_dicty).read()
dicty_split = raw_da... | true |
2f0bc59cd894cc42b0c28e64e78b632b8586ad64 | Python | elados93/trex-core | /scripts/external_libs/lockfile-0.10.2/test/compliancetest.py | UTF-8 | 8,523 | 2.515625 | 3 | [
"Apache-2.0",
"GPL-1.0-or-later",
"GPL-2.0-or-later",
"GPL-2.0-only",
"MIT"
] | permissive | import os
import threading
import shutil
import lockfile
class ComplianceTest(object):
def __init__(self):
self.saved_class = lockfile.LockFile
def _testfile(self):
"""Return platform-appropriate file. Helper for tests."""
import tempfile
return os.path.join(tempfile.gettempd... | true |
12ed448e300437a59dbc7b5d9b97a6f227e43409 | Python | karoberts/adventofcode2015 | /21-1.py | UTF-8 | 2,663 | 3.125 | 3 | [] | no_license |
def run_game(my_hp, my_damage, my_armor, boss_hp, boss_damage, boss_armor):
while True:
boss_hp -= max(1, my_damage - boss_armor)
if boss_hp <= 0:
#print('boss loses', 'player =', my_hp)
return True
my_hp -= max(1, boss_damage - my_armor)
if... | true |
93d0257387359b9d3f43803d87e65adf99790f64 | Python | Mohamedballouch/covid19_morocco-package | /covid19_morocco/covid19.py | UTF-8 | 4,705 | 2.671875 | 3 | [] | no_license | import urllib.request
from bs4 import BeautifulSoup as bf
import time
state='Morocco'
def confirmed_people():
time.sleep(5)
#url = 'https://www.google.com/search?q=python'
url='https://www.worldometers.info/coronavirus/country/'+state+'/'
# now, with the below headers, we defined ourselves as a simpleton ... | true |
ea328c36e7dd543fdc39bf5126f50b4d0922e663 | Python | dhinojosa/tdd20160609 | /calcstats.py | UTF-8 | 586 | 3.546875 | 4 | [] | no_license | import unittest
class CalcStats
def __init__(self, list)
self.list = list
def filter(self, pred)
if (len(self) == 0) None
answer = self.list[0]
for (item in self_list[1:])
if (pred(item, answer))
answer = item
answer
def max(self)
filter(lambda next, cu... | true |
d67399ca1f0a8157319b221b6f5a7786cc9b0236 | Python | tirsott/lc-go | /problems/0123.best-time-to-buy-and-sell-stock-iii/best-time-to-buy-and-sell-stock-iii.py | UTF-8 | 924 | 3.28125 | 3 | [] | no_license | from typing import List
class Solution:
def maxProfit(self, prices: List[int]) -> int:
if len(prices) < 2:
return 0
dp = [[[None, None, None], [None, None, None]] for _ in range(len(prices))]
dp[0][0][0] = 0
dp[0][0][1] = 0
dp[0][0][2] = 0
dp[0][1][0] = ... | true |
fc2e361a47ab232f9bc360b0b6aac3feacbec2f3 | Python | aravind225/hackerearth | /pattern6.py | UTF-8 | 137 | 3.703125 | 4 | [] | no_license | n=5
i=1
j=n
while j:
if i==n:
print(j,end=" ")
j=j-1
else:
print(i,end=" ")
i=i+1
| true |
cba64e2d1f2a8a62f542a3164b9b262bccfff869 | Python | bean710/AirBnB_clone_v3 | /api/v1/views/places_reviews.py | UTF-8 | 2,714 | 2.609375 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/python3
"""File for the reviews route"""
from api.v1.views import app_views
from flask import Flask, jsonify, abort, request
from models import storage
from models.review import Review
from models.place import Place
@app_views.route("/places/<place_id>/reviews", methods=["GET"],
strict_sl... | true |
5663ab5a62c2f4a70083bda247ae784d653f957a | Python | templeblock/dlex | /dlex/utils/utils.py | UTF-8 | 3,185 | 2.734375 | 3 | [] | no_license | """General utils"""
import os
import sys
import time
import zipfile
import tarfile
import shutil
from six.moves import urllib
import requests
from tqdm import tqdm
from .logging import set_log_dir, logger
urllib_start_time = 0
def reporthook(count, block_size, total_size):
global urllib_start_tim... | true |
ce32202f6a2419730f9ed5240d3ed542b372c517 | Python | hvn2001/LearnPython | /DataStructures/IntroTrees/PreOrderTraversal.py | UTF-8 | 433 | 3.546875 | 4 | [] | no_license | from DataStructures.IntroTrees.BinarySearchTree import BinarySearchTree
from DataStructures.IntroTrees.Print import display
def preOrderPrint(node):
if node is not None:
print(node.val)
preOrderPrint(node.leftChild)
preOrderPrint(node.rightChild)
BST = BinarySearchTree(6)
BST.insert(4)
B... | true |
ff6f58f4c23ca918b0ba239e90913d570e58a825 | Python | mbisbano1/369_Project_1 | /experiment3/UDPServer.py | UTF-8 | 809 | 2.890625 | 3 | [] | no_license | from socket import *
import sys
global server_port
#serverPort=12000
if len(sys.argv) <= 1:
print('Usage: "python3 UDPServer.py server_port"')
print('server_port = server socket port: #80GX')
print('Using Default values for server_port')
print('server_port = 12000')
server_port = 12000
else:
server_port = int(... | true |
f3ed8928c63c260a81979a28fc43e0c835280e84 | Python | jimms/leetcode | /63.py | UTF-8 | 751 | 2.984375 | 3 | [] | no_license | class Solution(object):
def uniquePathsWithObstacles(self, g):
"""
:type obstacleGrid: List[List[int]]
:rtype: int
"""
m = len(g)
n = len(g[0])
a = []
for i in range(m):
a.append([0] * n)
for i in range(m - 1, -1, -1):
f... | true |
79b1d666d6fe69fcba41b1d958607d2e948cdd41 | Python | koalahang/covid19-mobility | /PODA_Model_Code/myFunctions.py | UTF-8 | 2,169 | 2.734375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Created on Tue May 12 00:52:39 2020
@author: hexx
"""
import os
def def_add_datashift (data_frame, column_name, x):
for i in x:
shift_i = column_name + '_shifted_'+str(i)
data_frame[shift_i] = data_frame[column_name]
data_frame[shift_i] = data_frame[... | true |
d2ecae5e7934e2d0e9b7791edef89cee80c4933f | Python | CodingPirates/taarnby-python | /uge3/dyr.py | UTF-8 | 3,222 | 3.84375 | 4 | [] | no_license | # Her laver vi en ny klasse. Bemærk at vi altid laver klassenavne med et stort bogstav
class Dyr:
# Her kommer nogle variable der tilhører klassen. Alle objekter af samme klasse deler disse
dyrtype = "dyr"
# Her kommer initialiseringsfunktionen. Den køres hver gang vi laver et nyt objekt af denne klasse... | true |
c0147fff8cf9a2b6282919ecdecb35932ae18eaa | Python | KYHlings/Poke-Mood2.0 | /pygame_upgraded/pygame_states.py | UTF-8 | 1,318 | 2.609375 | 3 | [] | no_license | import pygame as pg
from TextToPygame import start_game
#print("Lets use your new stats, press [Enter] to ge in to the World of Poketeers")
import pygame_upgraded.variables
from pygame_upgraded import global_stuff
from pygame_upgraded.screens import MenuStartScreen, StartScreen
from pygame_upgraded.variables import ... | true |
7570b4ce839370a2879002f6c5cc3f08afba0d82 | Python | phaustin/pythonlibs | /pyutils/pyutils/move_files.py | UTF-8 | 1,365 | 3.28125 | 3 | [
"BSD-3-Clause"
] | permissive | """
move files that don't start with . to a folder, leaving only directories
example: python -m pyutils.moveit thedir
"""
import argparse
import re, os
import tempfile
from pathlib import Path
import errno, sys
dotre = re.compile(r'^\..*')
def mkdir_p(path):
try:
os.makedirs(path, exist_ok=False)
... | true |
7ece71eb5727f05d16eee36de10039457bb613e4 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_96/1534.py | UTF-8 | 925 | 2.75 | 3 | [] | no_license | import sys
output = "Case #%s: %s"
f = open(sys.argv[1],'r')
T = int(f.readline())
for counter in xrange(T):
line = [int(i) for i in f.readline().strip().split(' ')]
N = line[0]
S = line[1]
p = line[2]
t = line[3:]
#print N
#print S
#print p
#print t
# calculus
normal = p*... | true |
826800f38bf455d7e35ab3d82bd9f8204d727e53 | Python | stephanieeechang/PythonGameProg | /PyCharmProj/turtleRunner.py | UTF-8 | 921 | 4.03125 | 4 | [
"LicenseRef-scancode-public-domain"
] | permissive | import turtle
def square(sqrlength, turtle):
'''
this function draws a square with turtle
:param sqrlength: length of square
:return:
'''
if sqrlength < 5:
return
else:
for i in range(4):
turtle.forward(sqrlength)
turtle.left(90)
turtle.up()
... | true |
4b6a4dd4d30363869796df0e65587d4f969dcfa6 | Python | Daniyal56/Python-Projects | /Euclidean distance.py | UTF-8 | 949 | 4.53125 | 5 | [] | no_license | ## 10. Euclidean distance
### write a Python program to compute the distance between the points (x1, y1) and (x2, y2).
#### Program Console Sample 1:
###### Enter Co-ordinate for x1: 2
###### Enter Co-ordinate for x2: 4
###### Enter Co-ordinate for y1: 4
###### Enter Co-ordinate for y2: 4
###### Distance between points... | true |
63693af1ffe1097b0415afe723728f77c74b16e4 | Python | bhrigu123/interview_prep_python | /double_dimension.py | UTF-8 | 128 | 3.046875 | 3 | [] | no_license |
def get_dd_matrix(rows, columns):
return [[0 for x in range(columns)] for y in range(rows)]
print (get_dd_matrix(1, 10))
| true |
a9c327052c0000f2252162d83635edd69cdb1a6d | Python | Akhila474/Python | /Python prgms/StudentDetails.py | UTF-8 | 834 | 4.59375 | 5 | [] | no_license | 1)Create a Python class called "Student" having "name","age" as attribute along with a list having the marks obtained for three subjects.
2)Create a constructor to initialize two objects of this class.
3)Create a member function called 'display' printing the details of a specific object.
4)Ask user to enter the values ... | true |
9e2f88c82370bb418b0889b30395186ed711e537 | Python | yuu19/scraping_learing | /selpra2.py | UTF-8 | 853 | 3.15625 | 3 | [] | no_license | import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
#ChromeOptionでヘッドレスモードを指定
chrome_option = webdriver.ChromeOptions()
chrome_option.add_argument('--headless')
... | true |
ef7c242b9d8e9c6d2994ea18853e5b56672f4e6c | Python | mokuno3430/emu | /lyla_plot/bin/alignment.py | UTF-8 | 10,187 | 2.734375 | 3 | [] | no_license | import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors as clr
import sys
import csv
import common
import os.path
class Colormap:
pallet = {
'red':((0.00, 0.10, 0.10),
(0.25, 0.10, 0.10),
(0.40, 0.30, 0.30),
(0.60, 1.00, 1.00),
... | true |
6c26eee3b256bd33aeb2c6ba99f4047d7fbbc4de | Python | piyushpatel2005/Python | /examples/testing/test_mymath.py | UTF-8 | 945 | 3.546875 | 4 | [] | no_license | import mymath
import unittest
class TestAdd(unittest.TestCase):
"""
Test the add function from mymath library
"""
def test_add_integers(self):
"""
Tests that the addition of two integers returns the correct total
"""
result = mymath.add(1, 2)
self.assertEqual(r... | true |
caaab9031bb3d2a9a3ff51e79b9da15227b9c6c0 | Python | thomcom/berserker | /advmodel/AdvBuilders/WeaponBuilder.py | UTF-8 | 520 | 2.875 | 3 | [] | no_license | # Build objects of type Weapon
from advmodel.AdvBuilders import ItemBuilder
from advmodel.AdvDataObjects import Weapon
from advmodel.AdvDataObjects import DieRoll
from advview.Log import Log
class WeaponBuilder(ItemBuilder):
def Build(self):
builder = ItemBuilder()
builder.SetJson(self.jsonData)
r... | true |
76cda9f0d1ad55dbb78a84411f1ffaec3f3d38f0 | Python | dynasty919/stanford_algorithms | /course3_pa4_knapsack_big.py | UTF-8 | 1,523 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2018/3/7 16:56
# @Author : dynasty919
# @Email : dynasty919@163.com
# @File : course3_pa4_knapsack_big.py
# @Software: PyCharm
def readfile():
with open('knapsack_big.txt', 'rt') as f:
a = f.readlines()
c = []
for b in a[1:]:
c.append(b.... | true |
26beefaa416bbee8f44b81891dcb4ed31d07aeac | Python | luvt2019/DecisionTree-Model | /DecisionTree.py | UTF-8 | 2,555 | 3.03125 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
loans = pd.read_csv('loan_data.csv')
# Create a histogram of two FICO distributions on top of each other, one for each credit.policy outcome
plt.figure(figsize = (11,7))
loans[loans['credit.policy'] == 1]['... | true |