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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
49479c29ab960d2dd33e72a45d7b32019fd9862c | Python | valluriavi/Simplecalculator | /Simple_calculator.py | UTF-8 | 178 | 4.03125 | 4 | [] | no_license | # Simple Calculator #
print('Welcome to simple calculator')
a = int(input('Enter a number :'))
b = int(input('Enter a number to be multiplied :'))
c = a*b
print('Answer = ', c)
| true |
5ea8e38151e67acb89e08cd9c557e354d51870b0 | Python | VigneshReddyJulakanti/Harry_python | /tasks/design-2.py | UTF-8 | 101 | 3.296875 | 3 | [] | no_license | a=int(input())
print("*"*a)
for i in range(a-2):
print("*{0}*".format(" "*(a-2)))
print("*"*a)
| true |
5edc61f12ccd46b2d4f75d92051dc2dd109fd605 | Python | scott-p-lane/Advent-of-Code-2019 | /Day_04/d4main.py | UTF-8 | 1,004 | 3.59375 | 4 | [] | no_license | '''
Created on Jan 4, 2020
@author: slane
'''
matchesCount = 0
failCount = 0
'''
Input range is 234208 - 765869, however the end value in Python range is not inclusive, so I had to bump
it up by one.
'''
for val in range(234208,765870):
valray = list(str(val))
hasDecrease = 0
hasValidDouble = 0
repeat... | true |
6185b387244914d04dde6340f4766712db7d3fbd | Python | tjstoll/guess-word-ai | /index.py | UTF-8 | 820 | 3.78125 | 4 | [] | no_license | '''
GuessWordAI in Python...
Author: Taneisha Stoll
'''
import GameLoop
class Index(object):
""" Entry and exit point """
def __init__(self, name, nLets, category):
'''
name - name of player
nLets - number of letters to be guessed
category - word category
'''
... | true |
e53b694399551ba35a054a896fab177ffa132516 | Python | Ed-Narvaez/CartShop | /prin.py | UTF-8 | 2,787 | 3.078125 | 3 | [] | no_license | from producto import Producto
from factura import Factura
from funcionesBD import *
conexion = conectar()
print("Ingrese usuario y contraseña... [UTIICE: usuario: user | contraseña: mipass]")
usuario = input("Ingrese usuario")
miPass = input("Ingrese pass")
data = (usuario, miPass)
c = ejecutar("select * from users whe... | true |
e69238d222d74d5dff1b93d72f2fbc089f3d03a2 | Python | bobmayuze/RPI_Education_Material | /CSCI_1100/Week_6/Lecture_10/part_4.py | UTF-8 | 322 | 3.4375 | 3 | [] | no_license | co2_levels = [ 320.03, 322.16, 328.07, 333.91, 341.47, 348.92, 357.29, 363.77, 371.51, 382.47, 392.95 ]
i = 0
p = float(input('Enter the fraction: '))
print(p)
for level in range(len(co2_levels)):
co2_levels[i] *= (1+p)
i += 1
print('First: {:.2f}'.format(co2_levels[0]))
print('Last: {:.2f}'.format(co2_levels[-1])... | true |
34d928d0e74df2864b1f14ba6d0ed724fc5d283a | Python | anthonylife/ReviewBasedRatingPrediction | /script/convertTripleRatingFormat.py | UTF-8 | 4,116 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
#encoding=utf8
#Copyright [2014] [Wei Zhang]
#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 ... | true |
56d66db44c1714de2ecfbb36dc10727353afdb21 | Python | ChunjieShan/Baselines | /simpleconv3_pt_dataset/dataset.py | UTF-8 | 1,304 | 2.78125 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf8 -*-
import torch
import os
from PIL import Image
from torch.utils.data import Dataset
class ImageData(Dataset):
def __init__(self, data_dir, transform=None):
self.label_name = {"Cat": 0, "Dog": 1}
self.data_info = self.get_img_info(data_dir)
self.tran... | true |
5113d2ae9fe953749bbb3a0d7dea0278b2b8196f | Python | saranya258/python | /56.py | UTF-8 | 115 | 3.546875 | 4 | [] | no_license | g=input()
for i in range(0,len(g)):
if(g[i].isalpha() and g[i].isdigit()):
print("No")
else:
print("Yes")
| true |
eae50e9c515b83538678c6344174787cddcb9587 | Python | jumphone/Bioinformatics | /scRNAseq/Natalie_20181113/combine.py | UTF-8 | 751 | 2.640625 | 3 | [] | no_license | import sys
f1=open(sys.argv[1])
f2=open(sys.argv[2])
fo=open(sys.argv[3],'w')
GENE={}
header1=f1.readline().rstrip().split('\t')[1:]
header2=f2.readline().rstrip().split('\t')[1:]
newheader='GENE\t'+'\t'.join(header1)+'\t'+'\t'.join(header2)+'\n'
fo.write(newheader)
GENE1={}
for line in f1:
seq=line.rstrip().spli... | true |
d2951eb49e291dc94ca74616e1741c0f47899d64 | Python | AyeniTrust/python-for-everybody | /Using Python to Access Web Data/Week 4/Following Links in HTML Using BeautifulSoup.py | UTF-8 | 672 | 3 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Oct 16 21:12:49 2017
@author: atse
"""
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
url = input('Enter URL: ')
num = in... | true |
ad3cfd758f7a6274bc6055615eddefef655416e8 | Python | cnmodel/cnmodel | /cnmodel/data/ionchannels.py | UTF-8 | 30,253 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | # -*- encoding: utf-8 -*-
from ._db import add_table_data
"""
Ion channel density tables
All of the ion channel densities for the models implemented in cnmodel
are (or should be) stated here, and should not be modified in the
cnmodel code itself.
"""
add_table_data('RM03_channels', row_key='field', col_key='model_ty... | true |
125e68e4f06b2872d17a03bf0f42533f7cfb731c | Python | ljmulshine/cs263-final-project | /messageDecode.py | UTF-8 | 9,198 | 2.96875 | 3 | [] | no_license | import sys
import os
import bot_config as config
import subprocess
from skimage import io # install skimage
##########################################################
# Decoding
##########################################################
########################################
#
# getNbits(S,N)
#
#... | true |
14e96c5567f3f6418b29fe464be2f932306b3c8f | Python | vtranduc/Android-customizable-puzzle-game | /menu.py | UTF-8 | 8,754 | 2.53125 | 3 | [] | no_license | import kivy
kivy.require('1.7.2')
from kivy.uix.widget import Widget
from cropImage import CropImage, cropFit, ratioFit, centering_widget
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.uix.label impor... | true |
2028d34f1164f7dd35380537427155fdfc8329bb | Python | Zero-Grav/art-apex | /apex/src/lib/adafruit_bno08x/i2c.py | UTF-8 | 4,238 | 2.640625 | 3 | [
"MIT"
] | permissive | # SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Subclass of `adafruit_bno08x.BNO08X` to use I2C
"""
from struct import pack_into
import adafruit_bus_device.i2c_device as i2c_device
from . import BNO08X, DATA_BUFFER_SIZE, const, Packet, Packet... | true |
888b406a2aada1ceeeb311bc30123fe4ec4f5112 | Python | moongchi98/MLP | /백준/JAN_FEB/1316_그룹단어체커.py | UTF-8 | 268 | 3.328125 | 3 | [] | no_license | T =int(input())
cnt = 0
for _ in range(T):
stack = []
word = input()
for alpa in word:
if alpa not in stack:
stack.append(alpa)
else:
if stack[-1] != alpa:
break
else:
cnt += 1
print(cnt)
| true |
d0a53763935f70585804bb18aa637b1675d696b6 | Python | m-barneto/ArcadeBot | /Bot/Filler/tile.py | UTF-8 | 111 | 2.921875 | 3 | [] | no_license | class Tile:
def __init__(self, color: int, team: int):
self.color = color
self.team = team
| true |
dee7acaca8dfc16045615524ca4974da01d2cd7f | Python | SkittlePox/Direct-Compositional-Parser | /LexicalStructures/Syntax.py | UTF-8 | 1,733 | 2.984375 | 3 | [] | no_license | import enum
from functools import reduce
VERBOSE = True
class SyntacticPrimitive(enum.Enum):
def __str__(self):
return str(self.value)
S = "S"
NP = "NP"
PP = "PP"
N = "N"
CP = "CP"
class SyntacticFeature(enum.Enum):
def __str__(self):
return self.value
A = "A"
... | true |
ccb31698744764ccda62e9475c129483a4b3170c | Python | xuanxuan03021/ml_implementationfrom_strach | /coursework1/data/data_explore.py | UTF-8 | 3,303 | 3.359375 | 3 | [] | no_license | import numpy as np
# read dataset
#train_full
x_full=np.loadtxt("train_full.txt", delimiter=',',dtype= str)
x_sub=np.loadtxt("train_sub.txt", delimiter=',',dtype= str)
x_noisy=np.loadtxt("train_noisy.txt", delimiter=',',dtype= str)
# Your function/class method should return:
# 1. a NumPy array of shape (N,K) represen... | true |
7bb3e12ed54f98f86b4e31ddb6e2cb05ba43d95e | Python | TheAlgorithms/Python | /project_euler/problem_030/sol1.py | UTF-8 | 1,187 | 4.375 | 4 | [
"MIT",
"CC-BY-NC-4.0",
"CC-BY-NC-SA-4.0"
] | permissive | """ Problem Statement (Digit Fifth Powers): https://projecteuler.net/problem=30
Surprisingly there are only three numbers that can be written as the sum of fourth
powers of their digits:
1634 = 1^4 + 6^4 + 3^4 + 4^4
8208 = 8^4 + 2^4 + 0^4 + 8^4
9474 = 9^4 + 4^4 + 7^4 + 4^4
As 1 = 1^4 is not a sum it is not included.
... | true |
06db442da07f1cd0b54d5f33624bc8784f3e99bd | Python | JacobIRR/rovers | /mars_rovers.py | UTF-8 | 11,094 | 3.5 | 4 | [] | no_license | #! /usr/bin/python
import sys
class CollisionError(Exception):
"Raise this when a non-self_preserve rover collides with another"
pass
class OutOfBoundsError(Exception):
"Raise this when a non-self_preserve rover runs off the edge"
pass
class CrossedOwnPathException(Exception):
"Raise when we ... | true |
9bb8532cb4885173185bf788e5ecfc69ab1415bf | Python | saimahithanatakala/python-basics | /dates/1.todays date.py | UTF-8 | 137 | 2.96875 | 3 | [] | no_license | from datetime import date
today=date.today()
print("todays date is: ",today)
print("date is: ",today.day,"-",today.month,"-",today.year)
| true |
128ec82de5336e4c08ecb1d35869940a59c337b6 | Python | saikb92/rookie | /abc.py | UTF-8 | 330 | 3.25 | 3 | [] | no_license | def sum(a,b):
return a+b
def avg(a,b):
return sum(a,b)//2
a= float(input("Enter first number:"))
b= float(input("Enter second number:"))
c= input("enter the test")
print("Sum of the given two numbers is: ", sum(a,b))
print("Average of the given numbers is: ", avg(a,b))
print("Input c:", c1)
sa... | true |
38a25942208e36c5c4f496350b9f311bb7157946 | Python | sydney0zq/LeetCode | /AAAAU_LeetCodeLTS/300_length_of_lis.py | UTF-8 | 837 | 3.21875 | 3 | [] | no_license | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2020 qiang.zhou <qiang.zhou@Macbook>
#
# Distributed under terms of the MIT license.
"""
https://leetcode-cn.com/problems/longest-increasing-subsequence/
"""
class Solution:
def lengthOfLIS(self, nums) -> int:
# init dp array... | true |
0b6ae7deeb2e463392395b60b0f4cbb7461e2eba | Python | Ariyohalder2007/PythonAssingment2 | /Q-3.py | UTF-8 | 225 | 2.796875 | 3 | [] | no_license | def file_read(fname):
my_array = []
with open(fname) as f:
for i in f:
my_array.append(i)
print(my_array)
file_read('D:/python assingment2/Q-2.txt')
| true |
e8c77f39a4242843fb4fc0603ff9dec31a1025d0 | Python | prymnumber/AoC | /AoC/day6.py | UTF-8 | 1,676 | 2.671875 | 3 | [] | no_license | import pdb
import sys
from common import *
l_file = '/Users/iposton/GitHub/PyPractice/AoC/'+str(sys.argv[1])
init = map(int,get_file(l_file).split('\t'))
class memory_bank:
blocks = 0
id = None
cycle = 0
MaxBlock = False
pattern = []
def __init__(self,blocks,id,cycle):
self.blocks = b... | true |
b047f196198f5af2735e5fc9def83aa13e70423e | Python | woodybury/raspi_flask | /main.py | UTF-8 | 1,732 | 2.671875 | 3 | [
"MIT"
] | permissive | from flask import Flask, render_template, redirect
from flask_basicauth import BasicAuth
import datetime
import env
# gate code imports
import time
import RPi.GPIO as GPIO
# set GPIO mode
GPIO.setmode(GPIO.BCM)
def openGate():
GPIO.setup(17,GPIO.OUT)
GPIO.output(17,GPIO.LOW)
time.sleep(1.45)
GPIO.output... | true |
de5c0a911849514d8023567a8e15d834fd3ee69e | Python | dianezhou96/egocentricgaze | /video_to_data.py | UTF-8 | 9,710 | 2.875 | 3 | [] | no_license | import cv2
import mmcv
import numpy as np
import pandas as pd
import random
import torch
from torch.utils.data import DataLoader, Dataset, IterableDataset
from torchvision import transforms
# multiple videos
class GazeFrameDataset(IterableDataset):
"""
An dataset to iterate through frames of video with gaze ... | true |
400adfffde85b29d60daaa695b22cf2153d898e9 | Python | YuenFuiLau/Hand-Tracking-Project | /ConvNet/test_utils.py | UTF-8 | 3,942 | 3.3125 | 3 | [] | no_license | import numpy as np
def batchnorm_forward(x, gamma, beta, bn_param):
"""
Forward pass for batch normalization.
During training the sample mean and (uncorrected) sample variance are
computed from minibatch statistics and used to normalize the incoming data.
During training we also keep an expo... | true |
c67ae7caba441ac342857dc1e199494fda55f804 | Python | SyGoing/ClassificationWork | /networks/mynet_new.py | UTF-8 | 1,372 | 2.546875 | 3 | [] | no_license | import torch.nn as nn
import torch
class Net(nn.Module):
def __init__(self):
super(Net,self).__init__()
self.net_Conv=nn.Sequential(
nn.Conv2d(3, 16, 3, stride=1),
nn.ReLU(),
nn.MaxPool2d(3, stride=2),
nn.Conv2d(16, 32, 3, stride=1),
nn.ReL... | true |
9dda60b227b6204235e6aeb93e715e3d525444c3 | Python | TAUTIC/PartGrabber | /partgrabber.py | UTF-8 | 2,803 | 2.59375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# The MIT License (MIT)
#
# Copyright (c) 2014 Jayson Tautic
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rig... | true |
477b971725a7962f0d6741c6534ba139a9969061 | Python | Bohyunnn/PythonBasic | /week2/03_for_while.py | UTF-8 | 1,017 | 4.0625 | 4 | [] | no_license | """
"""
"""
반복문
for : 정해진 횟수 동안
while : ~ 조건이 유지되는 동안
"""
# 1에서 부터 10까지 출력을 하고 싶다.
number = 1
# 중복되는 부분을 반복문 안에서 처리하고
# 바뀌어야 하는 부분이 무엇인지 고민한다.
while number <= 10 :
print(number)
number = number + 1
"""
while [조건문] :
[실헹구문]
while True :
# 데이터를 입력 받는데 언제 끝낼지 모를 때
# 프로그램 전체를 반복할 떄
# 데이터 입력이 올... | true |
d267a5b9c995b78713db136bb4e362a1629fa41d | Python | seyon123/slack-bot | /bot.py | UTF-8 | 3,772 | 2.859375 | 3 | [] | no_license | # For Slack
import slack
from slackeventsapi import SlackEventAdapter
# Store Keys
from dotenv import load_dotenv
import os
from pathlib import Path
from datetime import datetime
from geotext import GeoText
import random
import requests
import json
# To handle requests
from flask import Flask
# Load the .env file ... | true |
0c4610d1216d152b8d94a757896aa1e8c0e3c63f | Python | beduffy/rl-autoencoder-experiments | /save_images_from_env.py | UTF-8 | 839 | 2.515625 | 3 | [] | no_license | import time
import numpy as np
import matplotlib.pyplot as plt
import sys
import gym
# save image
def show_image(obs):
imgplot = plt.imshow(obs)
plt.show()
number_of_saved_images = 0
# observation (210, 160, 3)
open_ai_env_name = 'SpaceInvaders-v0'
env = gym.make(open_ai_env_name)
for i_episode in rang... | true |
545df0d7977e86cdef3e748b3aadc8df646242c2 | Python | gpioblink/alg1 | /le06/B.py | UTF-8 | 426 | 3.109375 | 3 | [] | no_license | # WHATIS: パーテーション 入力された配列を右端の数字の大小で仕分け
def partition(A, p, r):
x = A[r]
i = p-1
for j in range(p,r):
if A[j] <= x:
i = i+1
A[i], A[j] = A[j], A[i]
A[i+1],A[r] = A[r], A[i+1]
return i+1
n = int(input())
A = list(map(int, input().split()))
mid = partition(A,0,n-1)
print(' '.join(map(str,A[:mid]... | true |
0dbaa2c72e1832db35958b614cc313b46bb8549e | Python | Heavysss/Hevyks | /PyCharm/Module_Os.py | UTF-8 | 184 | 2.859375 | 3 | [] | no_license | # Изучение модуля os
import os
print(os.getcwd())
os.chdir(r"C:\Users\Yummer\Documents")
print(os.getcwd())
print(os.path.basename(r"C:"))
k = 'piP'
k.lower()
print(k) | true |
f920c1434c2373311bdec5485ff66e8501c82a4e | Python | jiang2533001/Cracking-the-Coding-Interview | /Chapter 2/stack.py | UTF-8 | 831 | 4 | 4 | [] | no_license | class Stack(object):
def __init__(self):
self.head = None
self.list = []
self.size = 0
def is_empty(self):
if self.size == 0:
return True
else:
return False
def push(self, val):
self.list.append(val)
self.head = self.size
... | true |
5efb52843dc1038a0aef23a68f703eaf98ef2151 | Python | ekqls3659/Algorithm_Study-BackJoon | /2439.py | UTF-8 | 258 | 4 | 4 | [] | no_license | # 첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제
# 하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오.
a=int(input())
for i in range(1,a+1):
print(" "*(a-i) + "*"*i) | true |
b0974040778bf956e466edee02981bb291a6ea7a | Python | way2joy/air_analysis_v3 | /cnn_3d.py | UTF-8 | 7,039 | 2.625 | 3 | [] | no_license | from read_data import read_data
import numpy as np
import pandas as pd
import tensorflow as tf
import matplotlib.pyplot as plt
import os
def batch_creator(X_set, y_set, batch_size, dataset_length):
"""Create batch with random samples and return appropriate format"""
batch_mask = rng.choice(dataset_length-1, b... | true |
1e76b1754a46749e1e43f75ccf50b56fc992e6fb | Python | akshitgupta29/Competitive_Programming | /LeetCode & GFG & IB/P7 - Counting Elements.py | UTF-8 | 512 | 3.859375 | 4 | [] | no_license | '''
Given an integer array arr, count element x such that x + 1 is also in arr.
If there're duplicates in arr, count them seperately.
Example 1:
Input: arr = [1,2,3]
Output: 2
Explanation: 1 and 2 are counted cause 2 and 3 are in arr.
'''
from typing import List
def countElements(arr: List[int]) -> int:
count = 0... | true |
24680331acbbfaf0015ce5d50d2fe151687e5da1 | Python | lizhenQAZ/code_manage | /Python2.7/Flask/E5_SQLARCHEMY数据库与迁移.py | UTF-8 | 2,581 | 3.125 | 3 | [] | no_license | # coding=utf-8
"""
功能:
1.SQLALCHEMY使用:
设置SQLALCHEMY_DATABASE_URI与SQLALCHEMY_TRACK_MODIFICATIONS
2.模型类定义:
设置表名、反向引用、外键、主键与唯一
3.数据库迁移:
# 1.实例化管理器对象
manager = Manager(app)
# 2.使用迁移扩展
Migrate(app, db)
# 3.使用迁移命令
manager.add_command('db', MigrateCommand)
# 4.执行迁移
manager.run()
"""
fro... | true |
d738a57e22ad502e6e8c1d8c7ecfd03e4a6d2368 | Python | colinwke/tcc_cloth_matching | /tcc_taobao_clothes_matching/preprocess/offline_set_generator.py | UTF-8 | 2,289 | 3.328125 | 3 | [] | no_license | """
1. 测试商品集随时间购买次数
2. 匹配商品集随时间购买次数
通过1,2的图像可得,测试商品集是从匹配商品集中抽样出来的
因此可直接从匹配商品集合中抽样出线下训练和测试商品集
生成训练集和验证集
训练集5500
验证集2541
"""
import pandas as pd
import matplotlib.pyplot as plt
from core.config import *
def plot_itemset_bought_count2(itemset, history, multi_factor=1):
history = history[history['item_id'].isin(i... | true |
1053e61af63fd3fae0b1d0d42228be09f14dd96c | Python | jmcb/murderrl | /builder/builder.py | UTF-8 | 28,802 | 2.703125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
"""
Attempt to create a "manor" akin to::
###############################################
#.........#......#........#...........#.......#
#.........#......#........#...........#.......#
#.........#......#........#...........#.......#
#.........#......#........#...........#.......#
###... | true |
e89575bd46357a5182cfe3e472b84f21468de76e | Python | jamiezeminzhang/Leetcode_Python | /dynamic programming/010_OO_regular_expression_matching.py | UTF-8 | 4,757 | 4.09375 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 10:00:45 2015
LeetCdoe #10 Regular Expression Matching
Implement regular expression matching with support for '.' and '*'.
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not par... | true |
72e7857b20d02c01a89918c6011322beca5fac03 | Python | 3n73rp455/cli | /main.py | UTF-8 | 1,324 | 2.640625 | 3 | [] | no_license | import argparse
import os
import requests
import sys
from modules import auth, get
class CLI(object):
def __init__(self, user, password, endpoint):
self.token = auth.login(user, password)
self.endpoint = endpoint
def create(self):
return
def get(self, pk):
pw = get.passw... | true |
7491c266f7c131f690dbb89a27842bd15de37bb2 | Python | GBaileyMcEwan/python | /src/comparePrices/comparePrices.py | UTF-8 | 2,700 | 2.90625 | 3 | [] | no_license | #!/usr/local/bin/python3
from bs4 import BeautifulSoup
from termcolor import colored
import requests
import re
import json
#import time
#grab user search string
product = input("What product would you like to search for? ")
#product = "tomato sauce"
print(f"Product was: {product}")
#time.sleep(10)
#woolworths needs ... | true |
5b37c743696ad032c6beb3bf653f28d0fd88dfd1 | Python | pritesh-ugrankar/edxpy | /varb.py | UTF-8 | 224 | 3.640625 | 4 | [] | no_license | varA = 10
varB = 'moretext'
if type(varA) == str or type(varB) == str :
print("type varA: strings involved")
if varA > varB:
print("bigger")
if varA == varB:
print("equal")
if varA < varB:
print("smaller")
| true |
a0d22f91973e9167344ca3c53453d8f35758fc85 | Python | chenchienlin/Algorithmic-Toolbox | /interesting_topics/puzzle_solver.py | UTF-8 | 1,367 | 2.953125 | 3 | [] | no_license | from collections import deque
from interesting_topics.puzzle_solver_util import *
import logging
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger()
def BFSSolver(initial, goal):
BLANK = 16
Q = deque()
Q.append(initial)
prev = dict()
prev[list_to_str(initial)] = None
state = N... | true |
45b75100835cf569c58e9108f614b92a7030043d | Python | Darkkyelfo/Replicacao-pixel-clustering | /Replicacao-pixel-clustering/execucoes.py | UTF-8 | 1,588 | 2.515625 | 3 | [] | no_license | '''
Created on 30 de dez de 2017
@author: raul1
'''
from classificadores import classicarKNN
from imagemparabase import imgsParaBase
from dividirbase import Holdout
from pixelcluster import IntensityPatches
from numba import jit
def executarIntensity(base,qtCla=15,hold=10,knn=1):
#Bases
if(base=="georgia"):
... | true |
0bf1bbabd140742158d59ef01aacc79281ae5baa | Python | pit-ray/Anime-Semantic-Segmentation-GAN | /datasets.py | UTF-8 | 2,268 | 2.640625 | 3 | [
"MIT"
] | permissive | # coding: utf-8
import os
from glob import glob
import joblib
import numpy as np
from chainer.datasets.tuple_dataset import TupleDataset
from PIL import Image
from functions import label2onehot
def gamma_correction(img, gamma=2.5):
return img ** (1 / gamma)
def get_dataset(opt):
files = glob(opt.dataset_d... | true |
2a9ac33e7fee4825cded5e2665a56f09b132a138 | Python | harrybiddle/ynab | /ynab/bank.py | UTF-8 | 1,509 | 3.40625 | 3 | [] | no_license | import uuid
class ObjectWithSecrets:
def __init__(self, secrets, *args, **kwargs):
self._secrets = secrets or dict()
@classmethod
def from_config(cls, config, keyring):
secrets_keys = config.pop("secrets_keys", {})
secrets = keyring.get_secrets(secrets_keys)
return cls(con... | true |
805c06e084250af2a071cf0f55f97abffb95bfe3 | Python | defoe-code/defoe | /defoe/es/queries/geoparser_pages.py | UTF-8 | 3,952 | 2.75 | 3 | [
"MIT",
"CC0-1.0",
"CC-BY-4.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | """
It uses ES stored data.
Identify the locations per page and geo-resolve them.
It uses the Original Edinburgh geoparser pipeline for identifying all the posible locations within a page and georesolve them.
"""
from operator import add
from defoe import query_utils
from defoe.hdfs.query_utils import blank_as_nul... | true |
3f9fce8c94dad4542b654b276dcd554323b3c444 | Python | OverHall27/Gasyori100knock | /Question_61_70/myanswers/myans66.py | UTF-8 | 1,528 | 2.953125 | 3 | [
"MIT"
] | permissive | import cv2
import numpy as np
def BGRtoGRAY(img):
gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
return gray
def HOG(gray):
def GetGradXY(gray):
Ver, Hor = gray.shape
gray = np.pad(gray, (1, 1), 'edge')
gx = gray[1:Ver+1, 2:] - gray[1:Ver+1, :Hor]
... | true |
2c9d360753f76eec3f61d53de3f487da0305e8fb | Python | varanasisrikar/Programs | /Python/Random Data Plot.py | UTF-8 | 193 | 2.578125 | 3 | [] | no_license | import numpy as np
import pylab as pl
Y = Data = np.random.normal(5.8, 5.4, 1000)
print(Data)
X = np.arange(1, 10)
pl.plot(Data, "ro")
pl.show()
pl.plot(Data)
pl.show()
pl.hist(Data)
pl.show() | true |
bb58dafcd18adc3207a90239b44294563961da29 | Python | yeqown/playground | /pythonic/analyze_image_exif.py | UTF-8 | 2,329 | 3.328125 | 3 | [] | no_license | """
This is a snippet of code that will analyze the EXIF data of an image.
It will print out the EXIF data in a human readable format.
@File: analyze_image_exif.py
@Author: yeqown
"""
import exifread
from geopy.geocoders import Nominatim
from typing import Dict, Any
geoconverter = Nominatim(user_agent="analyze_imag... | true |
f42a73112e38a0bdc6ed0d7cc374c4aca0e74ab2 | Python | fchamicapereira/projecteuler | /17.py | UTF-8 | 1,721 | 3.609375 | 4 | [] | no_license | numbers1 = ['','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']
numbers2 = ['','','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']
numbers3 = ['','hundred','thousand','million','bill... | true |
eef0e8f5ba33e8e89f2d5ac2cfca80620c0ee726 | Python | Taeheon-Lee/Programmers | /level1/gcd_and_lcm.py | UTF-8 | 730 | 4.03125 | 4 | [] | no_license | "최대공약수와 최소공배수"
# 문제 링크 "https://programmers.co.kr/learn/courses/30/lessons/12940"
def solution(n, m):
n1, n2 = max(n, m), min(n, m) # 두 수를 비교하여 큰 값, 작은 값을 변수로 대입
i = 1
while i > 0: # 유클리드 호제법 이용 (Euclidean algorithm)
i = n1 % n2 # 큰 수에서 작은 수를 나눈 뒤, 다시 작은 수를 나머지... | true |
d67c7aef77e0899b5c7867606a0ac2b8f475b3bc | Python | toe4626/picryptoclock | /clock.py | UTF-8 | 3,089 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env python3
import os, time, pygame
# Initialize PyGame...
os.putenv('SDL_VIDEODRIVER', 'fbcon') # works for 320x240 Adafruit PiTFT
os.putenv('SDL_FBDEV', '/dev/fb1') # which is treated as a framebuffer
pygame.init()
pygame.mouse.set_visible(False)
screen = pygame.display.set_mode((0, 0), pygame.FULLS... | true |
2e9bb0a22844ccd2f38ca4698d6494e3f1933752 | Python | AdamZhouSE/pythonHomework | /Code/CodeRecords/2900/60624/316453.py | UTF-8 | 164 | 3.109375 | 3 | [] | no_license | def func13():
s = input().strip()
ans = len(s)
for i in s:
if i==" " or i=="\n":
ans -= 1
print(ans,end="")
return
func13() | true |
9ce494c9e4be8da9187cf7a35d8ca60c289f52ff | Python | Shreeyak/cleargrasp | /z-ignore-scripts-helper/move_images_syn_dataset.py | UTF-8 | 5,001 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python3
import argparse
import concurrent.futures
import fnmatch
import glob
import itertools
import json
import multiprocessing as mp
import os
import shutil
import time
from pathlib import Path
import sys
from termcolor import colored
# The various subfolders into which the synthetic data is to be or... | true |
fb659966a7e17500bcdf3d5ae1410221416b7cb2 | Python | SaahilClaypool/CS534_AI | /1_Assignment/1_part/HeavyHill.py | UTF-8 | 7,053 | 3.28125 | 3 | [] | no_license | import random
import heapq
from queue import PriorityQueue
import time
from typing import Sequence, Mapping
from copy import deepcopy
import argparse
class Board:
"""
array of
"""
def __init__(self, board: [], prev_cost: int, added_cost = 0, rand=False):
self.size = len(board)
self.prev_... | true |
5b88fa997fdca34aa3bbd944ae8a7a021aef9d26 | Python | entoad/location-entropy | /test_utils.py | UTF-8 | 1,040 | 2.96875 | 3 | [] | no_license | import math
import unittest
from pyspark.sql import SparkSession
from utils import calc_location_entropy
class TestUtils(unittest.TestCase):
def test_location_entropy(self):
spark = SparkSession.builder.master("local[2]").appName("pyspark-sql-test").getOrCreate()
lst = [('test-loc', 1)]
... | true |
d56ea7d1000e36720a395fcb81dd038cd531de0b | Python | jtlai0921/XB1828- | /XB1828_Python零基礎最強入門之路-王者歸來_範例檔案New/ch11/ch11_30_1.py | UTF-8 | 197 | 2.6875 | 3 | [] | no_license | # ch11_30_1.py
def printmsg():
print("列印全域變數: ", msg)
msg = "Java" # 嘗試更改全域變數造成錯誤
print("更改後: ", msg)
msg = "Python"
printmsg()
| true |
bb34451ef6b1da8fb940e27ee4cdd50c254faabb | Python | mackoo13/pmp | /pmp/rules/bloc.py | UTF-8 | 668 | 2.578125 | 3 | [] | no_license | from .weakly_separable import WeaklySeparable
class Bloc(WeaklySeparable):
"""Bloc vote scoring rule."""
def __str__(self):
return "Bloc"
def initialise_weights(self, k, _profile):
self.weights = [1] * k
def find_committee(self, k, profile, random_winning_committee=False):
s... | true |
647dd92c2c51cf82d1fa728f09427f81bdc1bd4b | Python | lurenxiao1998/CTFOJ | /[De1CTF 2019]SSRF Me/test.py | UTF-8 | 258 | 2.578125 | 3 | [] | no_license |
import socket
import urllib
def scan(param):
socket.setdefaulttimeout(10)
# try:
return urllib.urlopen(param).read()[:100]
# except:
# return "Connection Timeout"
if __name__ == "__main__":
print(scan("a.py")) | true |
a37d3b54d78c8c3f33af16044ffcaa66bde22ca3 | Python | ssoomin1/CosPro_Test | /모의고사3_2.py | UTF-8 | 371 | 3 | 3 | [] | no_license | #신수민
def func_a(arr):
total=0
for i in arr:
total+=i
return total
def solution(total,arr):
result=[]
req_total=func_a(arr)
for i in arr:
if req_total>total:
result.append(total//len(arr))
else:
result.append(i)
return result
total=100
arr=[20... | true |
c9bf188095f2a110441922c2b73cd330ce898c39 | Python | ToJohnTo/OTUS_Python_QA_Engineer | /PythonQAOtus_Lesson28/Test_REST_API_1/test_1_API_1.py | UTF-8 | 433 | 2.765625 | 3 | [] | no_license | import pytest
import requests
url = "https://dog.ceo/api/"
proxy = {"https": "localhost:8080"}
@pytest.mark.parametrize("number", [2, 3, 4, 5])
def test_count_image(number):
""" Проверка получения фотографий рандомных пород. """
response = requests.get(url + "breeds/image/random/{}".format(number), proxies=pr... | true |
6f40e38df27d95a0b766e93adc844e3b7d9fae22 | Python | pshrest21/Histogram-Equalization | /project2.py | UTF-8 | 7,033 | 3.203125 | 3 | [] | no_license | import cv2
from collections import Counter
import matplotlib.pyplot as mplot
import numpy as np
from PIL import Image
#Read the images using openCV
fish = cv2.imread('fish.pgm', 0)
jet = cv2.imread('jet.pgm', 0)
def oneDList(img_array):
#create convert 2D array of images to 1D array
new_img_array = [it... | true |
ea3f78c45c550a49ebc9dd67cac27fe68396dd87 | Python | LennyPhoenix/Jank-Engine | /jank/load_animation_sheet.py | UTF-8 | 845 | 2.796875 | 3 | [
"MIT"
] | permissive | import jank
def load_animation_sheet(image: jank.pyglet.image.AbstractImage, data: dict):
max_length = max(a["length"] for a in data["animations"])
sprite_sheet = jank.pyglet.image.ImageGrid(
image,
len(data["animations"]),
max_length
)
animations = {}
for a in range(len(da... | true |
7be59a6ec97d4ce920b307663ecf9d2ae63636ff | Python | KermaniMojtaba/Social_distancing_demo_COVID_19 | /ImpactOfSocialDistancing2.py | UTF-8 | 1,625 | 3.0625 | 3 | [] | no_license | city = pd.DataFrame(data={'id': np.arange(POPULATION), 'infected': False, 'recovery_day': None, 'recovered': False})
city = city.set_index('id')
firstCases = city.sample(INITIALLY_AFFECTED, replace=False)
city.loc[firstCases.index, 'infected'] = True
city.loc[firstCases.index, 'recovery_day'] = DAYS_TO_RECOVER
stat_a... | true |
fa338a6e91041744ae9316bbb9158c497c9f1be7 | Python | FrancescAlted/IC | /invisible_cities/reco/peak_functions.py | UTF-8 | 12,035 | 2.546875 | 3 | [] | no_license | """Functions to find peaks, S12 selection etc.
JJGC and GML December 2016
"""
import numpy as np
from scipy import signal
from .. core import system_of_units as units
from .. sierpe import blr
from . import peak_functions_c as cpf
from . params import CalibratedSum
from . params import PMaps
def cali... | true |
ebb96ff1b6957656bc946a57a69b451562dfa348 | Python | icaro67621/clases | /eliminar_duplicados.py | UTF-8 | 1,104 | 3.390625 | 3 | [] | no_license | import pandas as pd
import numpy as np
import random as rm
lista_valores = [[1,2],[1,2],[5,6],[5,8]]
lista_indices = list('list')
lista_columna = ['valor1','valor2']
print(lista_valores)
print(lista_indices)
print(lista_columna)
dataframe1 = pd.DataFrame(lista_valores,index=lista_indices,columns=lista_columna)
print(d... | true |
6cef2bc24af0bd0804da1b53693d6db6b05d5a08 | Python | jreniel/BayDeltaSCHISM | /pyschism/station.py | UTF-8 | 8,861 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | from builtins import open, file, str
from pandas.compat import u
import pandas as pd
import argparse
station_variables = ["elev", "air pressure", "wind_x", "wind_y",
"temp", "salt", "u", "v", "w"]
def read_station_in(fpath):
"""Read a SCHISM station.in file into a pandas DataFrame
..... | true |
821c4c9ce70125a3cf2ae491f4cbad68bd5dbb5b | Python | st4lk/LSP | /plugin/core/events.py | UTF-8 | 923 | 2.890625 | 3 | [
"MIT"
] | permissive | try:
from typing import Any, List, Dict, Tuple, Callable, Optional
assert Any and List and Dict and Tuple and Callable and Optional
except ImportError:
pass
class Events:
def __init__(self):
self._listener_dict = dict() # type: Dict[str, Callable[..., None]]
def subscribe(self, key, list... | true |
e4f6bce74b8faa9562e63b8a0b842a39ccb8537a | Python | thinksource/pysp | /pysp/spiders/bbc_spider.py | UTF-8 | 1,087 | 2.671875 | 3 | [] | no_license | import scrapy
from string import *
class BbcSpider(scrapy.Spider):
name = "bbc"
main_url = 'http://www.bbc.com'
urls=[]
link_parts=["a.top-list-item__link", "a.media__link"]
title_parts=[""]
def start_requests(self):
scrapy.Request(url=self.main_url, callback=self.parse)
def main_p... | true |
b074d9ff508c8b3a8a8c55f4b87b3c1d1d0c0623 | Python | michaelamican/python_starter_projects | /Python_OOP/SLists.py | UTF-8 | 997 | 3.546875 | 4 | [] | no_license | class Node:
def __init__(self,value):
self.value = value
self.next = None
class SList:
def __init__(self,value):
node = Node(value)
self.head = node
def addNode(self,value):
node = Node(value)
runner = self.head
while(runner.next != None):
runner = runner.next
runner.next = node
def removeNode(s... | true |
d0056b17017a5e923020f42e3178e99f23fdc8b7 | Python | lightspeed1001/tgra_3d_lab | /Matrices.py | UTF-8 | 10,771 | 2.890625 | 3 | [] | no_license | from math import * # trigonometry
from Base3DObjects import *
class ModelMatrix:
def __init__(self):
self.matrix = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1]
self.stack = []
self.stack_count = 0
... | true |
b13001d17b815e4c9e6822a4dab86fd63d830e8e | Python | oshsage/Python_Pandas | /py4e/CodeUp/1010_input_output_01.py | UTF-8 | 353 | 4.15625 | 4 | [] | no_license | # 정수형(int)으로 변수를 선언하고, 변수에 정수값을 저장한 후
# 변수에 저장되어 있는 값을 그대로 출력해보자.
a = int(input())
print(a)
# 새로운 개념: input()
# input() 함수는 어떠한 값을 입력받을 때 쓰는 함수이다. 괄호 안에 '' 로 문구를 적으면 문구도 띄울 수 있다. | true |
5af21ba3a136a3292f4b057f66820531e56b292a | Python | vpalmerini/unicamp-api | /subjects/tests/test_models.py | UTF-8 | 1,249 | 2.640625 | 3 | [
"MIT"
] | permissive | from django.test import TestCase
from subjects.models import Subject, Semester, PreReq, Continence, Equivalence
from subjects.tests.factories import SemesterFactory, SubjectFactory, PreReqFactory, ContinenceFactory, EquivalenceFactory
class BaseModelTest(TestCase):
def setUp(self):
semester = SemesterFact... | true |
ffb3ee86fb7455d3cce096c8214f9a53036fb879 | Python | Aasthaengg/IBMdataset | /Python_codes/p03041/s481457150.py | UTF-8 | 175 | 3.15625 | 3 | [] | no_license | N, K = map(int, input().split())
S = str(input())
if S[K-1] == "A":
print(S[:K-1]+"a"+S[K:])
elif S[K-1] == "B":
print(S[:K-1]+"b"+S[K:])
else:
print(S[:K-1]+"c"+S[K:]) | true |
11a6b56b37bda0ac16e2415f5e4a3144ef35895c | Python | microease/Old-boy-Python-knight-project-1 | /16-30/day30/5 demo2/server.py | UTF-8 | 822 | 2.84375 | 3 | [] | no_license | import socket
sk = socket.socket() # 买手机
# sk.bind(('192.168.16.11',9000)) # 给新买的手机换上一张卡
sk.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) #就是它,在bind前加
sk.bind(('127.0.0.1',9000)) # 给新买的手机换上一张卡
sk.listen() # 开机
while True:
try:
conn,addr = sk.accept() # 等电话
while True:
... | true |
239c4ea6f4c9590c34b2738297557f15689926cf | Python | linusreM/Gelo | /embedded/python/stepper.py | UTF-8 | 3,459 | 2.59375 | 3 | [
"MIT"
] | permissive | import numpy as np
from time import sleep
import RPi.GPIO as GPIO
M2 = 18
M1 = 15
M0 = 14
DIR1 = 20 #Direction GPIO Pin
DIR2 = 16
STEP = 21 # Step GPIO Pin
SLEEP = 27
CW = 1 # Clockwise Rotation
CCW = 0 # Counterclockwise Rotation
FW = 1
BW = 0
def motor_setup():
GPIO.setmode(GPIO.BCM)
GPIO.setup(DIR... | true |
060d30a8c2a97c0de99cf63942ce062a3a979a2a | Python | sandeepks23/pythondjango | /class/calculator.py | UTF-8 | 444 | 3.9375 | 4 | [] | no_license | class Calculator:
def __init__(self,num1,num2):
self.num1=num1
self.num2=num2
def add(self):
sum=self.num1+self.num2
print(sum)
def sub(self):
diff=self.num1-self.num2
print(diff)
def mul(self):
prod=self.num1*self.num2
print(prod)
def... | true |
6d92cc29126527e628f5a570d6f9421d3df3be9b | Python | forkcodeaiyc/skulpt_parser | /run-tests/t492.py | UTF-8 | 465 | 3.84375 | 4 | [
"MIT"
] | permissive | class B:
def __init__(self, x=0, y=0, z=0):
self.x = x
self.y = y
self.z = z
def __str__(self):
return str((self.x, self.y, self.z))
print("\nClass with defaults")
print(B())
print(B(1, 2, 3))
print(B(1), B(2), B(3))
print(B(x=1), B(y=2), B(z=3))
print(B(x=1, z=3), B(z=3, x=1... | true |
79a58a50de1e0f2b2382f4767ab4db50af6f2c38 | Python | alshamiri5/makerfaire-booth | /2016/1-o/mini-magneto/controller.py | UTF-8 | 1,529 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | import time
import gevent
import gevent.monkey
gevent.monkey.patch_all()
import socket
import serial
def derivative(value, prev):
deriv = value - prev
if (abs(deriv) < 180):
print prev, value, deriv
else:
deriv = value - (prev-360)
if (abs(deriv) < 180):
print prev, value, deriv
else:
... | true |
057cf30becd832a974dde4fd0eaaa491ae542453 | Python | B2BDA/Streamlit_Web_App_Basics | /Bank_App/dummy_bank_frontend.py | UTF-8 | 3,216 | 2.53125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 1 15:33:29 2020
@author: bishw
"""
import streamlit as st
import pandas as pd
from datetime import timedelta
import os
from smtplib import SMTP
from email.mime.text import MIMEText
from pretty_html_table import build_table
from email.mime.multipart import ... | true |
387b61f45d79a7eb05cea613a2710549d172cf6f | Python | robsiegwart/simpleFEA | /simpleFEA/preprocessing.py | UTF-8 | 2,229 | 2.953125 | 3 | [
"MIT"
] | permissive | '''
Preprocessing classes and functions.
'''
from simpleFEA.loads import Force, Displacement
def N_dist(n1,n2):
'''Calculate the scalar distance between two nodes'''
return ((n2.x - n1.x)**2 + (n2.y - n1.y)**2 + (n2.z - n1.z)**2)**0.5
class Node:
'''
Node class.
:param num x,y,z: sc... | true |
0a2fd64a99a72b21aa3b869245ac261d306c7215 | Python | idlelearner/interview_qns | /coding_practice/algos/search/count_occurence.py | UTF-8 | 263 | 3.71875 | 4 | [] | no_license | # count occurence in a elmt in a list
def count_occurrences(lst, val):
return len([x for x in lst if x == val and type(x) == type(val)])
if __name__=='__main__':
print count_occurrences([3,5,1,2,6,5,3],5)
print count_occurrences([3,5,1,2,6,5,3],0)
| true |
4dffcbdcf5ca0146f78bdcd54481ab8786cbf31c | Python | phildavis17/Advent_Of_Code | /2020/AoC_2020_4_test.py | UTF-8 | 1,920 | 2.796875 | 3 | [] | no_license | from AoC_2020_4 import * # Wildcard seemed appropriate here. Is this good practice?
BAD_PASSPORTS = """eyr:1972 cid:100
hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926
iyr:2019
hcl:#602927 eyr:1967 hgt:170cm
ecl:grn pid:012533040 byr:1946
hcl:dab227 iyr:2012
ecl:brn hgt:182cm pid:021572410 eyr:2020 byr:1992... | true |
fa70f52dccede30d8d0aff7215e2ade57e3d5e57 | Python | AlanFermat/leetcode | /linkedList/445 addTwoNumII.py | UTF-8 | 876 | 3.296875 | 3 | [] | no_license | from ListNode import *
def add(x, y):
start = ListNode(-1)
res= start
values = [0]
x1, x2= x, y
m, n = 0, 0
while x1:
x1 = x1.next
m += 1
while x2:
x2 = x2.next
n += 1
# make sure x is the longer
if n > m:
x, y, m ,n = y, x, n, m
for i in range(m-n):
values.append(x.val)
x = x.next
for _ in ... | true |
714e024b2b39f028e011dfb58dd19223bd543210 | Python | eroncastro/learning_algorithms | /linked_list.py | UTF-8 | 2,123 | 3.953125 | 4 | [] | no_license | class Element(object):
def __init__(self, value):
self.value = value
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def append(self, new_element):
current = self.head
if self.head:
while current.next:
... | true |
5ece63ba5364148d0e3c94db7fba6da9aa9b91f7 | Python | podhmo/pyramid-experiment | /point/junks/convertor/schema/wtforms.py | UTF-8 | 1,360 | 2.546875 | 3 | [] | no_license | from . import SchemaValidationException
class _ListDict(dict):
""" dummy multidict
"""
def getlist(self, k):
return [self[k]]
class SchemaMapping(object):
def __init__(self, schema):
self.schema = schema
def __call__(self, *args, **kwargs):
return self.schema(*args, **kwar... | true |
018434f2da3b7b850a89e86d9df1af7df3f9f5ae | Python | muthurajendran/modeinc-logsearch | /backend/app.py | UTF-8 | 3,850 | 2.65625 | 3 | [] | no_license | from flask import Flask, request
from flask_restful import Resource, Api, reqparse
from json import dumps
import os
import json
import operator
from pymongo import MongoClient
import pymongo
from flask_pymongo import PyMongo
from collections import defaultdict
import datetime
from flask_cors import CORS, cross_origin
... | true |
00975f114a2c4865075d23f8d15a1ecc72505aaf | Python | dhairya0904/Deep-Learning | /LanguageTranslator/translate.py | UTF-8 | 2,628 | 2.78125 | 3 | [] | no_license |
import numpy as np
import pandas as pd
import nltk
seed = 7
np.random.seed(seed)
from sklearn.preprocessing import LabelEncoder
from keras.preprocessing.sequence import pad_sequences
from keras.utils import to_categorical
from keras.models import Model
from keras.layers import Input
from keras.layers import Dense
fr... | true |
6aa6a921a6f7e0f3d104655f3384e450226c6930 | Python | Lucces/leetcode | /reorderList_143.py | UTF-8 | 847 | 3.390625 | 3 | [] | no_license | #!/usr/bin/env python
# coding=utf-8
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reorderList(self, head):
"""
:type head: ListNode
:rtype: void Do not return anythin... | true |
f9b24ea61bcee36a1edfcb3c865fd4a17ca67081 | Python | DylanMsK/TIL | /Algorithm/SW Expert Academy/7087. 문제 제목 붙이기.py | UTF-8 | 506 | 2.640625 | 3 | [] | no_license | # url = 'https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWkIdD46A5EDFAXC&categoryId=AWkIdD46A5EDFAXC&categoryType=CODE'
for _ in range(int(input())):
N = int(input())
lst = []
for i in range(N):
lst.append(input())
alp = {chr(i): 0 for i in range(ord('A'), ord('Z... | true |
fab93ded81ea59d887d301d46cf2923919969c09 | Python | yangyang198599/CQMB_Project | /cqen/telnet_task.py | UTF-8 | 558 | 2.828125 | 3 | [] | no_license | import getpass
import telnetlib
def telnet_task():
try:
HOST = "localhost"
user = input("Enter your remote account: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until(b"login: ")
tn.write(user.encode('ascii') + b"\n")
if password:
... | true |
6e8edb724c8b1ea5c4c767dc59416394baa68b70 | Python | JiahuaLink/PokemonDemo | /battleProcess.py | UTF-8 | 1,685 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : battleProcess.py
@Time : 2019/11/28 22:53:50
@Author : Jawa
@Version : 1.0
@Contact : 840132699@qq.com
@Desc : 战斗进程实现
'''
# here put the import lib
import time
import threading
from battleControls import PlayerControls, EnemyControls
c... | true |
30415ae41f2c652d5f21a17ab0809df136ee897a | Python | CodeForContribute/Algos-DataStructures | /stackCodes/check_parenthesis.py | UTF-8 | 806 | 3.65625 | 4 | [] | no_license | def check_parenthesis(exp):
stack = list()
for i in range(len(exp)):
if exp[i] == '(' or exp[i] == '[' or exp[i] == '{':
stack.append(exp[i])
continue
if len(stack) == 0:
return False
if exp[i] == ')':
x = stack.pop()
if x == '[... | true |
8ec48e87c69aaedd1dbd48b4ccc66964adb3e9f9 | Python | SietsmaRJ/dsls_master_thesis | /side_scripts/train_xgb_models.py | UTF-8 | 5,301 | 2.9375 | 3 | [] | no_license | import argparse
import pickle
import xgboost as xgb
import json
from sklearn.model_selection import train_test_split
from impute_preprocess import impute, preprocess, cadd_vars
import gzip
import pandas as pd
import numpy as np
class ArgumentSupporter:
"""
Class to handle the given command line input.
Typ... | true |