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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0ba04732a57f637047dcb0dded281d89a32dd15a | Python | Adurden/group_roll_table_bot | /src/roll_funcs.py | UTF-8 | 3,783 | 3.3125 | 3 | [
"MIT"
] | permissive | import numpy as np
def roll(num, face, mod=0):
"""
a wrapper around numpy randint for generating a set dice rolls
Parameters
----------
num : int
the number of dice inteded to be rolled
face : int
the number of faces on the dice being rolled
mod : int
a modifier to... | true |
d7355f5ef9db8a3e1da769b2b634693b80937e93 | Python | aamuru/python_practice | /Number_of_Islands/Number_of_Islands.py | UTF-8 | 1,693 | 3.203125 | 3 | [] | no_license | class Solution:
'''def dfs(self,grid,i,j):
if(i<0 or j<0 or i>=len(grid) or j>=len(grid[0]) or grid[i][j]=='0'):
return
grid[i][j]='0'
self.dfs(grid,i+1,j)
self.dfs(grid,i-1,j)
self.dfs(grid,i,j-1)
self.dfs(grid,i,j+1)
def numIsla... | true |
a4a8d9f0a8bb803c9cd1ca8deee2c36cd1f049f0 | Python | davsvijayakumar/python-programming | /player/number reversed.py | UTF-8 | 72 | 2.921875 | 3 | [] | no_license | a=str(input("enter the number"))
print("\n",''.join(list(reversed(a))))
| true |
6f6ef094d8bbef50e69dbb7f008beeeae5c5ff84 | Python | kemingy/daily-coding-problem | /src/2d_iterator.py | UTF-8 | 1,311 | 4.5 | 4 | [
"Unlicense"
] | permissive | # Implement a 2D iterator class. It will be initialized with an array of arrays,
# and should implement the following methods:
# • next(): returns the next element in the array of arrays. If there are no
# more elements, raise an exception.
# • has_next(): returns whether or not the iterator still has e... | true |
7a4f145787e09eeece4209e408cc0cb5fa942589 | Python | rbrandao22/susep | /models2.py | UTF-8 | 38,293 | 2.5625 | 3 | [] | no_license | #########################################################################
## Regression models of counts and claims data for auto insurance cost ##
#########################################################################
import os
import sys
import pickle
import shelve
import numpy as np
import scipy.special as sp
im... | true |
9a4f99ead700621ca0b7636bb6682bae4fd50b47 | Python | szhyuling/aha-algorithm-python | /Chapter_1/xiaohengmaishu.py | UTF-8 | 1,662 | 3.65625 | 4 | [] | no_license | import numpy as np
from bubble_sort import bubble_sort
from quick_sort import quick_sort
#去重+排序问题
#解法一:先去重,后排序(桶排序)
#解法二:先排序,后去重(常规排序算法)
def bucket_uniquesort(m, nums, sort="ascend"):
assert(sort=="ascend" or sort=="descend")
book = np.zeros((m,), dtype=int)
n=len(nums)
for i in range(... | true |
83b0a3332b1ce9a465f7a835471f9a217f1c107f | Python | Egogorka/gameplatformer | /src/utility/Eventer.py | UTF-8 | 421 | 2.65625 | 3 | [] | no_license | from src.utility.EventListener import EventListener
class Eventer:
def __init__(self):
self._observers = []
def addListener(self, inObserver : EventListener):
self._observers.append(inObserver)
def removeListener(self, inObserver : EventListener):
self._observers.remove(inObserve... | true |
8bf14969f0aa9a66725469f2381ed1eb4aba702f | Python | Zedmor/hackerrank-puzzles | /leetcode/4.py | UTF-8 | 891 | 3.921875 | 4 | [] | no_license | """
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
Example 1:
nums1 = [1, 3]
nums2 = [2]
The median is 2.0
Example 2:
nums1 = [1, 2]
nums2 = [3, 4]
The median is (2 + 3)/2 = 2.5
Subscribe to ... | true |
26dc6d3fb834cda18c6dfc6610266f042d8c0548 | Python | assen0817/bfindex | /File.py | UTF-8 | 3,701 | 3.078125 | 3 | [] | no_license | from BloomFilte import bfindex
# ブルームフィルターのビット列
m=64
# 登録可能キーワード数
k=3
# ファイルへの書き込み
# ファイル名、データ内容、日付
def write(file_name, data, date):
# バイナリ登録用のファイル名と名前が被らないように避ける
if file_name == 'binary_data':
print('ファイル名を変えてください')
return 'ファイル名を変えてください'
# ファイル名がぶつからないように存在していたらエラーを取得
# ファイルが存在する... | true |
eaf2c68e78298c0f702f0672633783c848ef781a | Python | dandyvica/articles | /python_lists/a6.py | UTF-8 | 273 | 2.5625 | 3 | [] | no_license | phrase = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
# convert each character to its ASCII representation
converted_phrase = [ord(x) for x in phrase]
# now compute sdbm hash
sdbm = reduce() | true |
4c4994ad8636d74511edf7d4963fc14e893aafc8 | Python | mfitton/Wordpress-Grabber | /blogclass.py | UTF-8 | 552 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env python
# encoding: utf-8
"""
WordpressGrab
Created by Max Fitton on 2012-12-16.
Copyright (c) 2012 __MyCompanyName__. All rights reserved.
"""
#in loc tags
import sys
from bs4 import BeautifulSoup
def get_list_of_posts(xml_file):
list_of_posts = []
sitemap = open(xml_file)
soup = BeautifulSoup... | true |
1357968fc2ced3c602c26064166ba746488e1520 | Python | oddeirikigland/tdt4171 | /classifiers/sklearn_classifier.py | UTF-8 | 1,905 | 3.0625 | 3 | [] | no_license | import os
import pickle
from sklearn import feature_extraction, naive_bayes, tree, metrics
def transform_input_data(input_training, input_test):
vectorized = feature_extraction.text.HashingVectorizer(
stop_words="english", binary=True
) # n_features
return (
vectorized.fit_transform(input... | true |
0747534c10b9bddb5b524bf7608bdfd9c7ae3b27 | Python | lijikai1206/Pycharm_Projects01 | /PythonFile/10_MySqlTest/demosql/demo_sql02_CreatTable.py | UTF-8 | 463 | 2.703125 | 3 | [] | no_license | import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="ljk1103",
database="runoob"
)
mycursor = mydb.cursor()
#创建数据表
mycursor.execute("CREATE TABLE Websites (id VARCHAR(255), "
"name VARCHAR(255), url VARCHAR(255),alexa VARCHAR(255),"
... | true |
eb511cfd9fee2787ef8572fa5e2391da991aa5cf | Python | DankGroundhog/PyMarlin | /pymarlin/core/module_interface.py | UTF-8 | 8,497 | 2.984375 | 3 | [
"MIT"
] | permissive | """
Module Interface module:
This module contains the abstract classes CallbackInterface and
ModuleInterface that can provide everything necessary for model
training. Users should implement these abstract classes in their
Scenarios.
"""
from abc import ABC, abstractmethod
import enum
from typing import Iterable, Tuple... | true |
488a0a3bd5c4e52f98a4bc5fee28687e68fd3d65 | Python | sofide/apicolapp | /accounting/manage_data.py | UTF-8 | 3,602 | 2.890625 | 3 | [] | no_license | """
Manipulate accounting data to be used in views.
"""
from collections import defaultdict
import datetime
from django.db.models import Q, Sum, Count
from django.db.models.functions import Coalesce
from django.utils.text import slugify
from accounting.models import Category, Product, Purchase
def purchases_by_cate... | true |
afc052a5cfd58e0edbd8f5cbc15c79424f958638 | Python | arunpsg/unscramble_python | /Task2.py | UTF-8 | 1,197 | 3.9375 | 4 | [] | no_license | """
Read file into texts and calls.
It's ok if you don't understand how to read files
"""
import csv
phone_duration = {}
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
for call in calls:
... | true |
dca6cc043fabe096b5084136e3cf12b1e74a8c35 | Python | jchernjr/code | /advent2021/day3.py | UTF-8 | 1,552 | 3.8125 | 4 | [] | no_license | from typing import List, Dict
def get_all_ith_chars(strings: List[str], i: int) -> List[str]:
"""Get the ith char of all input strings, and return them as a list"""
return [s[i] for s in strings]
def count_chars(chars: List[str]) -> Dict[str, int]:
counts = {}
for c in chars:
if c not in cou... | true |
48b93a12601c712db7f59101fed60db81c73d07c | Python | coolkevinc/CSIT-230-Final-Project | /Not_Gate.py | UTF-8 | 512 | 3.765625 | 4 | [] | no_license | ##Created by Kevin Chau
##interface class for the NOT gate
def NOT(a): ##defines the NOT Gate
if(a == True):
return int(False)
else:
return int(True)
def NOTrunner():
#defines the method that will simulate the NOT Gate
##inverts the user input (1 or 0)
##run NOTrunner.py fo... | true |
541d164b300d40d1e7ac0fdbe29ff234e198a998 | Python | likr/egraph-rs | /crates/python/examples/stress_majorization.py | UTF-8 | 878 | 2.921875 | 3 | [
"MIT"
] | permissive | import networkx as nx
from egraph import Graph, Coordinates, StressMajorization, stress, warshall_floyd
import matplotlib.pyplot as plt
def main():
nx_graph = nx.les_miserables_graph()
graph = Graph()
indices = {}
for u in nx_graph.nodes:
indices[u] = graph.add_node(u)
for u, v in nx_graph... | true |
b0c24221fa58866d322bb250490896333d8743e9 | Python | angrycaptain19/logtree | /render.py | UTF-8 | 3,504 | 2.75 | 3 | [] | no_license | #!/usr/bin/env python3
import matplotlib
matplotlib.use('SVG')
import matplotlib.pyplot as plt
import networkx as nx
import string
import random
import itertools as it
import sys
from logtree import LogTree
def render(tree, output):
# create graph
G = nx.DiGraph()
heights = {}
column_labels = {}
... | true |
38b44b172f4905b657bdbb19207e4237623b0a8c | Python | RT-Thread/mpy-snippets | /examples/03.board/1.stm32l4_pandora/pin_num.py | UTF-8 | 775 | 3.015625 | 3 | [] | no_license | #
# Copyright (c) 2006-2019, RT-Thread Development Team
#
# SPDX-License-Identifier: MIT License
#
# Change Logs:
# Date Author Notes
# 2019-06-28 SummerGift first version
#
def pin_num(pin_index):
"""
Get the GPIO pin number through the GPIO index, format must be "P + <A~K> + number", su... | true |
051ea84461366fe711fb38c978c4bea4f316a81b | Python | se210/tracy | /src/common/Library.py | UTF-8 | 13,033 | 2.890625 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2011 Nokia
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribu... | true |
af1d0e3cf48bf37997c8497eaa43cd7935ef014f | Python | Shaligram/spworks | /multi/echoclient.py | UTF-8 | 1,403 | 2.53125 | 3 | [] | no_license | import socket
import IN
import sys
import time
import timeit
i = 1
while i < 2:
i += 1
# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((sys.argv[1], 0))
server_address = (sys.argv[2], int(sys.ar... | true |
226f3e379753a10f663aecf1b044582cef2008dc | Python | j-bennet/cracking | /2.0_linked_list_basics.py | UTF-8 | 208 | 3.234375 | 3 | [] | no_license | from linked_list import Node, LinkedList
ll = LinkedList(range(1, 11))
to_remove = [2, 1, 8]
print 'Original:'
ll.output()
for i in to_remove:
print 'Removed ' + str(i) + ':'
ll.remove(i)
ll.output()
| true |
7eb11421abdd7c23a78638749b0139cd3a0a3098 | Python | MiltonCastilloG/gplsiScrapper | /director.py | UTF-8 | 1,244 | 2.78125 | 3 | [] | no_license | from scrapper import simple_get
from questions_parser import *
from questions_xml_generator import *
from regex_repository import *
def generate_questionary_xml(url, correct_answers_path):
content = get_page(url)
parsed_content = parse_questions(content, get_answer_list(correct_answers_path))
file_content ... | true |
382412168366888ff9f5bd07612c454b6ca34ab5 | Python | numberonewastefellow/projects | /small_ds/readingFileinChunks.py | UTF-8 | 1,063 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | #https://stackoverflow.com/questions/7167008/efficiently-finding-the-last-line-in-a-text-file
def last_line(in_file, block_size=1024, ignore_ending_newline=False):
suffix = ""
in_file.seek(0, os.SEEK_END)
in_file_length = in_file.tell()
seek_offset = 0
while(-seek_offset < in_file_length):
... | true |
c854056dfd38217063d2bf623fdd73c4b137e20e | Python | DenSinH/AdventOfCode2019 | /day10/day10.py | UTF-8 | 2,133 | 2.953125 | 3 | [] | no_license | from math import gcd, atan2, pi
def see(pos, asteroids):
if asteroids[pos[1]][pos[0]] != "#":
return 0
for dy in range(-pos[1], len(asteroids) - pos[1]):
for dx in range(-pos[0], len(asteroids[0]) - pos[0]):
if gcd(dx, dy) != 1:
continue
yield ... | true |
4cd1989b2772d4315e99f3e01bd820ad29aac62c | Python | shahnawaz-pabon/Python-with-HackerRank | /Problems' Solution/SwapCase.py | UTF-8 | 98 | 2.78125 | 3 | [] | no_license | if __name__ == '__main__':
inp = str(input())
inp = inp.swapcase()
print(inp) | true |
66b69240e0fa6403a09a31399891c83422a48faa | Python | comtihon/catcher_modules | /test/resources/airflow_hello_world.py | UTF-8 | 596 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | from datetime import datetime
from airflow import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator
def print_hello():
return 'Hello world!'
dag = DAG('hello_world',
description='Simple tutorial DAG',
schedule_interval... | true |
39fcd5cd53b58f9677425c8a2e6928eed6df17b8 | Python | jskim062/calculator | /01_calc/hello.py | UTF-8 | 507 | 3.1875 | 3 | [] | no_license | from tkinter import *
from tkinter import ttk
from tkinter import messagebox
win = Tk ()
win.title("Raspberry Pi UI")
win.geometry('200x100+200+200')
def clickMe():
messagebox.showinfo("Button Clicked", str.get())
str = StringVar()
textbox = ttk.Entry(win, width=20, textvariable=str)
textbox.grid(column = 0 , r... | true |
3be902cd18f2040e826748c2a00e62d845865861 | Python | ufwt/dizzy | /dizzy/tests/test_dizzy.py | UTF-8 | 15,984 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | # test_dizz.py
#
# Copyright 2017 Daniel Mende <mail@c0decafe.de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the... | true |
6d559f4940104ebd5278eadab9cb5b2b7c265032 | Python | buddydeepansh/LEtsUpgrade_Python_Batch7 | /Day8.py | UTF-8 | 704 | 4.1875 | 4 | [] | no_license | # decorator wala program
def outer_decorator_function(fun):
print("We are inside Outer decorator function.")
a = int(input("Enter a range"))
def inner_decorated_function():
print("Inside decotrated function")
fun(a)
return inner_decorated_function()
def fibbo(n):
a... | true |
3db94d6b496679b10b732fbd57f535cefc552b97 | Python | abretaud/galaxy | /lib/galaxy/tools/toolbox/lineages/stock.py | UTF-8 | 1,632 | 2.703125 | 3 | [
"CC-BY-2.5",
"AFL-2.1",
"AFL-3.0",
"CC-BY-3.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import threading
from distutils.version import LooseVersion
from .interface import ToolLineage
from .interface import ToolLineageVersion
class StockLineage(ToolLineage):
""" Simple tool's loaded directly from file system with lineage
determined solely by distutil's LooseVersion naming scheme.
"""
li... | true |
f9493469e4abad8ed0416cbb01905121a48e07e1 | Python | DarkShadow4/Python | /clase/python/str6.py | UTF-8 | 107 | 3.453125 | 3 | [
"MIT"
] | permissive | palabra = raw_input("Introduce palabra:")
if palabra == palabra[::-1]:
print "si"
else:
print "no"
| true |
c88b9c9f7f268dcc6c22fa02034d704793ad3382 | Python | hiddeagema/programming | /les06/opdracht6_1.py | UTF-8 | 64 | 3.109375 | 3 | [] | no_license | s = '0123456789'
print(s[2:5])
print(s[7:9])
print(s[1:8])
| true |
1a4f93587ea18a6809d0d075673863c9bd86f905 | Python | walkccc/LeetCode | /solutions/1153. String Transforms Into Another String/1153.py | UTF-8 | 435 | 3.15625 | 3 | [
"MIT"
] | permissive | class Solution:
def canConvert(self, str1: str, str2: str) -> bool:
if str1 == str2:
return True
mappings = {}
# No char in str1 can be mapped to > 1 char in str2
for a, b in zip(str1, str2):
if mappings.get(a, b) != b:
return False
mappings[a] = b
# No char in str1 ma... | true |
456c908cfbaa76d1d78b4804df4c28a5effd015a | Python | houxudong1997/compuational_physics_N2015301020064 | /random1.py | UTF-8 | 845 | 3.53125 | 4 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 22 16:24:12 2017
@author: Houxudong
"""
import random
import turtle
wn=turtle.Screen()
turtle.screensize(2000,2000)
wn.title("Random walk: 2D")
wn.bgcolor('white')
tess=turtle.Turtle()
tess.shape('classic')
tess.color('black')
tess.pensize(1)
for i ... | true |
f727bcf62e5a0eea51983e40b1f0f086001b399c | Python | YZJ6GitHub/PyTorch_Learing | /torch_save_model.py | UTF-8 | 1,910 | 3.015625 | 3 | [] | no_license | import torch
import matplotlib.pyplot as plt
from torch.autograd import Variable
import torch.nn.functional as F
x = torch.unsqueeze(torch.linspace(-1,1,100),dim=1)
y = x.pow(2) + 0.2*torch.rand(x.size())
def save():
net = torch.nn.Sequential(
torch.nn.Linear(1,10),
torch.nn.ReLU(),
... | true |
c5ba8f1e39a86eff16f48d375802942102c7c96c | Python | ErikBuchholz/kidsMathQuiz | /kidsMathQuiz/user_interface.py | UTF-8 | 1,626 | 3.703125 | 4 | [] | no_license | #
#
#
#
#
#
#
def display_dialogue(prob_text, question_num):
print("\n")
display_problem(prob_text, question_num)
user_answer = get_answer()
return user_answer
#
#
#
#
#
def display_problem(prob_text, question_num):
print("Question #%d: %s" % (question_num, prob_text))
#
#
#
#
#
def get_answer():... | true |
1eb1a20cca4e64744c3c860ba9ffc78209de8c23 | Python | wsgan001/PyFPattern | /Data Set/bug-fixing-4/3339d802402fd2f2ed5e954434c637bf7a68124d-<_make_validation_split>-bug.py | UTF-8 | 1,278 | 2.796875 | 3 | [] | no_license | def _make_validation_split(self, y):
'Split the dataset between training set and validation set.\n\n Parameters\n ----------\n y : array, shape (n_samples, )\n Target values.\n\n Returns\n -------\n validation_mask : array, shape (n_samples, )\n Equal ... | true |
a5b8c461e1dd874f60e1eba9c190373c9912502a | Python | JaeZheng/unet | /test.py | UTF-8 | 688 | 2.796875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : JaeZheng
# @Time : 2019/10/22 21:04
# @File : test.py
import cv2
import numpy as np
def iou(y_true, y_pred):
y_true_mask = (y_true == 255)
y_pred_mask = (y_pred == 255)
iou = np.sum(y_true_mask & y_pred_mask) / np.sum(y_true_mask | y_pred_m... | true |
8ae00e9e0eebba0416a945744452756c1ac7cde2 | Python | jlas/misc | /store_credit/test_store_credit.py | UTF-8 | 594 | 2.9375 | 3 | [] | no_license | import store_credit as sc
def test_it():
global ref_list
for credit, L, ans in [
(100, [5, 75, 25], [1, 2]),
(200, [150, 24, 79, 50, 88, 345, 3], [0, 3]),
(8, [2, 1, 9, 4, 4, 56, 90, 3], [3, 4]),
(32, [1, 1, 1, 1, 32, 2, 2, 2], [4]),
(42, [3, 8, 12, 80, 18, 12], [2, 4, 5... | true |
7785a28a266567fd68a666969feab65cceeaadac | Python | cgnarendiran/bandit_problem | /bandit.py | UTF-8 | 4,349 | 3.4375 | 3 | [] | no_license | """
Bandit Algorithms defined.
"""
import numpy as np
class Bandit:
def __init__(self, n_arms, arm_option = 1):
# No. of arms
self.k = n_arms
# State Mean values:
# self.q = np.random.random((self.k,))*10.0
# self.q = [1.5,1.5,9.5,1.5,1.5]
self.q = [4.0,4.5,5.0,5.5,6.0]
# State
def pull(self, arm... | true |
50e0dd0a6f8877bc14fd58a463ef6e7c00b9bde3 | Python | uccser/cs-field-guide | /csfieldguide/tests/test_repository.py | UTF-8 | 1,849 | 2.578125 | 3 | [
"CC-BY-NC-SA-4.0",
"BSD-3-Clause",
"CC0-1.0",
"ISC",
"Unlicense",
"LicenseRef-scancode-secret-labs-2011",
"WTFPL",
"Apache-2.0",
"LGPL-3.0-only",
"MIT",
"CC-BY-SA-4.0",
"LicenseRef-scancode-public-domain",
"CC-BY-NC-2.5",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-unknown... | permissive | """Test class for other respository tests."""
import os.path
import yaml
import glob
from django.test import SimpleTestCase
class RepositoryTests(SimpleTestCase):
"""Test class for tests for other areas of the project repository."""
def test_node_modules_setup(self):
"""Check if all 'package.json' f... | true |
b81a3a2fed4d308f722b17348a0b1198101d75b3 | Python | xeeeion/Python_unI | /Pr2/Pr_2/11.1. Розенкранц и Гильденстерн меняют профессию.py | UTF-8 | 221 | 3.140625 | 3 | [] | no_license | string = input()
i = 0
k = 0
mx = 0
for n in string:
if n == 'о' and k == 0:
i += 1
elif n == 'о' and k != 0:
i = 1
k = 0
else:
k = 1
if i > mx:
mx = i
print(mx)
| true |
2e799b523aa2cb694c5084e6f041920c88dd70fe | Python | MStaniek/ECL | /Perzeptron/Perzeptron.py | UTF-8 | 835 | 3.390625 | 3 | [] | no_license | import math
class Perceptron:
def __init__(self, dimensionen):
self.weightvector=[0]*dimensionen
def update(self, test):
sum=0
for a,b in enumerate(self.weightvector):
sum+=b*test[a]
result=sum*test[-1]
if result <= 0:
for a,b in enumerate(self.we... | true |
a8353dfed9b1964e52f4b8b9637d400969da798c | Python | pavit939/A-December-of-Algorithms | /December-15/pascal.py | UTF-8 | 571 | 3.359375 | 3 | [] | no_license | def pascal(n):
l1 = []
for line in range(0,n):
for i in range(0,line + 1):
l1.append(coeffbi(line,i))
a = len(l1)
a = a-n
while(a < len(l1)):
j = 0
for i in range(n-1,-1,-1):
print(l1[a],"x^",i,"y^",j)
a = a + 1
j = j + 1
def co... | true |
6f912f266609e25f26a33f675a1fd61e3d9bd30c | Python | DIEE-ISDe-code/design_pattern | /observer/observer3.py | UTF-8 | 2,088 | 3.796875 | 4 | [] | no_license |
# observer3.py (Python 3)
# The Observer
class Subscriber:
def __init__(self, name):
self.name = name
def update(self, message):
print( self.name,' received the message ', message)
# The Observable
class Publisher:
def __init__(self, events):
# The constructor accepts in input a ... | true |
d0b6aba8643a851750c80647b164b34431c7ed9d | Python | ShangHung0314/sc-projects | /stanCode_Projects/hangman_game/Substitution_Cipher_ext.py | UTF-8 | 3,568 | 4.46875 | 4 | [
"MIT"
] | permissive | """
File: Substitution_Cipher_ext.py
Name: Cage
-----------------------------
This program use the concept of substitution cipher.
I use the secret code to form a set of alphabet sequence.
For example, if my SECRET is 'HELLO WORLD'.
The new set of sequence will be 'HELOWRDABCFGHIJKMNPQSTUVWXYZ', deleting the spa... | true |
05ae9ba97a714251b53c5c1431ea1f6adf186fcb | Python | ati-ozgur/course-python | /2020/examples-in-class-2020-11-05/answer_to_question05.py | UTF-8 | 81 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | def multiple_outputs(a,b):
return a*b,a+b, a-b
print(multiple_outputs(5,4))
| true |
da7c9c722a82bba77ee56e1410a5b10661b99201 | Python | SenadI/tea | /tea/console/utils.py | UTF-8 | 1,367 | 2.984375 | 3 | [] | no_license | __author__ = 'Viktor Kerkez <alefnula@gmail.com>'
__date__ = '20 October 2010'
__copyright__ = 'Copyright (c) 2010 Viktor Kerkez'
import os
from tea.system import platform
if platform.is_a(platform.WINDOWS | platform.DOTNET):
import msvcrt
def _clear_screen(numlines):
os.system('cls')
... | true |
1ea324f90f564e108fb5a3c147a0332427061edb | Python | Mitrou/rep-one | /_lrn/old_stuff/new_hope/int1.py | UTF-8 | 525 | 3.140625 | 3 | [] | no_license | # def extendList(val, list=[]):
# list.append(val)
# return list
#
# list1 = extendList(10)
# list2 = extendList(123,[])
# list3 = extendList('a')
#
# print "list1 = %s" % list1
# print "list2 = %s" % list2
# print "list3 = %s" % list3
#
# print list1
def extendList(val, list=[]):
if len(list) != 0:
... | true |
5504cabb82b8bda2b4055262db18192be34a3d7b | Python | inchiyoung/Listeria_ISGylome | /script/Parse_RSA.py | UTF-8 | 1,236 | 2.515625 | 3 | [] | no_license | #!/usr/bin/python
import os
import sys
import glob
import numpy as np
from collections import defaultdict
def reading_RSA(infile_RSA):
infile = open(infile_RSA,'r')
RSA_dict = defaultdict(list)
for line in infile.xreadlines():
if 'UniProt_ID' in line: continue
line = line.rstrip().rsplit("\t")
RSA_di... | true |
5424e3dd9a1448b009bf9044c3d522b9bb44414c | Python | SergeiBondarev/B_test | /Less-4.1_home.py | UTF-8 | 1,668 | 2.78125 | 3 | [] | no_license | # Home: добавление комментария (94)
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("user-data-dir=C:\\profile")
driver = webdriver.Chrome(chrome_options=options)
driver.maximize_window()
driver.get("https://google.com")
time.sle... | true |
b91d0f8e6da7ba7ea376f42e7d45c84bc393a871 | Python | 3enoit3/tools | /vimrc/parse_vimrc.py | UTF-8 | 6,798 | 2.703125 | 3 | [] | no_license |
import sys
import re
# Parser
class sourceLineIter:
def __init__(self, iLines):
self._lines = iLines
self._lineCount = len(iLines)
self._currLineNb = 1
self._previousLine = ''
self._blockDepth = 0
self._blockEnds = None
# Iteration
def get(self):
... | true |
a3d8ba69e835adfa1f34599b53ebb1b5016b530a | Python | mjiana/python | /pythonProject/py001-023/py007.py | UTF-8 | 217 | 3.609375 | 4 | [] | no_license | # 도전
# 반복문을 이용하여 정삼각형과 정사각형 그리기
import turtle as t
for x in range(3):
t.forward(100)
t.left(120)
for x in range(4):
t.forward(200)
t.left(90)
| true |
39d8dec52c343129e1cc772ba7dc0c0bb4f4cfab | Python | jb55/cloudvibe-client | /src/cloudvibe/gui.py | UTF-8 | 1,342 | 2.9375 | 3 | [] | no_license | import sys
class Tray():
""" The Cloudvibe tray """
def __init__(self):
self.handlers = {}
def on(self, event, fn):
"""
Register event handlers
Events:
- sync
"""
if event in self.handlers:
self.handlers[event].append(fn)
else:
self.handlers[event] ... | true |
7f7a74a77e213e0427e79ecc42f4de403aeb6382 | Python | andrewsris/preProcessing | /Normalize.py | UTF-8 | 3,032 | 2.65625 | 3 | [
"MIT"
] | permissive | """
@author: Narmin Ghaffari Laleh <narminghaffari23@gmail.com> - Nov 2020
"""
##############################################################################
from multiprocessing.dummy import Pool as ThreadPool
import stainNorm_Macenko
import multiprocessing
import os
import cv2
import numpy as np
global... | true |
abf1e1bece917d607b76eeaeaf364be77d9fbd12 | Python | Aasthaengg/IBMdataset | /Python_codes/p03241/s345879830.py | UTF-8 | 244 | 2.890625 | 3 | [] | no_license | n, m = map(int, input().split())
result = 1
for i in range(int(m**0.5), 0, -1):
if m % i == 0:
j = m // i
if i >= n:
result = max(result, j)
elif j >= n:
result = max(result, i)
print(result)
| true |
4f8c0119910d26b2f480a4588373de728a5967d4 | Python | SpenceGuo/py3-learning | /coding/Fibobacci.py | UTF-8 | 85 | 3.234375 | 3 | [
"Apache-2.0"
] | permissive | a, b = 0, 1
while b <= 10000:
print(b, end=",")
m = b
b = a+b
a = m
| true |
4515818d3b81c85a20ed4c9e433aa0ecb5a3403d | Python | x95102003/leetcode | /binary_tree_level_order_traversal_II.py | UTF-8 | 665 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def levelOrderBottom(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
def _... | true |
8b4ba4169ddb8ff0a36bcc5a10a0e81a17a0314b | Python | Krzyzaku21/Git_Folder | /_creating_programs/lotto.py | UTF-8 | 330 | 2.765625 | 3 | [] | no_license | #symulator liczb lotto
# %%
from random import randint as ran
set_nums = set()
def big_lotto():
while len(set_nums) != 6:
random_nums = int(ran(1,49))
set_nums.add(random_nums)
str_nums = "".join(str(set_nums).replace("{", "")).replace("}", "")
print(f" Win numbers are: {str_nums}")
big_lot... | true |
fb43e10e7a02ac2b47a2ae08139f5fa8518d6fb2 | Python | lalitmahato/Content-Management-System | /event/models.py | UTF-8 | 1,188 | 2.734375 | 3 | [] | no_license | from django.db import models
from datetime import datetime
from pages.imageCompression import compress_image
class Event(models.Model):
"""
Event model
Fields
event title (Foreign Key)
event description
event_image
event created date
event location
event ti... | true |
565eec001c8fc1064d0747cdb23122f692cb9907 | Python | littlelienpeanut/Leetcode_challenge | /Two_Sum_IV_-_Input_is_a_BST.py | UTF-8 | 715 | 3.140625 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def findTarget(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: bool
... | true |
87649b5087392f339bf998cd7cf2ec8fbfcac361 | Python | sherry-roar/Roar | /pydfs/port1.py | UTF-8 | 502 | 2.9375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'Mr.R'
import socket
# 1.创建socket对象
s = socket.socket()
# 获取本地主机名
host = socket.gethostname()
# 设置端口
port = 12345
# 2.绑定端口
s.bind((host, port))
# 3.等待客户端连接,监听socket对象
s.listen(5)
while True:
c, addr = s.accept() # 建立客户端连接
print('连接地址:', addr)
... | true |
2faa36c61324d9d51e2d86a73363641211b26ec0 | Python | mkw18/CellSegmentation | /supplementary_modify/see.py | UTF-8 | 10,167 | 2.546875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu May 28 00:05:53 2020
@author: SC
"""
from __future__ import absolute_import
import cv2
import numpy as np
import os
import os.path as osp
from tensorflow.keras import layers, models, optimizers
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow.keras.... | true |
eeed92298ada742ea09fe30c7f347f72294990e5 | Python | KarolAntczak/DeepStenosisDetection | /Network.py | UTF-8 | 1,579 | 2.703125 | 3 | [] | no_license | import pickle
from Keras.keras.backend import *
from Keras.keras.layers import *
from Keras.keras.models import *
from Keras.keras.optimizers import SGD, Adam
def load_dataset(filename):
dataset = pickle.load(open(filename, 'rb'))
return dataset
def generate_output_set(dataset, assigned_class):
return ... | true |
2d2896886fbc8efec9b56653b392f0e39c58cf63 | Python | JoaoPauloAntunes/Python | /exs-python-brasil/EstruturaSequencial/5-metros-para-centimentros.py | UTF-8 | 88 | 3.71875 | 4 | [] | no_license | # 1 m = 100 cm
metros = float(input('Metros: '))
print(f'centímetros: {metros * 100}') | true |
cee2e189d2974098579fa0aa07c3c7319950d1e1 | Python | utkuozbulak/pytorch-cnn-visualizations | /src/LRP.py | UTF-8 | 5,680 | 2.8125 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
"""
Created on Mon Mar 14 13:32:09 2022
@author: ut
"""
import copy
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
from misc_functions import apply_heatmap, get_example_params
class LRP():
"""
Layer-wise relevance propagation with gamma+epsilon rule
... | true |
74ff4a54c781d9ed1ed46465f064e11ed96a36cb | Python | jokojeke/Python | /week1/1.1.py | UTF-8 | 277 | 3.640625 | 4 | [] | no_license | name =input('What is your name?\n')
surname =input('What is your surname?\n')
Education =int(input('What is your Education\n'))
Studentcode =int(input('What is your Studentcode\n'))
print(" %s." %name)
print(" %s." %surname)
print(" %s." %Education)
print(" %s." %Studentcode) | true |
8a7a5e589433400aa97fd1de80f41e5bf18407b4 | Python | dnaka/EV3_sample | /sample/testColor.py | UTF-8 | 570 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import ColorSensor
from pybricks.parameters import Port, Color
from pybricks.tools import wait, DataLog
"""
色センサーの確認用コード
"""
colorSensor = ColorSensor(Port.S3)
ev3 = EV3Brick()
# ログファイル指定
#data = DataLog('R', 'G', 'B', app... | true |
c9eba56daa4f391483fc4f91594868ba07371af0 | Python | bw33/Python_Games | /Week 2 Project - Guess_The_Number.py | UTF-8 | 2,237 | 4.0625 | 4 | [] | no_license | # Guess the Number Game
# Import the module
import simplegui
import random
# Define global variables (program state)
print "Instructions!"
print "_____________"
print ""
print "Pick a number range, i.e. from 1-100 or 1-1000."
print "The goal of the game is to guess correctly the number"
print "that the computer rando... | true |
22a6875d3591c9d8b3db56b902f8994134464970 | Python | johnhjernestam/John_Hjernestam_TE19C | /Programmeringslaboration/Uppgift 1/euppgift.py | UTF-8 | 1,081 | 3.84375 | 4 | [] | no_license | import random as rnd # Importerar random för att få slumpmässiga punkter till rad 4 och 5
n = 0 # Variabel för hur många punkter som kommer hamna i cirkeln
for k in range(20): # Först gången programmet kör denna rad kod så är k = 0, nästa gång k=1 osv. upp till k=19
x = rnd.uniform(-1,1) # Eftersom raden har en i... | true |
18ee8cb9eca62af3e2719fa5bb63aafe8d69e3ac | Python | Fondamenti18/fondamenti-di-programmazione | /students/1742740/homework04/program02.py | UTF-8 | 11,073 | 3.875 | 4 | [] | no_license | '''
Il tris e' un popolarissimo gioco. Si gioca su una griglia quadrata di 3×3 caselle.
A turno, i due giocatori scelgono una cella vuota e vi disegnano il proprio simbolo
(un giocatore ha come simbolo una "o" e l'avversario una 'x').
Vince il giocatore che riesce a disporre tre dei propri simboli in linea retta
ori... | true |
1a9d4463d479c4264fa1f75add3d3da978618895 | Python | kimbomi99/05_week | /funtional_test.py | UTF-8 | 3,153 | 3.015625 | 3 | [] | no_license | from selenium import webdriver
import unittest
class FuntionalTest(unittest.TestCase):
class QuestionDetailViewTests(TestCase):
...
def test_has_a_href_link(self):
"""
Questions with a pub_date in the past are displayed on the
detail page with a href link to result page.
... | true |
f460e723d8847fc9d80dddf1b262a731487a49a2 | Python | thangteo/TheCryptoBall | /telegram.py | UTF-8 | 646 | 2.859375 | 3 | [] | no_license | import datetime
import json
import requests
import time
import urllib
# define key/global variables
baseURL = "https://api.telegram.org/bot"
# send message through telegram bot
def send_message(text, chatID , token):
text = urllib.parse.quote(text)
url = baseURL + token + "/sendMessage?text={0}&c... | true |
2350a5160bb8de897ec1e0da1029b2a6bc59163f | Python | JASAdrian1/EDD_SmartClass_201901704 | /Fase2/matriz_dispersa/lista_interna_matriz.py | UTF-8 | 3,194 | 3.046875 | 3 | [] | no_license | from matriz_dispersa.nodo_interno import nodo_interno_matriz
class lista_interna_matriz:
def __init__(self):
self.primero = None
def insertarx(self,tarea,x,y):
nuevo_nodo = nodo_interno_matriz(tarea,x,y)
if self.primero is not None:
if nuevo_nodo.posy< self.primero.posy:
... | true |
2d22b3e00ab6ba15c9f6da6fdc128c85c80828f6 | Python | XelorR/adventofcode_2015 | /day_03/first_part.py | UTF-8 | 418 | 3.703125 | 4 | [] | no_license | INPUT = open("input.txt").read()
def visit_houses(directions):
visited = set()
x = 0
y = 0
for direction in directions:
if direction == "^":
y += 1
elif direction == "<":
x -= 1
elif direction == ">":
x += 1
elif direction == "v":
... | true |
c1bb35216a283cb8cb1ef171408aa7f91a9d5ab9 | Python | bluaxe/TNN | /tools/caffe2onnx/src/OPs/Pooling.py | UTF-8 | 7,053 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | import numpy as np
import src.c2oObject as Node
import math
import copy
def get_pool_pads(layer):
pad = layer.pooling_param.pad
if pad != 0:
pad_h = pad_w = pad
else:
if layer.pooling_param.pad_h != 0 and layer.pooling_param.pad_w != 0:
pad_h = layer.pooling_param.pad_h
... | true |
d9049f681d71aebc220bde95041be187d4b5fa45 | Python | amin-sorkhei/PythonProjects | /BuildingMachineLearningSystemsWithPython-master/ch10/simple_classification.py | UTF-8 | 2,224 | 3.015625 | 3 | [
"MIT"
] | permissive | # This code is supporting material for the book
# Building Machine Learning Systems with Python
# by Willi Richert and Luis Pedro Coelho
# published by PACKT Publishing
#
# It is made available under the MIT License
import mahotas as mh
from sklearn import cross_validation
from sklearn.linear_model.logistic import Log... | true |
482c08b2fc7faab8f6555182ff4f01d45ecf0177 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_155/2958.py | UTF-8 | 531 | 2.953125 | 3 | [] | no_license | import sys
lines = sys.stdin.readlines()
n_tests = int(lines[0])
for j in range(1,len(lines)):
line = lines[j]
if not line.strip():
continue
nums = line.split(" ")
smax = int(nums[0])
counts = [int(x) for x in nums[1].strip()]
invites = 0
standing = 0
for i in range(len(counts... | true |
caf8e0a10c785221f8207a5c69e5efd46fa29d27 | Python | Swastik-Saha/Python | /Print_List_of_Even_Numbers.py | UTF-8 | 355 | 4.3125 | 4 | [
"MIT"
] | permissive | # INPUT NUMBER OF EVEN NUMBERS
n = int(input("Enter the limit : ")) # user input
if n < 0:
print("Invalid number, please enter a Non-negative number!")
else:
even_list = [i for i in range(0,n+1,2)] # creating string with number "i"
print(even_list) # in ... | true |
9a4698ed416370f07c1d78e3173084974d3972ef | Python | saksham0309/GUI-Music-Player-using-Tkinter-and-Pygame | /MusicPlayer.py | UTF-8 | 2,328 | 3.546875 | 4 | [] | no_license | #Importing Necessary Modules
import pygame
import tkinter as tkr
from tkinter.filedialog import askdirectory
import os
#creating window (interface) for player
musicplayer = tkr.Tk()
#adding title for interface
musicplayer.title("Music Player")
#setting dimensions of tkinter window
musicplayer.geometry('... | true |
9750a57f98f60e192b3530c22876a6db24b56047 | Python | SonjaGrusche/LPTHW | /EX06/ex6.py | UTF-8 | 1,301 | 4.6875 | 5 | [] | no_license | # the variable for x gets set, it consists of a string with a format character and its variable at the end
x = "There are %d types of people." % 10
# the variable for binary is binary
binary = "binary"
# the variable for do_not is don't
do_not = "don't"
# the variable for y is a string that includes two format charact... | true |
beecfeba880731495bc60a7c49d3829707b9dac8 | Python | tasusu/ProjectEuler | /problem28.py | UTF-8 | 235 | 3.1875 | 3 | [] | no_license | '''
Problem 28
https://projecteuler.net/problem=28
'''
if __name__ == '__main__':
s = 1
n = 1
for i in range(1, 1001//2 + 1):
for j in range(4):
n = n + 2 * i
s += n
print(s) | true |
da036ad944b3bcf7bfc5fe9a1e742d5df41c67ce | Python | PELTECH/raspberry-pi-gmail-alarm | /GmailAlarm.py | UTF-8 | 3,401 | 3.25 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
#-------------------------------------------------------------------------------
# GmailAlarm.py
#-------------------------------------------------------------------------------
# Description:
# A Python script written for the Raspberry Pi which checks your Gmail inbox for
# an alarming subject a... | true |
5b7078e29a5e1e59fdf62d0d8fc71fa4e650381c | Python | ryudox/yehg-core-lab-misc | /dll-hijack-helper/dll-hijack-helper.py | UTF-8 | 5,251 | 2.59375 | 3 | [] | no_license | # DLL Hijacking Helper
# Myo Soe, http://yehg.net/
# 2013-12-08
# platform: Python 2.x @ Windows
import csv
import shutil
import hashlib
import os
import sys
import re
def md5sum(filename):
md5 = hashlib.md5()
if os.path.exists(filename) == True:
with open(filename,'rb') as f:
... | true |
8581195d63c35c9962bc8d7496e920e04fe743a5 | Python | Alwayswithme/LeetCode | /Python/007-reversed-integer.py | UTF-8 | 658 | 3.75 | 4 | [] | no_license | #!/bin/python
#
# Author : Ye Jinchang
# Date : 2015-04-27 23:06:18
# Title : 7 reversed integer.py
# Reverse digits of an integer.
#
# Example1: x = 123, return 321
# Example2: x = -123, return -321
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: i... | true |
e78ba6354ac6d5367370c94dfc5c5b9bc441adb9 | Python | fela/triangles | /test_triangles.py | UTF-8 | 1,671 | 2.796875 | 3 | [] | no_license | import unittest
from triangles import subsets, list_of_set_to_set_of_set
class TestListOfSetToSetOfSet(unittest.TestCase):
def test_two(self):
inp = [{1}, set()]
output = {
frozenset({1}),
frozenset(set())
}
self.assertEqual(list_of_set_to_set_of_set(inp), ... | true |
6e08ca834437f12829c02c1267b234e7c0b859ad | Python | tsvikas/hanabi | /players/humanlike.py | UTF-8 | 12,294 | 2.59375 | 3 | [] | no_license | from collections import namedtuple
from game import Clue, Play, Discard, ResolvedClue
CardInfo = namedtuple('CardInfo', 'positive negative')
Info = namedtuple('Info', 'suit rank')
PossibleClue = namedtuple('PossibleClue', 'player card type')
def humanlike_player(state, log, hands, rules, tokens, slots, discard_pile)... | true |
6fad53e1c2ccb6a6dd2bed74d02262f587452cf7 | Python | MirekPz/WSB | /csv-2-excel_pasek_postepu.py | UTF-8 | 890 | 3.625 | 4 | [] | no_license | # Konwersja wielu plików CSV do formatu Excela
# uwaga: w folderze "Dane" mogą być przed konwersją tylko pliki CSV
import os
import pandas as pd
from tqdm import tqdm
import time
print(os.getcwd())
files_list = os.listdir("Dane")
print("\nZawartość katalogu przed konwersją plików:\n", files_list)
print()
print(os... | true |
e7cceae7fb33e63f72018334db4e805b979a5d93 | Python | Thunor12/cours-soutient-telecom | /Python/SourcesP/06-control-exception.py | UTF-8 | 441 | 3.578125 | 4 | [] | no_license | # =============== Gestion d'exception, sans "2nde chance"
try:
i = int(input(" (Saisie securise): Donner un entier SVP: "))
except ValueError:
print(" Il faut donner un ENTIER!")
print(i)
# =============== Gestion d'exception AVEC "2nde chance"
while True:
try:
i = int(input(" (Saisie s... | true |
56290d0ac7b0e4ff2c8a0ba7e2ab71f7e78fd8ff | Python | sun1218/SuperProjects | /Super tkinter/file_read.py | UTF-8 | 4,499 | 3.234375 | 3 | [
"MIT"
] | permissive | # 导入模块
import tkinter
import os
import time
from tkinter import ttk
from tkinter import filedialog
from PIL import Image, ImageTk
# 定义类
class Application():
def __init__(self):
# 设置根窗口
self.root = tkinter.Tk()
self.root.title('文件预览') # 设置标题
self.entryvar = tkinter.StringVar() # ... | true |
2642f56d74b35360dbb3a12b27ffbef740ef085d | Python | LalithK90/LearningPython | /privious_learning_code/OS_Handling/os.close() Method.py | UTF-8 | 501 | 3.96875 | 4 | [] | no_license | # Description
#
# The method close() closes the associated with file descriptor fd.
# Syntax
#
# Following is the syntax for close() method −
#
# os.close(fd);
#
# Parameters
#
# fd − This is the file descriptor of the file.
#
# Return Value
#
# This method does not return any value.
# Example
import os, sys
# Open a ... | true |
b87f893aeade4d87b8e03980d98a74f9f9b720dc | Python | granatb/DS-y-mordeczki | /najlepszy_shellsort.py | UTF-8 | 534 | 3.46875 | 3 | [] | no_license | def shell_sort(t):
n = len(t)
h = 1
while True:
h = 3*h + 1
if h >= n:
h = h//9
break
if h == 0:
h = 1
while h >0:
for j in range(n-h-1,-1,-1):
x = t[j]
i = j+h
while i <= n-1 and x > t[i]:
t[... | true |
35f1767c59ad4ffd6e83a30cb8b81aa7966b37cb | Python | mikaelgba/PythonDSA | /cap5/Metodos_Especiais.py | UTF-8 | 1,290 | 3.75 | 4 | [] | no_license | #Classe Livro
#Metodos especiais são metodos dentro da classe do objeto que permitem trabalhar o objeto com diversas funções Buiit-in
class Livro ():
def __init__( self, nome, autor, paginas ):
self.nome = nome
self.autor = autor
self.paginas = paginas
#Metodo que ... | true |
d98bf7fb05ff220efcab393e7ea7acd7cc7871b6 | Python | Aasthaengg/IBMdataset | /Python_codes/p02863/s590627710.py | UTF-8 | 811 | 2.75 | 3 | [] | no_license | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
from operator import itemgetter
n, t = list(map(int, readline().split()))
mat = [list(map(int, readline().split())) for _ in range(n)]
mat.sort(key=itemgetter(0))
dp = [[0] * ... | true |
72d1820040c883e8c5182b67beab0719732f53f1 | Python | michael-far/neuron-classfication | /learn_ephys_feats.py | UTF-8 | 3,756 | 2.515625 | 3 | [] | no_license | import pandas as pd
import numpy as np
from keras.layers import Dense, Dropout
from keras.models import Sequential
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import StratifiedKFold
from model import Model
from helper_func import calc_metrics, plot_confusion_matrix
class FeatureLea... | true |
de1dd609dbe7e74269c6e0485f8a8a65639ff4ba | Python | destinyddx/HelloWorld | /PCA.py | UTF-8 | 2,158 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | import numpy as np
class PCA:
def __init__(self, n_components):
"""初始化PCA"""
assert n_components >= 1, "n_components must be valid"
self.n_components = n_components
self.components_ = None
def fit(self, X, eta = 0.01, n_iters = 1e4):
"""获得数据集X的前n个主成分"""
... | true |
1150edd260176d4f517c1eae995b8f08d2d750fe | Python | LzWaiting/03.PythonProcess | /code/example/process_lock.py | UTF-8 | 444 | 2.90625 | 3 | [] | no_license | from multiprocessing import Process,Lock
import sys
from time import sleep
def writer1():
lock.acquire()
for i in range(20):
sys.stdout.write('writer1 我想先向终端写入\n')
lock.release()
def writer2():
lock.acquire()
for i in range(20):
sys.stdout.write('writer2 我想先向终端写入\n')
lock.release()
lock = Lock()
w1 = Proc... | true |