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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ab215c61c634e6b568680990f9337b8bb8efa4d1 | Python | SiberAlem/infoga | /lib/color.py | UTF-8 | 752 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# infoga - Gathering Email Information Tool
# Coded by M0M0 (m4ll0k)
class colors:
""" Colors """
def __init__(self):
self.BLUE = '\033[1;34m'
self.GREEN = '\033[1;32m'
self.RED = '\033[1;31m'
self.WHITE = '\033[1;37m'
self.CYAN = '\033[1;36m'
self.YELLOW =... | true |
12f3378b29d04461d585898a00a9b41d0f4bdcf5 | Python | kopair/code-python | /day-04-20211017/ex2.py | UTF-8 | 162 | 3.40625 | 3 | [] | no_license | # 运算
print('this is sum:', 20 + 23)
print('this is sum:', 20 + 23 * 3)
print("测试:", 100 / 10 * 23 % 5)
# 运算顺序:括号,指数,乘除加减 | true |
547bfe5d2f8a3b92cfc471eb5bb2808f5945defa | Python | rlopez93/seq-assembly-2 | /euler.py | UTF-8 | 7,392 | 3.9375 | 4 | [
"MIT"
] | permissive | #! /usr/bin/env python2
import networkx as nx
"""
Find an eulerian path
"""
# Copyright (C) 2015 by
# Edwardo S. Rivera <edwardo.rivera@upr.edu>
# All rights reserved. ??
# BSD license. ??
__author__ = """\n""".join(['Edwardo Rivera <edwardo.rivera@urp.edu>'])
__all__ = ['find_eulerian_path']
def find... | true |
21b8387eecadd1e5369b7d7ea9eb154a013607c6 | Python | jensl/critic | /src/jsonapi/v1/documentation.py | UTF-8 | 10,051 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | # -*- mode: python; encoding: utf-8 -*-
#
# Copyright 2014 the Critic contributors, Opera Software ASA
#
# 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/LI... | true |
972fb1c3d7b8585c3faf963a15f6157b7043cfc6 | Python | tylercrosse/DATASCI400 | /lab/05/L05-B-2-CategoryConsolidate.py | UTF-8 | 2,395 | 3.203125 | 3 | [] | no_license | """
# UW Data Science
# Please run code snippets one at a time to understand what is happening.
# Snippet blocks are sectioned off with a line of ####################
"""
# import package
import pandas as pd
# Download the data
# http://archive.ics.uci.edu/ml/machine-learning-databases/mammographic-masses/m... | true |
e30d2a3b1d021152602a6abafa2570b2cb5a94e9 | Python | sergiujoandrea/ProiectCarti | /main.py | UTF-8 | 3,818 | 2.921875 | 3 | [] | no_license | from time import sleep
import json
from bs4 import BeautifulSoup
from selenium import webdriver
import logging
"""
Site-uri de pe care am luat coduri sau ne-am inspirat pentru realizarea proiectului:
1. https://stackoverflow.com/questions/48477688/scrape-page-with-load-more-results-button
2. https://stackoverflow.com/... | true |
06bf7286e7eeecf99bb9720d0530888d84eb41ad | Python | MedulHasan/Project | /Stock Market prediction(AI)/stock1.py | UTF-8 | 8,396 | 2.671875 | 3 | [] | no_license | import streamlit as st
import tensorflow as tf
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from keras.layers import Dense, MaxPooling1D, Flatten
from keras.layers.convolutional import Conv1D
from keras.layers import LSTM
from keras.models import Sequential
import seaborn as sns
from sklearn.m... | true |
4fddc5b701ac39388ab455f138c69664cb5ed4d5 | Python | rafaelperazzo/programacao-web | /moodledata/vpl_data/94/usersdata/167/55304/submittedfiles/mediaLista.py | UTF-8 | 361 | 3.515625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
n=int(input('qte de valores:'))
lista=[]
for i in range(0,n,1):
t=int(input('termos:'))
lista.append(t)
def media(lista):
soma=0
for i in range (0,len(lista),1):
soma=soma+lista[i]
media=soma/len(lista)
return(media)
print('%.2f'%media(lista))
print('%.2f'%lista[... | true |
4c225d455c962860dc4cfd83be2ba14386d80cf0 | Python | KIRANROUTH/Python-Basic-Programming | /10_ImportingAndExportingModule/ShiftPythonFile/PythonFile1.py | UTF-8 | 619 | 3.171875 | 3 | [] | no_license | #When certain python module is in different location you can call or import by sys module
import sys
#Location of directory where the module name mymodule is present
sys.path.append('/Users/user/Desktop/Programming/Python/Python Programming/Programs/Episode9_Importing_modules_and_Exploring_Libuary')
from Mymodule impo... | true |
d0fa253da76828742df7885f5bd7c6336107029b | Python | bitelchux/demoncastle | /mapload2.py | UTF-8 | 4,197 | 3.265625 | 3 | [] | no_license | import json
import sys
import math
# This Python script is responsible for converting the map data created in the Tiled editor into a version which can
# be interpreted by the game itself.
# The map data is exported as a JSON file, which is interpreted by this script.
def num_to_char(num):
s = "0123456789abcdefgh... | true |
b40e853f6c9cce08aa9000065dbccf39994dddec | Python | PrivateVictory/Leetcode | /src/haoxiang/String/LengthofLastWord.py | UTF-8 | 264 | 2.984375 | 3 | [] | no_license | class Solution(object):
def lengthOfLastWord(self, s):
"""
:type s: str
:rtype: int
"""
part = s.strip().split(" ")
if len(part) == 0:
return 0
else:
return len(part[len(part)-1])
| true |
e255961d526db69f63c32ecae4ab66a3fcc21cd2 | Python | AlexisPotvin/Tracker | /AngleEstimator/angleEstimatorClass.py | UTF-8 | 655 | 3.03125 | 3 | [] | no_license | __author__ = 'User'
import GLOBAL
import threading
import time
class AngleEstimator():
# calss constructor
def __init__(self):
self._stop = threading.Event()
self.loopFrequency = 1 # Hz
threading.Thread.__init__(self, target=self.main)
self.__lastLoopTS = time.time() # ti... | true |
97b1d1f9cd3109c62fc4cded03cb74807ab5b006 | Python | mlzboy/python | /old/Object_Reference.py | UTF-8 | 150 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | class from_obj(object):
def __init__(self, to_obj):
self.to_obj = to_obj
b = [1, 2, 3]
a = from_obj(b)
print(id(a.to_obj))
print(id(b))
| true |
dc1f6c694a55b8248f49bd075cfaf9857af9c4f8 | Python | ramyasutraye/python_programming | /beginner/progression.py | UTF-8 | 95 | 3.203125 | 3 | [] | no_license | num=[]
for i in range(0,3):
num.append(int(input()))
num1=3*(num[0]+num[2])//2
print(num1)
| true |
b2bc66034d381dd2d0e639fcfee24c377ecba544 | Python | melquizedecm/pythonProjects | /ESTRUCTURA_DATOS/19B/Grafos.py | UTF-8 | 2,925 | 3.375 | 3 | [] | no_license | from Lista import *
from Cola import *
class Grafos:
vectores=[]
def __init__(self,dato):
lista=Lista(dato)
self.vectores.append(lista)
def agregarVector(self,dato):
lista=Lista(dato)
self.vectores.append(lista)
def mostrarVectores(self):
for lista in self.vec... | true |
c45e8b40f50f38739db97f91147126cbd5d0c04f | Python | kkhan003/general | /dubizzle/dubizzle/spiders/dbspider.py | UTF-8 | 1,726 | 2.546875 | 3 | [] | no_license | import scrapy
import pandas as pd
class QuotesSpider(scrapy.Spider):
name = "villa_listings"
start_urls = [
'https://dubai.dubizzle.com/en/property-for-sale/residential/villahouse/?filters=(bedrooms%3E%3D3%20AND%20bedrooms%3C%3D3)%20AND%20(amenities_v2.value%3A%22maids_room%22)'
]
# df1 = pd.... | true |
d9e4a9148c289b90c1cc326e87bd37e7f522b367 | Python | poojithayadavalli/codekata | /run length encoded string.py | UTF-8 | 200 | 2.9375 | 3 | [] | no_license | s = input()
n = len(s)
L=[]
i=0
while i < n :
c = s[i]
k=0
while i < n and c==s[i] :
k += 1
i += 1
L.append(c)
L.append(str(k))
res = ''.join(L)
print(res,end='')
| true |
ed6e21512b8768bdddd15746465b12ed680dc62a | Python | manish1990rathor/Assignment_9 | /assign_9.py | UTF-8 | 13,160 | 2.71875 | 3 | [] | no_license | #!/usr/bin/python
import re #importing re module for regular expression
ahappy=0 #defining variables
acrook=0
asurprised=0
aneutral=0
asarcastic=0
asad=0
aangry=0
bhappy=0
bcrook=0
bsurprised=0
bneutral=0
bsarcastic=0
bsad=0
bangry=0
chappy=0
ccrook=0
cs... | true |
3a8d856723b288c15cb0c842381ca8e6769a4fa4 | Python | sang-gyeong/Coding_Test | /HASH/메뉴리뉴얼.py | UTF-8 | 1,247 | 3.296875 | 3 | [] | no_license | # 24분
# 키워드 : 조합
# 주어진 메뉴들을 course에 있는 숫자의 갯수별로 조합을 만든뒤, 몇번 등장하는지 세어 딕셔너리에 저장
# 딕셔너리를 순회하며 갯수별로 최대로 많이 호출된 메뉴조합을 result에 담은 뒤 정렬
# 튜플로 리턴된 combination을 문자열로 변환하는 코드 <= 다른 방법은 없는지 찾아보자
from itertools import combinations
def solution(orders, course):
answer = []
results = {}
for order in orders:
o... | true |
40ea060b6117ea4eca8a00c543e91a07a099298b | Python | abhishekori/l-stack | /backend/HelloWorld.py | UTF-8 | 366 | 2.515625 | 3 | [] | no_license |
from GoogleSearch import GoogleSearch
gs=GoogleSearch()
class HelloWorld:
def __init__(self):
print("hello world class")
def getHelloWorlds(self,key,map):
sarchQuery=key+" Hello World program"
helloWorlds=gs.search(sarchQuery,1)
map['helloworlds'] = helloWorlds
# hw=He... | true |
5fcb9b628b285a0c383d1ae9a1e09b4e4b2381ab | Python | tarekis/RemindMePriceBot | /src/database.py | UTF-8 | 5,254 | 2.8125 | 3 | [
"MIT"
] | permissive | def map_to_zero_index(value):
return value[0]
def save_task(conn, user_name, comment_id, symbol, target, direction_is_up, currency, before_condition):
# Just throw the task in the DB
values_dict = {
'symbol': symbol,
'target': target,
'direction_is_up': direction_is_up,
'c... | true |
2c4c86ca70724d0d642b36f14abdefb94043d656 | Python | MrHamdulay/csc3-capstone | /examples/data/Assignment_1/bhrjam001/question2.py | UTF-8 | 234 | 3.65625 | 4 | [] | no_license | h = int(input("Enter the hours:\n"))
m = int(input("Enter the minutes:\n"))
s = int(input("Enter the seconds:\n"))
if (0 <= h < 24 and 0 <= m < 60 and 0 <= s < 60):
print("Your time is valid.")
else:
print("Your time is invalid.")
| true |
ecdebc56862ffa8080721a9c6de1746b53e50262 | Python | sudoberlin/python-DSA | /recursion_.py/fibonacci_series_finding_last no.py | UTF-8 | 269 | 3.859375 | 4 | [
"Apache-2.0"
] | permissive | def fib(n):
if n<=1:
return n
else:
return (fib(n-1)+fib(n-2))
count = int(input ("enter a number"))
if count <= 0 :
print ("enter value greater than 2")
else:
for i in range (count):
last_value = fib(i)
print(last_value)
| true |
ff739980731fb4aeb7ebfa10302626b5b2ffc612 | Python | andrewor14/sentimentanalysis | /plot_roc.py | UTF-8 | 1,338 | 3 | 3 | [] | no_license | #!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
import sys
if len(sys.argv) != 2:
print "Usage: plot_roc.py <log_file>"
sys.exit(1)
log_file = sys.argv[1]
roc_data = [] # (model, fpr, tpr, auc)
def parse_list(line):
return [float(x) for x in line[line.find("["):line.find("]")].strip("... | true |
d8fcc3b24cb8fea7a6dc0d3b763befdb28a239dd | Python | JonFreer/python_colmap_rerenderer | /loadTXT.py | UTF-8 | 1,496 | 2.6875 | 3 | [] | no_license | from image import Image
from rotation import Quaternion
import numpy as np
from os import listdir
from os.path import isfile, join
import PIL.Image as pil
imgPath = "data/imgs/"
cameraTXTPath = "data/cameras.txt"
imageTXTPath = "data/images.txt"
### offset: how far off the start you want to load
### amount: how many... | true |
69809a7f0cc680e76e870e051da555d36005a83b | Python | Peter-Xing/2020 | /getPic.py | UTF-8 | 664 | 2.578125 | 3 | [] | no_license | # -*- coding:utf-8 -*-
import requests
import re
import pymysql
import string
# from pyquery import PyQuery as pq
# download pictures from a website
i = 0
for x in range(1,298):
try:
html = requests.get('https://www.daquan.com/cyzy/list_'+str(x)+'.html').text
pic_url = re.findall('target="_blank">... | true |
e5d66b9255b655d48b324a276865270181785e69 | Python | JacobLei/arithmetic_python | /6_swap_nodes_in_paires/swap_nodes_in_paires_by_node.py | GB18030 | 826 | 4 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# ͨڵʵ
class ListNode(object):
def __init__(self, x):
self.value = x
self.next = None
class Solution(object):
def swap_pairs(self, head):
if head != None and head.next != None:
next = head.next
head.next = self.swap_pairs(next.next)
... | true |
0681eb9742ce621dfa506fd9ba4b519363ea39e1 | Python | seanv507/sklearn | /source/mls.py | UTF-8 | 3,901 | 2.71875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 3 20:22:22 2014
@author: sean
"""
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
def test_data(nsamples):
means = [[0, 0], [2, 2], [3, 3]]
covars = [np.eye(2), np.eye(2), np.eye(2)]
all_data = []
all_labels = []
nclasses = le... | true |
1508890563bb468021e137f142a9bd47ac736dcc | Python | NoureldinYosri/AI2016 | /project/logger.py | UTF-8 | 339 | 2.515625 | 3 | [] | no_license | def save(A,info):
print "saving"
f = file("new logger 3.txt","a+");
f.write("%s\n"%info);
for b in A:
f.write(" ".join([str(x) for x in b]));
f.write("\n");
f.write("=====================================================\n");
f.close();
print "done saving"
def write(s):
f = file("logger 3.txt","a+");
f.wri... | true |
138c2f467dac936f19bdefc017fda1f2d3de82a6 | Python | diniamo/subtitle-downloader | /utils.py | UTF-8 | 365 | 3 | 3 | [] | no_license | from os import path, getcwd
from shutil import rmtree
def chunks(lst, n):
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i:i + n]
def flatten(ml):
return [item for sublist in ml for item in sublist]
def cleanup():
tmp = path.join(getcwd(), "/tmp")... | true |
9a87da4e4a39c4aa189931cdc1f20aa18da856b3 | Python | ausbru87/python-playground | /umich-py3/grocery.py | UTF-8 | 698 | 3.875 | 4 | [
"MIT",
"LicenseRef-scancode-generic-cla"
] | permissive | grocery_list = []
grocery_item = ""
while grocery_item != "done":
grocery_item = input("Please write down an item to add to your grocery list. When you are done writing the list simply type: done \n")
if grocery_item != "done":
grocery_list.append(grocery_item)
else:
break
print(grocery_lis... | true |
7a8fb97875363522d8bb654ec7b605735d89394e | Python | chetanhonnavile/beginner | /Max_Diff.py | UTF-8 | 618 | 3.703125 | 4 | [] | no_license | #Maximum difference in an sub array
#maximum sum
def maximum_diff(list1):
max_diff = list1[1] - list1[0]
for i in range(0,len(list1)):
for j in range(i+1,len(list1)):
if (list1[j]-list1[i]) > max_diff:
max_diff = list1[j]-list1[i]
return max_diff
def maximum_sum(list1... | true |
6070a73d9ee0e47120ea5c9c365a66d390cedc93 | Python | PrabhakerVanam/Coursera_Capstone | /India-State-Crop-Analysis.py | UTF-8 | 19,253 | 3.125 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[222]:
import numpy as np # library to handle data in a vectorized manner
import pandas as pd # library for data analsysis
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
from geopy.geocoders import Nominatim
# import k-means from cluste... | true |
eb13f39585c00cd5b154f0d26632ddb829363b31 | Python | Darius-Vallejo/IUSH-AI | /IUSHElevenPoint.py | UTF-8 | 2,092 | 3.421875 | 3 | [] | no_license | """
Please notice that each import is starting the file to avoid the noise nearby the another logic or code
"""
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
import numpy as np
import matplotlib.pyplot as plt
... | true |
8b1f6dd438676c1ae9bf95996155c614ba2ff43b | Python | niviruwijayaratne/robotics-projects | /src/lab3pkg_py/scripts/lab3_func.py | UTF-8 | 2,228 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env python
import numpy as np
from scipy.linalg import expm
from lab3_header import *
"""
Use 'expm' for matrix exponential.
Angles are in radian, distance are in meters.
"""
def Get_MS():
# =================== Your code starts here ====================#
# Fill in the correct values for S1~6, as well as ... | true |
b751ad1a2017322a1a3745f8b250d807cfccb809 | Python | Rustymooz/NTC | /NEW/Algorithms/SVM.py | UTF-8 | 2,872 | 2.640625 | 3 | [] | no_license | from tkinter import messagebox
import joblib
from sklearn.svm import SVC
from sklearn.model_selection import train_test_split
from sklearn import metrics
from sklearn.datasets import load_iris
import pandas
import numpy
import File
import LogFile
import ProjectLogFile
import sklearn.externals
# IMPORT para apresentar... | true |
022d6a31eaa6ddeec30bc868fd7b68b331274d5f | Python | adrianoyasuda/Python_Threads | /hello_class_threads.py | UTF-8 | 588 | 3.75 | 4 | [] | no_license | from threading import Thread
import time
import random
class MinhaThread(Thread):
def __init__(self, i):
Thread.__init__(self)
self.i = i
def run(self):
time.sleep(random.randint(1, 5))
print("Olá, agora com classe!! {}".format(self.i))
if __name__ == '__main__':
print... | true |
55882c4704cc3222d313677a2edbcca7c27eb756 | Python | Monalisha01/area- | /listmycap.py | UTF-8 | 563 | 3.453125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 15 23:44:42 2021
@author: Asus
"""
list1=[]
n=int(input("Enter number of elements:"))
for i in range(0,n):
e= int(input())
list1.append(e)
print ("Input: ", end=" ")
print (list1)
li=list1
p=0
for p in li:
if p>0:
print(p)
... | true |
7a265e928eae0568e7d51b306f13cb14184a2de2 | Python | korneyrodionov/pythonbook | /множество путей.py | UTF-8 | 329 | 3.390625 | 3 | [] | no_license | #!/usr/bin/python3
# -*- coding: UTF-8 -*-
weather = input('Какая сегодня погода? (дождь/снег/солнце)')
if weather == 'дождь':
print('возьми зонтик!')
elif weather == 'снег':
print('возьми шапку!')
else:
print('возьми кепку!')
| true |
973bfd21cb4b38fc543063bf17eca382f5078cf7 | Python | KonstantinSKY/LeetCode | /defanging_an_ip_address.py | UTF-8 | 620 | 3.609375 | 4 | [] | no_license | """ https://leetcode.com/problems/defanging-an-ip-address/"""
import time
from typing import List
class Solution:
def defangIPaddr(self, address: str) -> str:
return "[.]".join(address.split("."))
def defangIPaddr2(self, address: str) -> str:
return address.replace(".", "[.]")
if __name__ ==... | true |
83a9f64f8f42c5eeb5f19df673d9d823934aaed9 | Python | Kasico/task_1 | /kasico_task_1.py | UTF-8 | 649 | 3.453125 | 3 | [] | no_license |
# source=["ねずこ","たんじろう","きょうじゅろう","ぎゆう","げんや","かなお","ぜんいつ",]
def read_csv():
import csv
with open('source.csv','r')as f:
reader = f.read()
return reader
def search():
word = input("鬼滅の登場人物の名前を入力してください>>")
kime = read_csv()
if word in kime:
print(f"{word}が見つかりました")
else:
... | true |
65bcdc2c2947bdcf45d06bdf7fdac37f1a15ff11 | Python | Mohammed-byte99/Sort-Analyzer | /sort-analyzer-python-startcode-master/sorting_functions.py | UTF-8 | 864 | 3.5625 | 4 | [] | no_license | def bubbleSort(anArray):
for numCompare in range(len(anArray) - 1, 0, -1):
for i in range (numCompare):
if anArray[i] > anArray[i+1]:
anArray[i], anArray[i+1] = anArray[i+1],anArray[i]
def selectionSort(anArray):
for fillSlot in range(len(anArray) - 1):
... | true |
11de1eadf2550ab26f437ea128585e94066755bc | Python | louisenaud/rl-value-prediction | /q-learning.py | UTF-8 | 3,943 | 3.140625 | 3 | [] | no_license | """
Project: rl-value-prediction
File: q-learning.py
Created by: louise
On: 01/05/18
At: 1:42 PM
"""
import gym
import numpy as np
from gym import wrappers
import tqdm
def softmax(Q, beta=1.0):
"""
Softmax function with parameter beta
:param Q:
:param beta: float, >= 0
:re... | true |
d2e035ce3974ae55b5eb31745812a620119ff26d | Python | Capone12/Fibonacci | /calc.py | UTF-8 | 3,477 | 3.3125 | 3 | [] | no_license | from tkinter import *
ventana = Tk()
ventana.title("Calculadora")
i = 0
#entrada
e_texto = Entry(ventana, font = "Calibri 15")
e_texto.grid(row = 0, column = 0, columnspan = 4, padx = 5, pady = 5)
#Funciones
def click_boton(valor):
global i
e_texto.insert(i, valor)
i += 1
def borrar():
e_texto.d... | true |
4c533f0090ed5531944ce24d6bf51ab2c4f164fd | Python | paulie-g/vector-python-sdk | /anki_vector/proximity.py | UTF-8 | 6,283 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | # Copyright (c) 2018 Anki, Inc.
#
# 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 in the file LICENSE.txt or at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | true |
a66baac0df97a90f08ecccfa936505e605bcf79b | Python | gemmechu/competitiveProgramming | /Interview/longestSubstringwithout.py | UTF-8 | 562 | 3.546875 | 4 | [] | no_license | def checkDuplicate(s):
myset = set()
for i in range(len(s)):
if (s[i] not in myset):
myset.add(s[i])
else:
return False
return True
def maxSubstring(s: str) -> int:
# if str empty
if (len(s) < 1):
return 0
result = 1
start = 0
while Tr... | true |
26e6bbf83a97e9653cd0248e77558ede3e602b91 | Python | mex3/fizmat-v | /356-360-D.py | UTF-8 | 185 | 2.765625 | 3 | [] | no_license |
#D:
n, m = map(int, input().split())
l = []
for i in range(n):
l.append(sum(map(int, input().split())))
print(l.count(max(l)))
#this code doesn't work right, and I don't know why
| true |
39d4b6cd75f5983c1af34ac36bf34ce639404d98 | Python | oskar404/aoc | /aoc2018/day01.py | UTF-8 | 639 | 3.484375 | 3 | [] | no_license | #!/usr/bin/env python3
import sys
def solve_part1(file):
sum = 0
with open(file) as f:
for line in f:
sum += int(line)
return sum
def solve_part2(file):
input = []
with open(file) as f:
for line in f:
input.append(int(line))
freqs = set()
sum = 0
... | true |
e0bb1f1dd38c77f21a1363d508caa9cba5617084 | Python | rudreshsingh999/atmos-pastforward | /round1.py | UTF-8 | 1,248 | 2.78125 | 3 | [] | no_license | from Arduino import Arduino
import time
import random
import pickle
board = Arduino('9600')
board.pinMode(21,"INPUT_PULLUP")
ar = [[1,4,3,2,5,8,7,6,9,10],[2,5,6,9,1,4,3,8,10,7],[7,9,2,5,1,8,6,3,10,4]]
file = open('output.txt', 'a')
switch=[36,52,42,48,34,46,38,44,40,50]
gates=[7,10,6,5,4,2,8,3,11,9]
def servoClose(pi... | true |
5d7b16f5e767269de7651d1dc097036f0cc62c9d | Python | aidenrism/TIL | /SWEA/5248_그룹나누기/prac1.py | UTF-8 | 704 | 2.84375 | 3 | [] | no_license | import sys
sys.stdin = open('input.txt')
def find_set(x):
if x == parent[x]:
return x
else:
return parent[find_set(x)]
def combine(go, to):
parent[find_set(to)] = find_set(go)
T = int(input())
n, m = map(int, input().split())
pair = list(map(int, input().split()))
parent = [0] * (n+1)
f... | true |
ce8b1fbd60dfed4b75da6ab82526f25e6f6a30e7 | Python | prabhanshu-aggarwal/Data_Structure_and_Algo | /Recursion/Reverse_of_string.py | UTF-8 | 490 | 3.78125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat May 23 19:51:27 2020
@author: Prabhanshu Aggarwal
"""
#reverse_list("hello world!") ==> !dlrow olleh
#Reverse of a String using recursion
def reverse_list(string):
if len(string)==0:
return
temp=string[0]
reverse_list(string[1:])
print(temp ... | true |
c83b9658c19f0b6b96b61d2b938aa37939ffda63 | Python | vladstreltsin/blox | /blox2/utils/memo.py | UTF-8 | 2,436 | 3.8125 | 4 | [
"MIT"
] | permissive | import typing as tp
class EnumeratedMemo:
""" Implemets a memo for lookup in a list of items where each has a unique name """
def __init__(self, container_fn: tp.Callable, name_fn: tp.Callable, filter_fn: tp.Optional[tp.Callable]):
"""
Parameters
----------
container_fn
... | true |
7c7f0ab15f7e8b93b3332a52e7f2faea10c4d52c | Python | ejbaird/stoich | /elstoich.py | UTF-8 | 4,992 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env python
#input: annotated reference genome and array.txt (tsv) of genes and differential expression between lines/ages
#python elstoich.py -g REL606.2.gbk (-d array.txt)
#output: chart of gene name, #C atoms, #N atoms, C/N ratio in both ancestor and evolved
import argparse
import os
import sys
import... | true |
aa5ef1e90672e9751a7f1352b44914e8c146cf8b | Python | Hengle/algorithm-1 | /CountInverse/count_inverse.py | UTF-8 | 1,545 | 3.984375 | 4 | [
"MIT"
] | permissive | """
Count inverse using divide and conquer
@author: ziye
"""
def count_inverse(array):
if len(array) == 1:
return 0, array
elif len(array) == 2:
if array[0] < array[1]:
return 0, array
else:
return 1, array[::-1]
else:
left_half_len = len(array) // ... | true |
216f4219d6b5538d6ae85d7c0ad45970d5365514 | Python | madeibao/PythonAlgorithm | /PartA/Py合并k个排序的链表.py | UTF-8 | 1,142 | 3.75 | 4 | [] | no_license |
# 合并K个有序的链表来归并成一个单一的排序链表。
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
from typing import List
import heapq
from heapq import heappop
class Solution(object):
def mergeKLists(self, lists:List[ListNode]):
# 通过建立一个堆来完成 操作。
import heapq
head =... | true |
fd41b87c85d829c65198ccdfc55c5ba9f8d96962 | Python | marcinbogdanski/marcin_ai | /dxlib/feeders_test.py | UTF-8 | 4,065 | 2.921875 | 3 | [] | no_license | import unittest
import feeders
import numpy as np
class FeedersTest(unittest.TestCase):
def setUp(self):
self.features = np.array([[ 0, 1, 2],
[10, 11, 12],
[20, 21, 22],
[30, 31, 32],
... | true |
45d3ee49bbf19bdbed5efe1e663e78c19df31c55 | Python | serea/DataMiningProject | /suliya/ID3ForContinuousValue.py | UTF-8 | 8,346 | 3.046875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sun Nov 13 11:44:31 2016
@author: Serea
"""
import operator
import json
from math import log
import math
import time
import csv
from sklearn import tree
import random
import os
sysPath = '/'.join(os.getcwd().split('/')[:-1])+'/suliya'
path = sysPath + '/continuousdata.csv'
#... | true |
092b9247b2839eaa975c8d4fc4713c078485070b | Python | theideasmith/network | /src/graphdatacollector.py | UTF-8 | 2,354 | 2.75 | 3 | [] | no_license |
import matplotlib.pyplot as plt
import networkx as nx
import csv
import os
import numpy as np
CSV_PATH = "./data/random-generated-graph-data.csv"
IMG_PATH = "./data/random-generated-graph-img/"
'''
============================================================
Based on chapter 1 of the paper
Characterization of Co... | true |
a25d55d28dbf8c6d9332e98286bcf8b05c8868fc | Python | toddhodes/bin | /xml2html.py | UTF-8 | 1,324 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python
"""
Convert XML to HTML+CSS.
"""
import sys
from xml.sax.saxutils import escape
from optparse import OptionParser
class xml_css_formatter():
def __init__(self,tab_width=2):
self.tab_width = tab_width
def format(self,content):
# format the content and split into lines, ... | true |
1ed03f9487773ac7f83134a71c7650950686c55d | Python | miaojiang1987/LeetCode | /Python/customSort.py | UTF-8 | 598 | 3.390625 | 3 | [] | no_license | class Solution:
def customSortString(self, S: str, T: str) -> str:
# dic[char] will be the number of occurrences of 'char' in T.
dic = {}
for c in T:
dic[c] = dic[c]+1 if c in dic else 1
# Write all characters that occur in S, in the order of S.
... | true |
40bcb281c66ff920e9655e1ae14b58322d8a809d | Python | imak81/query | /bcquery/serializer.py | UTF-8 | 1,055 | 3.0625 | 3 | [] | no_license | import struct
class Serializer:
def __init__(self):
self.data = ""
def write(self, bytes):
self.data += bytes
def write_string(self, string):
self.write_variable_uint(len(string))
self.write(string)
def write_hash(self, hash):
self.write(hash[::-1])
def ... | true |
6e78dae45a246bb13f0c24e0ee9693709a172de6 | Python | stanislavkuskov/obstacle_detector | /publisher.py | UTF-8 | 1,425 | 2.734375 | 3 | [] | no_license | import time
import zmq
from base import BaseThread
class Publisher(BaseThread):
def __init__(self, port="5555", topic="obstacle_detector"):
super().__init__()
port = port
context = zmq.Context()
self.socket = context.socket(zmq.PUB)
self.socket.bind("tcp://*:%s" % port)
... | true |
e9b6661b48f9268bc3a39ecaf5328236274e9691 | Python | ryu577/SurvivalAnalysis | /BaseModel.py | UTF-8 | 2,474 | 2.890625 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as integrate
class Base(object):
'''
Numerically integrates the PDF and obtains the expected value of x conditional on x less than y.
'''
def Ex_x_le_y(self,xs = np.arange(1,100000)*0.01):
vals = []
# \int_0^t x ... | true |
5d79588b5e6fb4df9456f893e2727befb557d608 | Python | Lars-H/slurp | /crop_engine/crop/source_selection/star_based.py | UTF-8 | 4,731 | 2.546875 | 3 | [
"MIT"
] | permissive | from .naive import NaiveSourceSelection
from itertools import combinations
from urlparse import urlparse
class StarBasedSourceSelection(object):
@staticmethod
def select_sources(triple_patterns, source_selector, **kwargs):
mode = kwargs.get("mode", "star")
if mode == "star":
retu... | true |
4e316f5683339acc431a3b05f881a1246544a0ce | Python | nojnoj/uaf_2015 | /BT/client_control_harness.py | UTF-8 | 1,915 | 2.75 | 3 | [] | no_license | #!/usr/bin/env python
import traceback
import sys
import subprocess
import time
cleaner_pid = 0
motion_pid = 0
def startServices():
try:
cleaner = subprocess.Popen(["./cleaner.sh", "&"])
subprocess.call(["sudo", "service","motion", "start"])
time.sleep(0.05)
c_pid = cleaner.pid
m_pid = int(su... | true |
9613e46ee0594a4b0decf265f128de26f70c8db8 | Python | atashi/LLL | /algorithm/Palindrome-Partitioning.py | UTF-8 | 1,060 | 3.59375 | 4 | [] | no_license | # Given a string s, partition s such that every substring of the partition is a palindrome.
# Return all possible palindrome partitioning of s.
# Example:
# Input: "aab"
# Output:
# [
# ["aa","b"],
# ["a","a","b"]
# ]
class Solution(object):
def partition(self, s):
"""
:type s: str
... | true |
692ce1d1d0d66696e82d94ee33500a9865d66e29 | Python | tzpBingo/github-trending | /codespace/python/examples/persistentconversationbot.py | UTF-8 | 5,968 | 3.078125 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain",
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | #!/usr/bin/env python
# pylint: disable=C0116,W0613
# This program is dedicated to the public domain under the CC0 license.
"""
First, a few callback functions are defined. Then, those functions are passed to
the Dispatcher and registered at their respective places.
Then, the bot is started and runs until we press Ctr... | true |
329667a5162a18a2b28597a416f61b457d1630f1 | Python | Canopius/School-Tasks | /OtherCode/SweetShopKiosk/SweetShopKiosk.py | UTF-8 | 1,802 | 3.671875 | 4 | [] | no_license | import pyinputplus as pyip
from datetime import *
ShopInventory = {"Red Sweet": 0.5, "Green Sweet" : 0.5, "Blue Sweet" : 0.5}
ShoppingBasket = {}
Item, Qty= False, False
def ChooseProduct():
Choices = []
for x in ShopInventory:
Choices.append(x)
Item = pyip.inputMenu(Choices, prompt = "\nPlease ... | true |
90d7bcdb3f6d1526e5a25c6cf3c3749d087184ba | Python | caiopo/INE5429 | /Primes/miller_rabin.py | UTF-8 | 721 | 3.328125 | 3 | [] | no_license | from random import randint
def decompose(n):
exp = 0
while n % 2 == 0:
exp += 1
n >>= 1
return exp, n
def miller_rabin(n, k=50):
if n in (2, 3):
return True
if n < 2:
return False
exp, rem = decompose(n - 1)
for _ in range(k):
candidate = rand... | true |
fdc26bb84f48dbc82553a953d1f152a564b7834f | Python | ThunderstormsZJ/Python | /ScriptUtil/Attribute/AttributeHelperMixin.py | UTF-8 | 904 | 2.609375 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
from .Attribute import Attribute
class AttributeHelperMixin:
def GetMethods(self):
return {funcname: func
for funcname, func in self.__class__.__dict__.items()
if hasattr(func, '__dict__')
}.items()
def HasAttr... | true |
6b6009b6a9886da1a36af6d8823fc74ab91e2011 | Python | Dalawho/cLoot_bot | /text_to_svg.py | UTF-8 | 2,348 | 2.6875 | 3 | [
"MIT"
] | permissive | """
Functions that:
- make the svg files from a string or array
- Uploads the pics to ipfs and returns the hash
- does the IPFS upload
- pins file to Pinata
"""
import subprocess
import requests
import pandas as pd
import tqdm
def make_svg(ingredients, file_name):
svg = [
"<svg xmlns=\"http://www.w3.org/2000... | true |
9db37179f4ff52858c3464946d0d19f9a2b33c7b | Python | prajwal60/ListQuestions | /learning/BasicQuestions/Qsn24.py | UTF-8 | 212 | 4.71875 | 5 | [] | no_license | # Write a Python program to test whether a passed letter is a vowel or not.
letter = input('Enter any letter')
if letter.lower() in ('a','e','i','o','u'):
print('Its Vowel')
else:
print('Its consonent') | true |
25338d764f82b7f0ee17ca4c1e4566ae60a0f2ed | Python | melkizedec/Python-advance-tracks | /koan_labs/multiples.py | UTF-8 | 201 | 3.046875 | 3 | [] | no_license | def multiple_sum():
#TODO: Your code goes here
list_number = []
indie = range(1,1000)
for x in indie:
if x % 3 == 0 or x % 5 == 0:
list_number.append(x)
return sum(x for x in list_number)
| true |
dc6afcb860671973688515f28e6d5e48976926cb | Python | tazz0009/opencv-tutorial | /module0106.py | UTF-8 | 789 | 3.140625 | 3 | [] | no_license | import cv2
import matplotlib.pyplot as plt
# Split the image into the B,G,R components
img_NZ_bgr = cv2.imread("assets/New_Zealand_Lake.jpg", cv2.IMREAD_COLOR)
# OpenCV stores color channels in a differnet order than most other applications (BGR vs RGB).
img_NZ_rgb = cv2.cvtColor(img_NZ_bgr, cv2.COLOR_BGR2RGB)
img_h... | true |
7481e91157bcd74cdadeca59879cf8ff04478fa5 | Python | 2019jrhee/FINAL | /matrix.py | UTF-8 | 214 | 3.265625 | 3 | [] | no_license | m = [[1,2,3],[4,5,6]]
find = 5
# rows
for o in range(len(m)):
# o = the first array [1,2,3]
for i in range(len(m[0])):
if m[o][i] == find:
print(m[o][i])
print ('hurray!')
| true |
e38e020a3f03b02d81516b103fa285f50c0c1af8 | Python | xtanmaygarg/HackerRankSolutions | /Problem Solving/Strings/Caesar Cipher.py | UTF-8 | 796 | 3.421875 | 3 | [] | no_license | #!/bin/python3
import os
# Complete the caesarCipher function below.
def caesarCipher(s, k):
Ans = ''
k = k % 26
for i in s:
if i.isalpha():
if i.islower():
if (ord(i) + k) > 122:
Ans += chr(96 + (ord(i) + k) % 122)
else:
... | true |
edd882afbc45c39e2bb80e10d4505b51b34f3c4a | Python | Calendis/CalEv2 | /calev2.py | UTF-8 | 21,165 | 2.5625 | 3 | [] | no_license | # A new evolution simulator, as the old one was poorly coded and difficult to maintain, as well as hopelessly full of unfixable bugs
# Bert Myroon
# 13 Sept, 2018
import pygame
from pygame.locals import *
from random import randint
from random import random
from random import seed
from math import radians, ceil, flo... | true |
5837fa864c112ec45df2641bf1a3617222bcb509 | Python | sidagarwal04/ImageAnalysis-OpenCV-CloudVision | /imagerecog-opencv-cloudvision.py | UTF-8 | 3,600 | 2.71875 | 3 | [] | no_license | import cv2
import numpy as np
import sys
import io
import os
import google.cloud.storage
import google.cloud.vision
sys.path.append('/usr/local/lib/python2.7/site-packages/')
# Create a storage client.
storage_client = google.cloud.storage.Client()
# TODO (Developer): Replace this with your Cloud Storage bucket name... | true |
b5892b40a3496e3a33a77c5bdfad4f96d7fa4afc | Python | CodingHaHa/PythonBase | /03高级语法/06生成器/01列表生成式.py | UTF-8 | 376 | 4.03125 | 4 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by fengL on 2017/9/3
#1:列表生成式
a = [x for x in range(10)]#使用空格分割
print(a)
#2:对每个元素进行操作,然后在放入到列表中。
a = [x*2 for x in range(10)]
print(a)
#3:使用函数来查找列表生成式
#定义函数
def f(n):
return n**3
a = [f(x) for x in range(10)]
print(a)
| true |
dad94fb752a2b65e3b58e81cb754953dca8bfdc2 | Python | abhishekzambre/Python_Programs | /LeetCode/007ReverseInteger.py | UTF-8 | 365 | 3.40625 | 3 | [] | no_license | def reverse(x):
minus = False
if x < 0:
minus = True
x = x * -1
t = x % 10
x = x // 10
while x > 0:
d = x % 10
t = t * 10 + d
x = x // 10
if t > pow(2, 31) - 1:
t = 0
return t * -1 if minus else t
print(reverse(123))
print(reverse(-123))
... | true |
d69af2b1d0be9d0cbe27c6f2f4d1e9e5e3b098cd | Python | daelynj/Data-Mining-Heart-Disease | /randomforests/main.py | UTF-8 | 3,690 | 2.90625 | 3 | [] | no_license | import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import numpy as np
import sys
plot_num = 0
def plot_results(x, y, z, plot_name, version, test_split_percentage):
global plot_num
plot_num += 1
plt.figure(plot_num)
... | true |
0a935f8df1c48dc0e92607171ef64f7b91a1bb77 | Python | siberiacalling/applied_python | /async_file_storage/storage.py | UTF-8 | 3,647 | 2.78125 | 3 | [] | no_license | import os
from sys import argv
import yaml
from aiohttp import web, ClientSession
import asyncio
class ConfigFileException(Exception):
pass
def get_config_dict(config_file):
with open(config_file, 'r') as stream:
try:
yaml_dict = yaml.load(stream)
return yaml_dict
exc... | true |
353916785ad92ebad22e12902ea80f56babf11e0 | Python | vsivakumar9/py4e_work | /Exer9_4a.py | UTF-8 | 1,250 | 3.4375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Jan 19 14:45:10 2018
@author: Shiva
"""
#Write a program to read through the mbox-short.txt and figure out who has
#the sent the greatest number of mail messages. The program looks for 'From '
#lines and takes the second word of those lines as the person who sent ... | true |
e71f8c2effdd50646b90b088ab90b3aff960e4bd | Python | DominKim/Learning_Python | /chap03_DataStr/exams/exam03.py | UTF-8 | 518 | 3.921875 | 4 | [] | no_license | '''
step05 문제
문) price에는 과일 가게에 진열된 과일과 가격이 저장되어 있고,
buy에는 고객이 구매한 장바구니이다.
list + for 형식1)을 적용하여 구매 상품 총 금액(tot_bill)을 계산하시오.
'''
# 과일가게 진열 상품
price = {'사과':2000, '복숭아' : 3000, '딸기' : 2500}
# 구매 상품
buy = {'사과' : 3, '딸기' : 5}
# 구매 상품 총 금액
tot_bill = [v*price[k] for k,v in bu... | true |
8953c993e91a978eef2bcebba00938b98805be50 | Python | WuPeng2019/Two-Sum | /1_two_sum.py | UTF-8 | 703 | 3.984375 | 4 | [] | no_license | """
Given an array of integers, return indices of the two numbers
such that they add up to a specific target.
You may assume that each input would have exactly one solution,
and you may not use the same element twice.
给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那
两个整数,并返回他们的数组下标。
你可以假设每种输入只会对应一个答案。但是,你不能重复利用这... | true |
17e94ed2657f44b338f1500b3051b3ab8e87314e | Python | ComputeCanada/examples-hyperparameter-search | /array_job.py | UTF-8 | 3,174 | 2.75 | 3 | [] | no_license | '''
Compute Canada distributed hyperparamter search example.
Adapted from the keras mnist example.
'''
from itertools import product
import os
import os.path as osp
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers imp... | true |
00bbff0f28ef783cffe4f976a3a7b77ac26a3e6d | Python | madingess/alien_invasion | /settings.py | UTF-8 | 1,919 | 3.09375 | 3 | [] | no_license | import pygame
class Settings():
"""A class to store all settings for Alien Invasion."""
def __init__(self):
"""Initialize the game's static settings."""
# Screen settings
self.screen_width = 1200
self.screen_height = 800
self.bg_color = (230, 230, 230) # Grey
# Ship settings
self.ship_limit = 3
... | true |
9d49a53806d52f595950655048bd75e86abad478 | Python | Aasthaengg/IBMdataset | /Python_codes/p03721/s736562396.py | UTF-8 | 265 | 2.71875 | 3 | [] | no_license | from collections import Counter
n, k = map(int, input().split())
c = Counter()
for _ in range(n):
a, b = map(int, input().split())
c[a] += b
c = sorted(c.items(), key=lambda x: x[0])
for i, v in c:
k -= v
if k <= 0:
print(i)
exit() | true |
7bc8f07afed5c775b96dd7fa7423cd11cdf6de01 | Python | stheartsachu/Python_basics_and_data_base_operations | /splitting_data_into_odd_and_even_numbers.py | UTF-8 | 237 | 3.859375 | 4 | [] | no_license | # splitting data into odd even numbers
data = [45,56,67,23,57,78,67,454]
odd = []
even = []
for d in data:
if d % 2:
odd.append(d)
else:
even.append(d)
print(f'Odd number : {odd}')
print(f'Even numbers : {even}')
| true |
51ed6a1d759170501c5fbaab75e082a5c2fd105a | Python | Jiawei955/udpchat | /server.py | UTF-8 | 3,132 | 2.78125 | 3 | [] | no_license | import sys
import json
from socket import *
import os
import time
class Server:
def __init__(self,port):
self.port = port
self.serverSocket = socket(AF_INET,SOCK_DGRAM)
self.serverSocket.bind(('',self.port))
self.clientStatus = {}
self.ack = False
def reg(self,usernam... | true |
51fa615ff2679e4949bf06d49d17904cb2d26bdb | Python | kel85uk/mpi-master-slave | /examples/example4.py | UTF-8 | 4,835 | 3.296875 | 3 | [
"MIT"
] | permissive | from mpi4py import MPI
from mpi_master_slave import Master, Slave
from mpi_master_slave import WorkQueue
from enum import IntEnum
import random
import time
Tasks = IntEnum('Tasks', 'TASK1 TASK2 TASK3')
class MyApp(object):
"""
This is my application that has a lot of work to do so it gives work to do
to i... | true |
cf47bb888c3158b8e4be60eb25ec3c9abe5a4c19 | Python | james0828/LeetCodeTraining | /BinaryTreeLevelOrderTraversalII/solve.py | UTF-8 | 876 | 3.09375 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def levelOrderBottom(self, root: TreeNode) -> List[List[int]]:
if root is None: return []
... | true |
d056a414ce28146cd72a41738ef631091bacc99e | Python | malay190/Assignment_Solutions | /assignment13/ass13_5.py | UTF-8 | 470 | 3.640625 | 4 | [] | no_license | #Q.5- Write a program to show and handle following exceptions:
# 1. Import Error
# 2. Value Error
# 3. Index Error
#import errror
try:
from surinder import mota
except Exception as e:
print("import error")
print("...............")
#value error
try:
s=int(input("enter your name:"))
except Exception as e:
prin... | true |
781dba047674372c79a47bdf8732fd0ccd820fb9 | Python | pabllo87/python_poznan_2014_08_05 | /kata/mars_rover/test_mars_rover.py | UTF-8 | 1,644 | 3.140625 | 3 | [] | no_license | import unittest
from mars_rover import Rover, Vector
class MarsRoverTests(unittest.TestCase):
def setUp(self):
self.rover = Rover()
def test_mars_rover_starts_at_0_0(self):
self.assertEqual((0,0), self.rover.position)
def test_mars_rover_starts_facing_north(self):
self.assertEqual... | true |
3e5f9f21867f4a2fd743ae805e0d9ae5f09be647 | Python | alonmelon25/SI206-Fall2017 | /Classwork/BeautifulSoup/bs1.py | UTF-8 | 482 | 3.375 | 3 | [] | no_license | import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
with open("index.html") as fp:
soup = BeautifulSoup(fp, "lxml")
tags = soup('a')
for tag in tags:
print(tag.get('href', None))
#Kinds of objects
#Tags
soup = BeautifulSoup('<b class="boldest">Extremely bold</b>', "lxml")
tag = soup.b... | true |
eb59c90646c7d77c87fd8a4af5410fa4243cc9f2 | Python | phonyphonecall/open-lambda | /testing/lambdas/thread_counter.py | UTF-8 | 567 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | from threading import *
import time
t = None
counter = 0
m = Lock()
def worker():
global counter
while True:
m.acquire()
counter += 1
m.release()
time.sleep(0.01)
def handler(db_conn, event):
global t, counter
if t == None:
print 'Init worker thread'
t ... | true |
28f2c6479f7d704c82c2c9c0b3aec79131353c98 | Python | bagibence/hidenseek_hmm | /hidenseek/util/plotting/time_points.py | UTF-8 | 1,668 | 3.078125 | 3 | [] | no_license | import matplotlib.pyplot as plt
import seaborn as sns
import hidenseek.util.plotting.plotting_setup as plotting_setup
def show_time_point_names(ax, positions, names, labelrotation=60, label_font_size=None):
"""
Plot time point names above the given Axes
Parameters
----------
ax : plt.Axes
... | true |
aa1623b0411c6d7b47a6f7e91f3761b786a1fc94 | Python | transcendtron/course_python | /code/02/condition.py | UTF-8 | 829 | 4.40625 | 4 | [] | no_license | # 条件
x = 5
if x > 10: # if引导条件语句,用冒号结尾
print('x > 10') # 当条件语句为True时,执行该语句
print('end')
# 条件嵌套
x = 5
if x < 10:
print('x < 10')
if x > 4:
print('ok')
if (x < 10) and (x > 4):
print('ok')
# else
if x < 10:
print('yes')
else:
print('default')
# elif
if x == 1:
... | true |
ff48b74772ad9f11bd36cbb4cbcd67a522118c7a | Python | vijeshm/navigationAlgorithm | /Report/Gnu Tella Network/AtoB.py | UTF-8 | 47,057 | 3.65625 | 4 | [] | no_license | import matplotlib.pyplot as plt
import random
import networkx as nx
import math
import numpy
import pdb
import pickle
def findHit(G, A, B, pathA, pathB):
'''
G: Graph which is undergoing machine learning
A: Vertex #1
B: Vertex #2
pathA: contains the drunkard walk starting from A
pathB: contains the drunkard walk... | true |
5af20dc33e64a12b89399aa01948f58c524b8e2f | Python | edgaromar90/react-project-mycontacts | /server/server/__init__.py | UTF-8 | 4,634 | 2.734375 | 3 | [] | no_license | from flask import Flask, jsonify, request, Response
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
import os
import platform
app = Flask(__name__)
CORS(app)
if platform.system() == 'Windows':
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+os.getcwd()+'\\database.db'
else:
app.config['SQ... | true |