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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ca317840ba25c9ca0fa95faa82c7425f4f4fcccc | Python | ShowmickKar/Snake-AI-using-A-Star-Pathfinding | /ai_agent.py | UTF-8 | 5,598 | 3.359375 | 3 | [] | no_license | import pygame
import math
import random
from queue import PriorityQueue
class Agent:
DIRECTIONS = [[1, 0], [-1, 0], [0, 1], [0, -1]]
current_path = []
@staticmethod
def manhattenDistance(snake_position, food_position):
return abs(snake_position[0] - food_position[0]) + abs(
snake_... | true |
234106b43eaf12915ade4145fdf21127f1b46110 | Python | juhi-ghosh/nMIL | /code/checkCosine.py | UTF-8 | 4,085 | 2.546875 | 3 | [] | no_license | import pickle
#from sklearn.metrics.pairwise import cosine_similarity
import gensim.models as g
import codecs
import numpy as np
import math
def vector_cos5(v1, v2):
v1 = np.array(v1)
v2 = np.array(v2)
prod = np.dot(v1, v2)
len1 = math.sqrt(np.dot(v1, v1))
len2 = math.sqrt(np.dot(v2, v2))
return pr... | true |
0041f7cc610c80e93bd721950cfc88e33e1d47b5 | Python | jiroyamada/Essence-of-ML | /ch4/contour2.py | UTF-8 | 333 | 3.359375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
def f(x,y):
return x**2 + y**2 / 4
x = np.linspace(-5,5,300)
y = np.linspace(-5,5,300)
xmesh, ymesh = np.meshgrid(x,y)
z=f(xmesh,ymesh)
colors=["0.1","0.3","0.5","0.7"]
levels = [1,2,3,4,5]
plt.contourf(x,y,z, colors=colors,levels=level... | true |
0db21a7c57c8d6fd73cae0ecb544069af2f43427 | Python | jasonpea/DAD-PROJECT | /ccc/sunflowers.py | UTF-8 | 604 | 2.953125 | 3 | [] | no_license | n = int(input())
l = []
for i in range(n):
l.append(list(map(int, input().split(" "))))
if l[0][0] > l[0][1]:
if l[0][0] > l[1][0]:
rotationsneeded = 2
else:
rotationsneeded = 3
else:
if l[0][0] < l[1][0]:
rotationsneeded = 0
else:
rotationsneeded = 1
for i in ran... | true |
46e326e4747da2af04369e334bfa008df18b0059 | Python | hologerry/SVHNClassifier-PyTorch | /visualize.py | UTF-8 | 1,003 | 2.703125 | 3 | [
"MIT"
] | permissive | import argparse
import os
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()
parser = argparse.ArgumentParser()
parser.add_argument('-l', '--logdir', default='./logs', help='directory to read logs')
def _visualize(path_to_log_dir):
losses = np.load(os.path.joi... | true |
1a7b3a36d09f3d8d34376303ec051e063579094e | Python | Anand601/Octobit8_python_assignment | /MAtplotlib.py | UTF-8 | 1,350 | 3.734375 | 4 | [] | no_license |
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
# line graph
x = np.array([3, 4, 5, 6])
y = x * 3
plt.plot(x, y)
plt.show()
# In[14]:
# bar graph
data = {'english': 20, 'maths': 15, 'history': 30,
'Python': 35}
courses = list(data.keys... | true |
366ec3e383350c09995ef1c1cf3c70e0cc12b286 | Python | Sharonoito/OOP-Python | /car.py | UTF-8 | 368 | 3.28125 | 3 | [] | no_license | class Car:
def __init__(self,color,model,mileage,speed):
self.color=color
self.model=model
self.mileage=mileage
self.speed=speed
def hoot(self):
return f"I love {self.color} cars espesially {self.model} with {self.mileage} mileage"
def accelerate(self):
retur... | true |
f483f4cfdc38d463d05bb3f5abad18698c4adc18 | Python | jackeelam/180DA-WarmUp | /Week_0_Intro_SW_CV/filename.py | UTF-8 | 171 | 3.109375 | 3 | [] | no_license | if __name__ == '__main__':
x = "ECE_180_DA_DB"
if x == "EE_180DA_DB":
print("You are living in 2017")
else:
#this is a comment
x = x + " - Best class ever"
print(x)
| true |
d8cbb3f395c53ad5733e28f1e83dd3b2f7dd785e | Python | Ian84Be/Intro-Python-II | /src/adv.py | UTF-8 | 5,987 | 3.25 | 3 | [] | no_license | import re
import sys
import time
from color import Color
from item import Item
from player import Player
from room import Room
from textwrap import wrap
items = {
'key': Item('Key', 'This Key is unusally large, and feels warm to the touch.', useRooms={'Treasure Chamber': f'You hesitate for a moment, contemplating ... | true |
c7103558449ea397e87836edc755155ee33b5493 | Python | mnovack8/pythonExample | /1function/basic.py | UTF-8 | 1,050 | 4.21875 | 4 | [] | no_license | long_statment = '''
Print a paragraph with out \\n everywhere
See another line
'''
create_dynamic_value_strings = "Mike"
print(f"My name is {create_dynamic_value_strings} which is {len(create_dynamic_value_strings)} chars long")
contains_string_check = "This contains some words"
print("words" in contains_str... | true |
84f0473f298949b28103b761b368736d8cb112f3 | Python | wendyrvllr/Dicom-To-CNN | /dicom_to_cnn/model/petctviewer/RoiPolygon.py | UTF-8 | 1,992 | 2.90625 | 3 | [
"MIT"
] | permissive | import matplotlib.patches
from dicom_to_cnn.model.petctviewer.Roi import Roi
class RoiPolygon(Roi):
"""Derivated Class for manual Polygon ROI of PetCtViewer.org
Returns:
[RoiPolygon] -- Polygone ROI
"""
def __init__(self, axis:int, first_slice:int, last_slice:int, roi_number:int, type_number... | true |
b386294a2763c5aa08aabb9c9e059394bdf5e630 | Python | JavaRod/SP_Python220B_2019 | /students/nskvarch/Lesson5/test_database.py | UTF-8 | 4,028 | 3 | 3 | [] | no_license | #!/usr/bin/env python3
"""Unit test for the HP Norton Furniture Consume APIs with NoSQL Assignment."""
# Created by Niels Skvarch
import unittest
import os
from database import import_data, show_available_products, show_rentals, clear_db
class TestCaseOne(unittest.TestCase):
"""Test the Import Data function from... | true |
d3a25b0de969c8af790db4b241ba8b3af182a11a | Python | i-aditya-kaushik/geeksforgeeks_DSA | /Searching/Codes/search_an_ele.py | UTF-8 | 1,238 | 4.75 | 5 | [] | no_license | """
Search an Element in an array
Given an integer array Arr[] and an element x. The task is to find if the given element is present in array or not.
Input:
First line contains an integer, the number of test cases 'T'. For each test case, first line contains an integer 'N', size of array. The second line contains the ... | true |
28f04b868a0c73536626807300bb2cf5287755d8 | Python | talekarpm1/micromagneticmodel | /micromagneticmodel/hamiltonian/exchange.py | UTF-8 | 654 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | import joommfutil.typesystem as ts
from .energyterm import EnergyTerm
@ts.typesystem(A=ts.Scalar(unsigned=True),
name=ts.Name(const=True))
class Exchange(EnergyTerm):
_latex = r'$A (\nabla \mathbf{m})^{2}$'
def __init__(self, A, name="exchange"):
"""An exchange energy class.
A... | true |
703a51cfba03c99fd8d04a690f1a148856a2eb56 | Python | james-d-pickering/introductory-quantum-mechanics | /figures/python_scripts/energy_gaps.py | UTF-8 | 1,332 | 2.765625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 2 09:50:07 2019
@author: pickering
"""
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import matplotlib.lines as lines
import matplotlib.gridspec as gs
import matplotlib.patches as patch
plt.rc('text', usetex=True)
plt.rc('f... | true |
94136cb891564e83e918a2a1e3b7d392ab9aaf9e | Python | tntman42/statistics | /STAT215-Final.py | UTF-8 | 6,418 | 3.359375 | 3 | [] | no_license | import math
from statistics import mean, variance
from scipy.stats import *
import calculus_math
import stat_math
def problem1(tax_free, mutual, both):
print("Problem 1")
oor = tax_free + mutual - both
print("\ta) ", oor)
print("\tb) ", (1 - oor))
def problem2(h, nh):
print("Problem 2")
n = ... | true |
6c8f6d3ed3eff3742b8f4ee5458c5ece23c5f16b | Python | ragibayon/Python-for-Everybody-Specialization | /Using Python to Access Web Data/Week 3/Understanding the Request_ Response Cycle.py | UTF-8 | 521 | 3.109375 | 3 | [] | no_license | """Understanding the Request / Response Cycle."""
import socket
import re
mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#website = input('What is the website?\n')
website = 'http://data.pr4e.org/intro-short.txt'
search = re.search(r'//(.+?)/', website)
host = search[1]
mysocket.connect((host, 80))
cmd ... | true |
a7d9605dd8dbb07187e82ce37bebe240169f8ee0 | Python | renjithraj2005/python-for-beginners | /basics-15-server/server.py | UTF-8 | 1,465 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive |
#!/usr/bin/env python
import socket
import re
def template(id):
return """HTTP/1.0 200 OK
Content-Type: text/html
<!DOCTYPE html>
<head>
<title>Success</title>
</head>
<body>
Successfully receieved ... | true |
d27fc3de411368960feba982788a37d1f7d27399 | Python | RowiSinghPXL/IT-Essentials | /6_strings/opgave5.py | UTF-8 | 143 | 3.171875 | 3 | [] | no_license | naam = input("Naam: ")
voornaam = input("Voornaam: ")
nieuwe_naam = voornaam[0].upper() + ". " + naam[0].upper() + naam[1:]
print(nieuwe_naam) | true |
703701ca91675b291db087bdd75c0fa39fe4026b | Python | vpiyush/SandBox | /python-samples/Max.py | UTF-8 | 167 | 3.546875 | 4 | [] | no_license |
def maximum(a1, b1):
if a1 > b1:
return a1
else:
return b1
res = maximum(10, 20)
finalres = maximum(15, res)
print(f"res is {finalres}")
| true |
8aedccd9522d9e1715f7f5e81d962a592bce8507 | Python | Liraz-Benbenishti/Python-Code-I-Wrote | /next_py/next-py.1.1.3.py | UTF-8 | 598 | 3.8125 | 4 | [] | no_license | def chk_divide_four(number):
"""
:param: number: a number to check.
:type number: integer
:return: check either or not the number divided by four without remainder.
rtype: bool
"""
return number % 4 == 0
def four_dividers(number):
"""
:param: number:
:type number: integer6
:return: return a li... | true |
b2edadc0680085eeb3041aa314498d166fb59f80 | Python | divanshu79/GeeksForGeeks-solutions | /Rearrange characters.py | UTF-8 | 602 | 2.796875 | 3 | [] | no_license | from collections import defaultdict
for _ in range(int(input())):
n = input()
def_dict = defaultdict(int)
k = []
for i in n:
if def_dict[i] == 0:
k.append(i)
def_dict[i] += 1
arr = []
for i in k:
m = def_dict[i]
arr.append((m, i))
arr.... | true |
fbd4c237c8300ce47778d961b4450d60fce3ce49 | Python | elenamoglan/Introducere_Afisare_Calcule | /Problema 6.py | UTF-8 | 119 | 3.53125 | 4 | [] | no_license | n = int(input('Numărul de mere primte: '))
print(f'La primul copil au ramas {n-2}, iar la al doilea copil are {n+1}') | true |
873fd2d21bfee6005bd7ba3628451acb4ea0ae53 | Python | margolek/Study | /Semester_5/Electromechanical_elements_of_automatics/EA11_brushless_motor/plots.py | UTF-8 | 7,347 | 2.796875 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from numpy import *
from scipy.interpolate import *
def zad1():
V = [3,7,12,15.4,20,23,27.4,30]
n = [532,916,1342,1734,2189,2527,2945,3220]
p1 = polyfit(V,n,1)
plt.style.use('seaborn')
plt.title('Charakterystyka prędkości obrotowej w funkcji ... | true |
52381779950226667f4a42b7576840c498365905 | Python | ninjer94/03_Math_Quiz | /02_rounds_test.py | UTF-8 | 2,249 | 3.921875 | 4 | [] | no_license | # Function used to check input is valid
import random
def num_check(question, exit_code):
while True:
response = input(question)
round_error = "Please type either <enter> or an integer that is more than 0"
if response != exit_code:
try:
response = in... | true |
51e8cfb6d9999cbffb5be91f458d71644533ba43 | Python | onebeartoe/games | /memory/cards/game/src/main/python/onebeartoe/games/memory/MemoryCardsGameEndOfGameSpecification.py | UTF-8 | 2,227 | 2.8125 | 3 | [] | no_license |
import unittest
from MemoryCardsGame import MemoryCardsGame
from MemoryCardsGameCannedData import MemoryCardsGameCannedData
from MemoryCardsGameResponse import MemoryCardsGameResponse
class MemoryCardsGameEndOfGameSpecification(unittest.TestCase):
def setUp(self):
self.cannedData = MemoryCardsGameCanned... | true |
71650573a24dba70e7ccf82aa114858aca6b21cc | Python | azkasena/Git-Introduction | /Azka Avicenna R_UPNJatim/identitas.py | UTF-8 | 295 | 2.75 | 3 | [] | no_license | print ("Nama : Azka Avicenna Rasjid")
print ("Jurusan : Informatika")
print ("Alasan ingin masuk GDSC : Alasan saya ingin masuk GDSC adalah saya ingin belajar tentang programming baik dari data science hingga web development. Saya juga ingin menambah relasi dengan teman-teman programmer dari luar kampus. ")
| true |
af2c605d39a65ad67d788de14d696d819f810c69 | Python | nfredrik/pyjunk | /packt_book2/src/stock_alerter/reader.py | UTF-8 | 1,729 | 3.1875 | 3 | [] | no_license | import csv
from datetime import datetime
class ListReader:
"""Reads a series of updates from a list"""
def __init__(self, updates):
self.updates = updates
def get_updates(self):
for update in self.updates:
yield update
class FileReader:
def __init__(self, filename):
self.filename = filenam... | true |
4bbb51bfea49928aafbe9b14a7084ad9af061cd0 | Python | GillesVandewiele/InterpretableEnsembles | /constructors/xgboostconstructor.py | UTF-8 | 6,453 | 2.78125 | 3 | [] | no_license | import time
from bayes_opt import BayesianOptimization
from sklearn.cross_validation import cross_val_score
from xgboost import XGBClassifier
from data.load_all_datasets import load_all_datasets
import matplotlib.pyplot as plt
class XGBClassification:
def __init__(self):
self.clf = None
self.nr... | true |
a0886c3cdc9a606f95db9ebf601328296ff83319 | Python | dilaraism/-solutions | /codewars/python/smallest.py | UTF-8 | 102 | 2.90625 | 3 | [] | no_license | def smallest(n):
from fractions import gcd
return reduce(lambda x, y: x*y/gcd(x,y), range(1,n+1))
| true |
c32070906244c249178b1010d7991c1f214f0079 | Python | phuclhv/Project-Euler | /30-Digit5thPower.py | UTF-8 | 931 | 4.1875 | 4 | [] | no_license | '''
https://www.projecteuler.net/problem=30
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44
As 1 = 14 is not a sum it is not included.
The sum of these numbers is 1634 + 8208 ... | true |
8b17ae1b37085ac6d08385a7bf5575aeb246ab20 | Python | shekarchi/Computational-Models-of-Semantic-Change | /FinalProject/extract_target_words.py | UTF-8 | 3,606 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 19 23:53:12 2018
@author: zahra
"""
import re
import time
import urllib.request
from bs4 import BeautifulSoup
import json
def load_BNC_words(filepath):
with open(filepath) as f:
content = f.readlines()
words = [x.strip() for x in c... | true |
8ba095374b52e9d716b653d718c563f3ec81bb6b | Python | junclemente/algorithms_and_unittests | /test_sum_of_primes.py | UTF-8 | 1,173 | 4 | 4 | [] | no_license | import unittest
from sum_of_primes import prime_sum
"""
This algorithm is used to find the sum of all prime numbers that are
less than or equal to the provided number which is always a positive integer.
My solution creates a list dynamically by testing odd numbers to see if they
fit the definition of a prime number. ... | true |
bbf3474bccda48213091331e17597aee79914921 | Python | limjungho/LostarkMarketPriceInfo | /MakeItemPriceDB_CheckPrice.py | UTF-8 | 4,263 | 2.53125 | 3 | [] | no_license | import os
import json
import requests
import sqlite3
from csv import reader
from bs4 import BeautifulSoup
import time
conn = sqlite3.connect("LostArkMarketPrice.db")
cur = conn.cursor()
CategoryList=['50000', '60000']
for cate in CategoryList:
for pageno in range(1,7):
url="https://lostark.game.onstove.co... | true |
91f722ff05e45c2a194c03036a9bda6479a9e259 | Python | sandialabs/pvOps | /pvops/text/preprocess.py | UTF-8 | 17,533 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | import re
import nltk
import numpy as np
import datefinder
import traceback
from datetime import datetime, timedelta
try:
nltk.data.find('tokenizers/punkt')
except LookupError:
nltk.download('punkt')
def preprocessor(
om_df, lst_stopwords, col_dict, print_info=False, extract_dates_only=False
):
"""Pr... | true |
f14eea16b1f5507b715562de1d288beaf80a3a7c | Python | qutip/qutip-qip | /src/qutip_qip/compiler/circuitqedcompiler.py | UTF-8 | 8,007 | 3.015625 | 3 | [
"BSD-3-Clause"
] | permissive | import numpy as np
from ..operations import Gate
from ..compiler import GateCompiler, Instruction
__all__ = ["SCQubitsCompiler"]
class SCQubitsCompiler(GateCompiler):
r"""
Compiler for :class:`.SCQubits`.
Compiled pulse strength is in the unit of GHz.
Supported native gates: "RX", "RY", "CNOT".
... | true |
f9c14480e0de9fbdcfbc54b9713007ea79705774 | Python | LennyFan/PythonNoteBook | /heapq.py | UTF-8 | 3,515 | 3.703125 | 4 | [] | no_license | inport heapq
# for all k
# a[k] <= a[2*k+1] and a[k] <= a[2*k+2]
# we can use this to achieve shortest-path algorithm
#### Basic Usage
q = []
heapq.heappush(q, (5, 'bwa'))
heapq.heappush(q, (7, 'bwa'))
heapq.heappush(q, (2, 'bwa'))
heapq.heappush(q, (1, 'bwee'))
heapq.heappush(q, (3, 'kiki'))
while q:
next_item... | true |
a8106acafc22ec0b3219f72060e895980ce49449 | Python | Selvaganapathi06/Pandas | /Pandas-reading-txt/Pandas-readinf-txtfile.py | UTF-8 | 240 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[2]:
#pandas reading text files
import numpy as np
import pandas as pd
poke12 = pd.read_csv('pokemon_data.txt', sep=" ", header=None)
print(poke12)
print(poke12.head(5))
print(poke12.tail(5))
| true |
dfd61b3d69c0d561e7c30cd0af8d4460f54f9484 | Python | lin-huaping/pythonHomeWork | /MyTrain.py | UTF-8 | 3,337 | 2.6875 | 3 | [] | no_license | import tensorflow as tf
import pandas as pd
import numpy as np
import sys
import matplotlib as mpl
import matplotlib.pyplot as plt
from tensorflow import keras
from sklearn.metrics import confusion_matrix
print(tf.__version__)
print(sys.version_info)
for module in mpl, np, pd, keras:
print(module.__name__, module... | true |
47713f76b4e40b21826c652b0d23ae92a49e09b7 | Python | smerdis/mrs_amblyopia | /individual_data_utils.py | UTF-8 | 5,954 | 3.03125 | 3 | [] | no_license | import numpy as np
import pandas as pd
from scipy.io import loadmat
import lmfit as lf
import glob
def load_individual_data(data_file, columns):
"""Function that loads individual psychophysics data stored in .mat files.
data_file: path to .mat file
columns: list of column names. must match number of c... | true |
be565cdde75d33a0c868779310fe3b1946be9134 | Python | limacaiquelg/video-pymaker | /robots/video.py | UTF-8 | 9,525 | 2.578125 | 3 | [] | no_license | from moviepy.audio.fx.audio_fadein import audio_fadein
from moviepy.audio.fx.audio_fadeout import audio_fadeout
from moviepy.audio.fx.volumex import volumex
from moviepy.editor import *
from moviepy.video.VideoClip import ImageClip
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy... | true |
3bf50da17ef9ddac1977aef64bd0a0a5effcb6a3 | Python | nilavalagan/MyCodeParser | /MyCodeParser/myCodeParser.py | UTF-8 | 5,845 | 2.8125 | 3 | [] | no_license | from flask import Flask, Response, request
import json
from tree_sitter import Language, Parser
from urllib.request import urlopen
# Create an instance of the Flask class that is the WSGI application.
# The first argument is the name of the application module or package,
# typically __name__ when using a single module... | true |
7eb6ae42905eccf8dc7bd5783920b04cc341986a | Python | yj-noh/treform | /examples/scraping_test2.py | UTF-8 | 2,267 | 2.59375 | 3 | [] | no_license | from selenium import webdriver
import time
from bs4 import BeautifulSoup
wd = webdriver.Chrome(r'D:\python_workspace\treform\selenium_server\chromedriver.exe')
#'''
url = 'https://www.goobne.co.kr/store/search_store.jsp'
wd.implicitly_wait(3)
wd.get(url)
select = wd.find_element_by_css_selector('#sSelsi > o... | true |
ab47f2d47570186c52012bf76d9403c7ee9909d1 | Python | birocoles/harmonica | /data/examples/south_africa_gravity.py | UTF-8 | 1,444 | 3.140625 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-public-domain"
] | permissive | """
Land Gravity Data from South Africa
===================================
Land gravity survey performed in January 1986 within the boundaries of the
Republic of South Africa. The data was made available by the `National Centers
for Environmental Information (NCEI) <https://www.ngdc.noaa.gov/>`__ (formerly
NGDC) and ... | true |
b2fd3ab08e875c27aa71b95d179be7ff82de4a6e | Python | lephuoccat/NLP | /hw09_evaluate.py | UTF-8 | 351 | 2.875 | 3 | [] | no_license | """Assignment 09: Word Features.
ECE 590: Natural Language Processing
Patrick Wang
"""
import nltk
from hw09_solution import related_words
def test_related():
word = 'play'
print(f'related to {word}: {related_words(word)}')
word = 'jury'
print(f'related to {word}: {related_words(word)}')
if __name... | true |
2713fd976ea4ccb858006e63e0af6e856acc4e8d | Python | the-code-experiments/get-to-know-python | /codes/session_1/string.py | UTF-8 | 1,337 | 4.21875 | 4 | [
"MIT"
] | permissive | # Open terminal > python3
# Start typing below commands and see the output
# Use single quote
'Ashwin'
'Ashwin\'s'
# Use double quote
"Ashwin's"
"Hello \"Ashwin\" "
name = 'Ashwin Hegde\nashwin.hegde3@gmail.com'
name # Without print() => \n has no effect
print(name) ## \n means new line
print('C:\python\name')
pr... | true |
de9a58d469825d4f4b7331611713be0f3d7ad003 | Python | Melek-C/Reproducible_tools_for_phylogeography_analysis_of_SARS-COV-2_data | /src/sliceFasta.py | UTF-8 | 1,172 | 2.671875 | 3 | [] | no_license | from Bio import SeqIO
import argparse
# usage
# sliceFasta.py --fasta sample.fasta --dataFile guide.txt --output myout.fasta
def walkOverCorrdinates(datafile):
with open(datafile) as input_coordinates:
lines=input_coordinates.readlines()
return lines
def parseseq(data_lines, input_fasta, outputfile): ... | true |
5caaea23d4f00c6ea894f9478c35fde4e35342d4 | Python | owenbob/yummy_recipes | /tests/test_recipe.py | UTF-8 | 608 | 3.1875 | 3 | [] | no_license | # third party import
import unittest
# local import
from object_oriented.recipe import Recipe
class RecipeTestCase(unittest.TestCase):
def setUp(self):
self.recipe_coffee = Recipe(title="africanCoffee", ingridient="water coffee", desc="pour water")
def test_title(self):
self.assertEqual(sel... | true |
9d1059079485374f5546842bc54e974335d258af | Python | HarshCasper/Rotten-Scripts | /Python/Color_Picker/Color_Picker.py | UTF-8 | 3,005 | 3.359375 | 3 | [
"MIT"
] | permissive | import cv2
import pandas as pd
import argparse
def get_argument():
"""
This function returns the arguement which was passed through the terminal.
"""
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True)
args = vars(ap.parse_args())
return args
def get_img():
... | true |
fd720511ef5842d9cdb344bee9d457ab34261a53 | Python | mgorkii-nlplogix/template | /main.py | UTF-8 | 1,067 | 2.53125 | 3 | [] | no_license | import argparse
import logging
import os
import resource
import sys
import timeit
from hurry.filesize import size
# setup the logger
logging.basicConfig(
stream=sys.stdout, level=logging.INFO, format="%(asctime)s : %(message)s"
)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
... | true |
d0d8709532cb0dba7525ae497048b2de594e2a96 | Python | tursunovJr/bmstu-python | /1 course/ЛР(доработки)/лр7защита.py | UTF-8 | 657 | 3.46875 | 3 | [] | no_license | m=int(input('количество строк/cтолбцов матрицы: '))
#n=int(input('количество столбцов матрицы: '))
x=[[0]*m for i in range(m)]
#print (x)
for i in range(m):
for j in range(m):
print ('Введите элемент матрицы: ')
x[i][j]=float(input())
for q in x:
print(q)
print()
for i in range(le... | true |
1119dc44d76dbd926aab38fae8afa7d33d199dfd | Python | hugosjoberg/Advent-of-Code-2017 | /Day-13.py | UTF-8 | 2,390 | 2.828125 | 3 | [] | no_license | import time
f = open('input_day13.txt','rt')
#f = open('test_day13.txt','rt')
firewall = []
for line in f:
line = list(map(str, line.split()))
line = list(map(lambda each:each.strip(":"), line))
line = list(map(int,line))
firewall.append(line)
scanner = [0]*(firewall[-1][0]+1)
scanner_movement = ['Down... | true |
151cf9d355fcace6bef0cacc15a359b3ffbe7ba9 | Python | dhruvsheth-ai/HapticCV | /test-a-buzz/buzz_a_buzz.py | UTF-8 | 1,749 | 2.6875 | 3 | [
"MIT"
] | permissive | import asyncio
from bleak import BleakClient
from bleak import discover
from neosensory_python import NeoDevice
def notification_handler(sender, data):
print("{0}: {1}".format(sender, data))
async def run(loop):
# "X" will get overwritten if a Buzz is found
buzz_addr = "X" # e.g. "EB:CA:85:38:19:1D"
... | true |
c2c3e4bc128b05d31ddddc51c43be1a54eb03bff | Python | kaz-yos/learning-to-program-with-python | /2014-06-01.advanced.py | UTF-8 | 3,606 | 4.0625 | 4 | [] | no_license | ### 2014-06-01 advanced
### Prepare libraries
import random
### Card class
class Card:
def __init__(self, value, suit):
self.value = value
self.suit = suit
def __str__(self):
if self.value == 14:
val = "Ace"
elif self.value == 13:
val = "King"
el... | true |
988fba32be83cbc312180c68a3757ffc874b7b61 | Python | HelloWorldIL/Binary-Tree | /binary_tree.py | UTF-8 | 215 | 2.859375 | 3 | [] | no_license | from tree import Tree
from random import randint
test = Tree()
test.add_value(6)
test.add_value(3)
test.add_value(7)
test.add_value(2)
test.add_value(1)
test.add_value(8)
test.to_string()
print(test.search_n(10)) | true |
cbd3d1c3e4dfa519e3cb4e3de83952a4684caf67 | Python | chufucun/dataflow-analysis | /python/src/grammar/day1/iterator_example3.py | UTF-8 | 1,708 | 4.25 | 4 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding:utf-8 -*
from collections.abc import Iterable, Iterator, Generator
# 扩展知识:
# 迭代器,是其内部实现了,__next__ 这个魔术方法。(Python3.x)
# 可以通过,dir()方法来查看是否有__next__来判断一个变量是否是迭代器的。
class MyList(object): # 定义可迭代对象类
def __init__(self, num):
self.end = num # 上边界
# 返回了一个实现了__iter__和__nex... | true |
e3778f6879d4fc0e0896f5535e2cd4ce696e3056 | Python | Roynecro97/pyheaders | /pyheaders/parsers/literals.py | UTF-8 | 1,889 | 2.703125 | 3 | [
"MIT"
] | permissive | '''
Parser for the ConstantsDumper magic string literals.
'''
import re
from typing import Dict, Optional, Text
from .constants import ConstantsParser
from ..parser import Context, ParserBase
from ..cpp import split as split_scope
from ..cpp.types import parse_value
class LiteralsParser(ParserBase):
'''
Pa... | true |
9980af77d87c3444982ac5b75315b323a9c2e9b9 | Python | SNURobotics/srbot | /menu.py | UTF-8 | 1,638 | 3.046875 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
import re
from collections import OrderedDict
def parse_snu_menu():
# 마지막 문자열은 식당 종류와 표시할 순서
# 참고: http://mini.snu.kr/cafe/pick/
# url = 'http://mini.snu.kr/cafe/today/kvdj'
url = 'http://mini.snu.kr/cafe/today/'
r = requests.get(url)
r.encoding = '... | true |
e99085d6983a1b4006e53ecf8f1154a8a5763260 | Python | rutvij1982/itp-w1-highest-number-cubed | /highest_number_cubed/main.py | UTF-8 | 539 | 3.265625 | 3 | [
"MIT"
] | permissive | """This is the entry point of the program."""
def highest_number_cubed(limit):
previous_number = 1
while True:
current_number = previous_number + 1
if current_number ** 3 > limit:
return previous_number
previous_number = current_number
... | true |
be9397745e16644bb5da7b3f6bcf57867f224ba8 | Python | maluarmini/Hand-detector-with-openCv2-and-pymunk | /hand-detector.py | UTF-8 | 2,689 | 2.78125 | 3 | [] | no_license | import pymunk
import cv2
import numpy as np
import mediapipe as mp
mp_hands = mp.solutions.hands
# Criando o espaço/mundo e definindo a gravidade para baixo
space = pymunk.Space()
space.gravity = 0, -300
# Definindo as bolas, seu formato e tamanho, e as adicionando no espaço
balls_radius = 12
balls = [(300 + np.rando... | true |
82372f73e4b69fd5b00a5e55ae5e8522f3c30cfa | Python | shaman-apprentice/SourceCodeExtractingRecipeIngredientsFromCookbooks | /ExtractingRecipeIngredientsFromCookbooks/informationExtraction/QuantityExtractor.py | UTF-8 | 1,443 | 3.515625 | 4 | [] | no_license | import unicodedata
#not really good cause of things like "ein Paar", "schüttet es durch ein Sieb"... -.-
quantityWords = {"einige":"einige", "etwas":"etwas",
"ein":"1", "eine":"1",
"zwei":"2",
"drei":"3",
"vier":"4",
"fünf":"5",
... | true |
d5fd71bf4e7a51bd31467b38e273035c7cd52b1d | Python | daniel-reich/ubiquitous-fiesta | /wBuZ2Qp9okzGeZc6e_14.py | UTF-8 | 215 | 3 | 3 | [] | no_license |
def first_place(road):
print(road)
try:
count = 1
while road[-count] == "=":
count += 1
print(count)
print(road[-count])
return road[-count]
except:
print(None)
return None
| true |
d71362e0899c8645b8a32a9a052543a17752fe94 | Python | garonzhang/my_genealogy | /src/load_members.py | UTF-8 | 2,253 | 2.9375 | 3 | [] | no_license | from dbmanager import DbManager
from member import Member
def load_members():
member_dict = {}
db_manager = DbManager()
cur = db_manager.conn.cursor()
cur.execute("SELECT member_id,\
member_name,\
descent_no,\
sex,\
... | true |
308c3e4ba56bc8eb0acbd7bad407c43ab1198374 | Python | alexander-mol/TransAmerica | /advanced_player.py | UTF-8 | 1,231 | 3.03125 | 3 | [] | no_license | from player import BasePlayer
class AdvancedPlayer(BasePlayer):
def decide_starting_node(self, game):
self.home_node = game.find_central_node(self.objectives)
self.update_target_order(game)
return self.home_node
class LeftPlayer(BasePlayer):
def decide_starting_node(self, game):
... | true |
124bb6a5b40884616e10d56f1ac76456e4ba9c25 | Python | yinlong312/python | /1.py | UTF-8 | 342 | 3.40625 | 3 | [] | no_license | print("请输入最近三天登录次数")
X = input()
print("请输入最近三天发微博数")
Y = input()
X = int(X)
Y = int(Y)
if X > 20 or Y > 10 :
print("非常活跃用户")
elif X >= 10 and X <= 20 or Y >= 5 and Y < 10 :
print("活跃用户")
elif X < 3 and Y <= 1 :
print("消极用户")
else :
print("普通用户") | true |
a10f9eb19c48310620f0545b64ca0c11643b75bb | Python | gpauloski/kfac-pytorch | /testing/models.py | UTF-8 | 2,061 | 3.21875 | 3 | [
"MIT"
] | permissive | """PyTorch Models for Testing.
Examples borrowed from:
https://pytorch.org/tutorials/beginner/introyt/modelsyt_tutorial.html
"""
from __future__ import annotations
import torch
from torch.nn import functional
class TinyModel(torch.nn.Module):
"""Tiny model with two linear layers."""
def __init__(self):
... | true |
85641ea8aa2ec4c4dec3264adf589a6119b03706 | Python | rsurapol/Python-Programming | /Unit-8/ex-8.21.py | UTF-8 | 346 | 3.75 | 4 | [] | no_license | i = 1
while i <= 5:
n = int(input("กรุณาป้อนคัวเลข 1-10 : "))
if n >= 11:
print ("คุณป้อนตัวเลขไม่ถูกต้อง !!")
continue
if n <= 10:
j = n * i
print ("ผลคูณระหว่าง %d x %d = " %(i, n), j)
i += 1 | true |
dfb8f9c2f1b387187707d11901041ae50dfda250 | Python | aws/aws-sam-cli | /samcli/lib/bootstrap/companion_stack/companion_stack_builder.py | UTF-8 | 3,615 | 2.78125 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"MIT",
"BSD-2-Clause"
] | permissive | """
Companion stack template builder
"""
from typing import Dict, cast
from samcli.lib.bootstrap.companion_stack.data_types import CompanionStack, ECRRepo
from samcli.lib.bootstrap.stack_builder import AbstractStackBuilder
class CompanionStackBuilder(AbstractStackBuilder):
"""
CFN template builder for th... | true |
4993041a941a37b9e7a9539d316a4c51eae9b152 | Python | kangli-bionic/leetcode-1 | /494.py | UTF-8 | 676 | 3.1875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# coding=utf-8
class Solution(object):
def findTargetSumWays(self, nums, S):
"""
:type nums: List[int]
:type S: int
:rtype: int
"""
numss = []
for v in nums:
if v: numss.append(v)
l = len(numss)
mask = sum(numss)... | true |
39829fc8df94cacf3a378276313d598a3c41fea7 | Python | syed-cbot/Fast_Segmentation | /history/debug6.py | UTF-8 | 99 | 2.671875 | 3 | [
"MIT"
] | permissive | import numpy as np
x = np.array([1, 2])
print(x.shape)
y = np.expand_dims(x, axis=0)
print(y.shape) | true |
bbbcdc6b4a2b4023a5614e95ceb8964d5c63885c | Python | Robock/project-compass | /check_profanity.py | UTF-8 | 466 | 2.84375 | 3 | [] | no_license | import urllib
def read_txt():
open_doc = open("C:\Users\Hank2\Documents\Jeep.txt")
reading = open_doc.read()
open_doc.close()
naughty_words(reading)
def naughty_words(text_to_check):
checkity = urllib.urlopen("http://www.wdylike.appspot.com/?q=" + text_to_check)
output =checkity.read()
checkity.close()
if "... | true |
b0eafc68f0fa2a87052d08c79f0b40922f0f5568 | Python | Prakashchater/Daily-Practice-questions | /Stack/Reverse Stack.py | UTF-8 | 683 | 3.9375 | 4 | [] | no_license | class Stack:
def __init__(self):
self.items=[]
def push(self,item):
return self.items.append(item)
def pop(self):
return self.items.pop()
def is_empty(self):
return self.items==[]
def peek(self):
if not self.is_empty():
return self.items[-1]
... | true |
a7daa2d35b52fd1ae8287ee7a02dd6278b93063f | Python | caioledesma/520 | /par.py | UTF-8 | 220 | 3.078125 | 3 | [] | no_license | #!/usr/bin/python3
from random import randint
numeros = [12, 56, 54, 21, 48, 513, 465, 84, 5469]
par = [x for x in numeros if x % 2 == 0]
#par = []
#for x in numeros:
# par.append(x)
print(par)
#print(randint(4))
| true |
7fc831b712ccca1a712e7c6b1113e4e6b27ed9a1 | Python | jackhhchan/watson-junior | /mongodb/mongodb_query.py | UTF-8 | 8,253 | 2.625 | 3 | [] | no_license | import sys
sys.path.append(sys.path[0] + "/..")
import os
from enum import Enum
import pymongo
from pymongo.errors import ConnectionFailure
import utils
"""
DATABASE INFO:
Database: 'wikiDatabase'
Collections:
'wiki' -- contains page_id (index), passage_idx, tokens
'InvertedIn... | true |
a3c0bbaed83f57e33c9fc1798a9f27ea62f5c156 | Python | Jeremy-Xin/Artificial-Intelligence-for-NLP | /lesson3/BeijingSubway/search.py | UTF-8 | 7,379 | 3.0625 | 3 | [] | no_license | import csv
import networkx as nx
import math
from functools import partial
stations = {}
lines = {}
graph = {}
intersects = {}
distances = {}
with open('stations.csv', newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
name, x, y = row
stations[name] = int(x)... | true |
be958867cd878394d1296f18822c25834094eb3c | Python | AbnerAA/Threensform-Cipher | /main.py | UTF-8 | 930 | 2.578125 | 3 | [] | no_license | import cipher
import threensform
import IO
import generator
import math
import time
block_length = 12
iterations = 12
def main():
encrypt = IO.request_mode()
if encrypt:
text = IO.request_plaintext()
else:
text = IO.request_ciphertext()
mode = IO.request_feistel_mode()
#coba buat mode ECB
external_key = ... | true |
0a8af4aab99aead745912896f9544a4a8a7e2e00 | Python | RHVH-QE/rhvh-playbooks | /library/mongo.py | UTF-8 | 2,528 | 2.5625 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
try:
import pymongo
except ImportError:
print('{"msg": "Error: pymongo is required", "failed": true}')
sys.exit(1)
from ansible.module_utils.basic import *
class Mongo:
def __init__(self, module):
self.module = module
self.host = m... | true |
21b7c2ea4d37eeffc991ce33fe45aa1a2707c8d5 | Python | xinbeiliu/coding-problems | /merge_meeting.py | UTF-8 | 1,157 | 4.09375 | 4 | [] | no_license | # a meeting is stored as tuple of int (start_time, end_time)
# these integers represent the number of 30-minute blocks past 9am
# (2,3) meeting from 10-10:30am
# (6,9) meeting from 12-1:30pm
# write a function merge_ranges() that takes a list of multiple meeting time
# ranges and return s a list of condensed ranges
# ... | true |
92d2f5cc4d58bcb1721f87aa6a3fc1effb2cd3c4 | Python | Taizul1579/Pythonbasic | /Multiplication_Of_Unknown_Number.py | UTF-8 | 201 | 3.71875 | 4 | [
"Apache-2.0"
] | permissive | # multiplication of unknown number
while True:
a = int(input("Enter The Multiplication Number:"))
i = 0
for i in range(0, 10):
i = i + 1
print(a, "*", i, "=", i * a)
| true |
549859036e0012e7bf64853bc6d426a0a5733d01 | Python | elbirk/ArcadeLED | /ArcadeLED/ArcadeLED.py | UTF-8 | 3,827 | 2.609375 | 3 | [] | no_license | import sys, getopt
from configparser import ConfigParser
import RPi.GPIO as LED
import os
# Adafruit NeoPixel libary
import board
import neopixel
# create an instance of ConfigParser class.
parser = ConfigParser()
# read and parse the configuration file.
parser.read(os.path.dirname(os.path.realpath(__file... | true |
74ad5be82cd908231679b9b3f27b04882a3ec267 | Python | ppkantorski/Astro_121 | /Lab_2/Code/1.4.2/dft.py | UTF-8 | 670 | 2.65625 | 3 | [] | no_license | import numpy as np
import pylab as py
def dft(filename,sampfreq):
data = np.load(filename)['arr_0']
N =len(data)
delt = 1./sampfreq
T = (N)*delt
E_nu = []
t = np.arange(-N/2,N/2,1)
nu = np.arange(-sampfreq/2,sampfreq*(1-2./N)/2,sampfreq/(N))
E_nu = []
for n in nu:
integr =... | true |
4f3287d19f57c3708bee5be73f661cb164ea0845 | Python | DreEleventh/python-3-object-oriented-programming | /ch07/timer_test_callbacks.py | UTF-8 | 1,823 | 4.09375 | 4 | [] | no_license | from timer import Timer
import datetime
def format_time(message, *args):
"""
Display a formatted time message with the current time followed by optional
positional arguments corresponding to replacement fields delimited by {} in
the message.
:param message: string containing replacement fields con... | true |
d93e189299a49c5a21aa66c52292cfeea1c6f35b | Python | alekssand/Project-Euler | /12.py | UTF-8 | 641 | 3.4375 | 3 | [] | no_license | import time
import math
def triangle_num(idx):
sum = 0
for i in range(idx + 1):
sum += i
return sum
def find_divisor(num):
count = 2
i = 2
while(num > i*i):
if num % i == 0:
count += 2
i += 1
if i*i == num:
count += 1
return cou... | true |
33a066ca3394b51b87a0583f7077963ff637f7c4 | Python | le-birb/advent-of-code_2020 | /day4.py | UTF-8 | 3,178 | 3.34375 | 3 | [] | no_license |
import re
passports = []
with open('day4-input', 'r') as f:
curr_passport = {}
for line in f:
if line.strip() == "":
# a passport has ended
passports.append(curr_passport)
curr_passport = {}
else:
entries = line.strip().split(' ')
fo... | true |
6db29ab3e89d9ae47d9cae5c8fde0a29f896dfd2 | Python | Kyudeci/EulerPythonPractice | /Large_Sum.py | UTF-8 | 432 | 4.3125 | 4 | [] | no_license | # Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.
from time import time
start = time()
with open("Fifty_Digit_Numbers.txt") as f:
number_file = f.read()
numbers = number_file.splitlines()
numbers = [int(number) for number in numbers]
sum_of_numbers = str(sum(numbers))
fir... | true |
55349f3eaf0ba524ff0c46055261bb2c76076fbd | Python | zukyspkt10117/Test | /server.py | UTF-8 | 2,726 | 2.59375 | 3 | [] | no_license | from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import parse_qs
from aiy.board import Board, Led
from aiy.leds import (Leds, Pattern, PrivacyLed, RgbLeds, Color)
from aiy.assistant.grpc import AssistantServiceClientWithLed
import cgi
import math
import time
import argparse
import locale
imp... | true |
1710dc28378bb70be38ff9dfb429f7a86dda4c46 | Python | mikekil/blockchain-ex | /discovery.py | UTF-8 | 1,449 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env python
'''
this module is used to detect the peer nodes in the subnet, and it trys to sent the heart beat package peer 10s (default config)
'''
import socket
from logger import *
from config import *
import time
class discovery():
def __init__(self,message,port):
self.message = message
... | true |
b2669a5393b27fb99a70bc0d836c695898ddb07f | Python | mukaddesau/HackerRankQuos | /FibonacciNumbersMemoization.py | UTF-8 | 1,970 | 4.34375 | 4 | [] | no_license | '''
File Name : FibonacciNumbersMemoization.py
Author : Mukaddes Altuntas
Created On : 05/12/2020
Version : Pyhton 3.7.4
Copyright (c) 2020 Mukaddes Altuntas. All rights reserved.
Description : This program finds the n'th fibonacci number using one of the dynamic programming
tecniques which is memoization.
... | true |
4d6bba3800255fd40210bb0e5a6ccbb57e6fc743 | Python | antjim/hack-the-box-challenges | /misDIRection.py | UTF-8 | 324 | 2.5625 | 3 | [] | no_license | #AORA
import sys
import os
import base64
key = range(37)
path = sys.argv[1]
folders = os.listdir(path)
for f in folders:
files = os.listdir(path+"/"+f)
for file in files:
key[int(file)] = str(f.split("-")[0])
encoded_key = (' '.join(str(x) for x in key)).replace(" ","")
print(base64.b64decode(encoded_key[1:]... | true |
2fc8fffa63958c61c72acf9f9f2283592a276401 | Python | cwallac/SoftDesFinalProject | /bbnode.py | UTF-8 | 951 | 3.09375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 17 03:25:57 2014
@author: dcelik
"""
import Tkinter as tk
class bbnode(tk.Button):
def __init__(self,frame,x,y):
self.xloc = x/30#self.xpixtoloc(x)
self.yloc = (y+22)/30
tk.Button.__init__(self,frame)
self.parent = frame
self.h... | true |
cbed2d0477b84a3a3b54ee7fd99a00fe84848ee6 | Python | Minniemu/2021-Python-Programming | /練習題2/4107056007_穆冠蓁_2.py | UTF-8 | 204 | 3.015625 | 3 | [
"MIT"
] | permissive | import pandas as pd
df = pd.read_csv("Titanic.csv")
df = df.replace({"Sex" : {"male":1, "female":0} })
print(df.corr())
corr_matrix = df.corr()
corr_matrix.style.background_gradient(cmap = 'coolwarm')
| true |
be50a4ec0d1c22bc86048e86280c42dd6e4c75e3 | Python | bitsreset/python | /google_python_class/cat_fnm.py | UTF-8 | 173 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | import sys
def Cat(filename):
f = open( filename , 'rU' )
lines = f.read()
print(lines)
f.close()
def main():
Cat( sys.argv[ 1 ] )
if __name__ == '__main__':
main() | true |
f825257e9aac41ec6909a3d0cac82c08ed99d176 | Python | fredrikhl/cryptopals-cryptochalls | /set2/13.py | UTF-8 | 1,293 | 2.546875 | 3 | [] | no_license | import base64
import binascii
import random
import os
from collections import OrderedDict
from Crypto.Cipher import AES
KEY = os.urandom(16)
def d(s):
return binascii.unhexlify(s)
def e(s):
return binascii.hexlify(s)
def pad(s, blocksize=16):
l = (blocksize - len(s) - 1) % blocksize + 1
return s + ... | true |
3d00fe0c7297cb5845f51a6bc85da997eb78c08c | Python | XIII-UP/news | /news/common/redisdb.py | UTF-8 | 1,496 | 2.78125 | 3 | [] | no_license | # -*- coding:UTF-8 -*-
import redis
# Jon!Q@W#E
class redisdb(object):
def __init__(self,host='localhost', port=6379, db=1, password = None):
self.pool = redis.ConnectionPool(host=host, port=port, db=db, password=password)
self.Redis = redis.Redis(connection_pool=self.pool)
# push a new link ... | true |
b130f31d982d7499d498ac8643a66ce8a3ea2d88 | Python | PMForest/Lesson_5 | /task_5.4.py | UTF-8 | 1,564 | 3.40625 | 3 | [] | no_license | """Создать (не программно) текстовый файл со следующим содержимым:
One — 1
Two — 2
Three — 3
Four — 4
Необходимо написать программу, открывающую файл на чтение и считывающую построчно данные.
При этом английские числительные должны заменяться на русские. Новый блок строк должен записываться
... | true |
a927e55313c6d6889797c0f6dc1271614eeb1748 | Python | lubeme/erdosControl | /netGrowControl.py | UTF-8 | 964 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import digraph
import matchings
import random
__author__ = 'Luis Úbeda (http://www.github.com/lubeme)'
def net_grow_control(n):
#init
G = digraph.DiGraph()
G.add_nodes(range(1, n + 1))
posibleEdges = {}
keyAux = 0
for node1 in xrange(1, n+1):
... | true |
ce32fabc68601fdc17a8a83360edd15471aaa403 | Python | gusario/intellectualAgents | /src/plot_results.py | UTF-8 | 1,534 | 2.96875 | 3 | [] | no_license | import matplotlib.pyplot as plt
import pandas as pd
from os import listdir
from os.path import isfile, join
import argparse
import numpy as np
def extract_data(files):
res = []
for file in files:
df = pd.read_csv(file).iloc[:,0]
df = df.apply(lambda x: x[1: -1]).to_numpy().astype(float)
... | true |
dcc664c00458bc678b71390fd3c6b7d9431e3952 | Python | alexandraback/datacollection | /solutions_5644738749267968_0/Python/mth/D.py | UTF-8 | 3,097 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env python
FILE_NAME_BASE = 'D-small-attempt0'
NUM_PROCESSES = 0
MEM_LIMIT_GB = 1.5 # per worker process
RECURSION_LIMIT = 1000
from itertools import chain
def parse(inp):
numBlocks, = (int(x) for x in inp.readline().split())
naomiBlocks = tuple(sorted(float(x) for x in inp.readline().split()))
kenBloc... | true |
7ab68e5b56efd979d707691b65e4327b93419be0 | Python | Matt-F90/python-core | /my_even.py | UTF-8 | 1,006 | 3.78125 | 4 | [] | no_license | some_list = [2 ,7 ,9 ,8 ,88 ,90 , 91,]
one_list = []
def even_number_of_evens(my_list, even_numbers):
for number in my_list:
if number % 2 == 0:
even_numbers.append(number)
length = len(even_numbers)
if not length % 2 == 0:
print("this is not an even number of evens")
... | true |
2f06cd4edc04ec21305a4fc533af55328d938165 | Python | DoctorSad/_Course | /Lesson_07/_0_lists_3.py | UTF-8 | 851 | 4.34375 | 4 | [] | no_license | """
Сортировка, реверс, max/min.
"""
def main():
numbers = [8, 6, -12, 21, 32, -5, 7, 16]
# Минимальное и максимальное значение списка с помощью min() и max()
print("min =", min(numbers))
print("max =", max(numbers))
# Сумма чисел списка
print("sum =", sum(numbers))
words = ["g", "s... | true |