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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6da7371b0a5ac4b4af36a2ad4c4dfb5c8cac7a4d | Python | AragonGalvan/programacionCompetitiva | /Python/may4.py | UTF-8 | 111 | 3.390625 | 3 | [] | no_license | a=int(input())
b=int(input())
if a>b:
b=a
a=int(input())
if a>b:
b=a
a=int(input())
if a>b:
b=a
print(b)
| true |
768176bc94d22bf06c359ace9acc6f76bd5dc863 | Python | JasonYRChen/DataStructures_codes | /ch9/tree/ArrayBinaryTree.py | UTF-8 | 10,228 | 3.359375 | 3 | [] | no_license | from ch9.tree.BinaryTree import BinaryTree
from collections.abc import Iterable
from collections import deque
class MultipleNodesError(Exception):
pass
class ArrayBinaryTree(BinaryTree):
class _Node:
__slots__ = '_element', '_key', '_index'
def __init__(self, key=None, element=None, index=N... | true |
8b2b9d2dd1ea3817ccf5e3ec4bd9e7e9a2946344 | Python | Jumaruba/LeetCode | /819.py | UTF-8 | 652 | 2.890625 | 3 | [] | no_license | class Solution:
def mostCommonWord(self, p: str, banned: List[str]) -> str:
p = re.sub(r'[!|\?||\'|,|\.|;| ]+', ' ', p)
w = p.split(" ")
dict = {}
bestUntilNow = -1
bestWord = ''
for b in banned:
dict[b.lower()] = -1
for s in w:
s = ... | true |
7e705f9071944bd55eb3afe4d910dca5c2dccdcc | Python | jinurajan/Datastructures | /LeetCode/hard/reachable_node_in_subdivided_graph.py | UTF-8 | 2,653 | 3.796875 | 4 | [] | no_license | """
882. Reachable Nodes In Subdivided Graph
You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a chain of nodes, with the number of new nodes varying between each edge.
The graph is given as a 2D array of edges where edg... | true |
2ef71cb4b8cb0b8791d8838b90b6812cafa6540c | Python | ericwenn/breakout | /visualize_evaluation.py | UTF-8 | 1,621 | 2.625 | 3 | [] | no_license | import matplotlib.pyplot as plt
import sys
import json
import numpy as np
print(list(range(len([9,3,2]))))
def get_data(eval_name):
with open('evaluations/{}.json'.format(evaluation), 'r') as infile:
data = json.load(infile)
epochs = sorted(data.keys(), key=int)
print(epochs)
mins = []
maxs = []
mea... | true |
528a0013bde1c8bd26f592238528b4e4509fed7c | Python | Aninhacgs/Programando_com_Python | /Estrutura_Dados_Python/fila.py | UTF-8 | 445 | 3.5 | 4 | [] | no_license | class Fila(object):
def __init__(self):
self.dados = []
def insere(self, elemento):
self.dados.append(elemento)
def retira(self):
return self.dados.pop(0)
def vazia(self):
return len(self.dados) == 0
fila = Fila()
fila.insere(1)
fila.insere(2)
fila.... | true |
9081b4213403ef47098487662481f8f2599676cc | Python | Blacktiger25/pyanalytics | /file1.py | UTF-8 | 143 | 2.828125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 6 16:57:57 2020
@author: Udbhav
"""
x=1
print(x)
y="Udbhav"
print(y)
print("hello world")
| true |
c616c1f8cf478f6be63dad5271e9bc694c3f43cf | Python | Boye-Koks/LeMooseUltra | /Model_Boye/firstmodel.py | UTF-8 | 1,312 | 2.734375 | 3 | [] | no_license | #! /usr/bin/python3
import pandas as pd
import numpy as np
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import LabelEncoder
from keras.models import Sequential
from keras.layers import Dense
def create_model(nodelist):
model = Sequential()
model.add(Dense(784, input_shape=(784,)... | true |
04898077c0d6e8bc503037304fa672ef3c00ca4d | Python | ciortanmadalina/bioinfo_db | /1.py | UTF-8 | 1,764 | 3.234375 | 3 | [] | no_license | import random
def createRandomString(n):
random.seed(7)
seq = ''.join([random.choice('ACGT') for _ in range(10)])
print('string : ' + seq)
return seq
def longestCommonPrefix(s1, s2):
i = 0
while 1< len(s1) and i< len(s2) and s1[i] == s2[i]:
i+=1
return s1[:i]
basePairs = {'A' : 'T'... | true |
86ebc16c6af8a232d6eaeace56526621a807137c | Python | melug/piper | /piper/http.py | UTF-8 | 446 | 2.671875 | 3 | [] | no_license | import logging
from .base import ResponseFilter
class ContentTypeFilter(ResponseFilter):
def __init__(self, content_type):
self.content_type = content_type
def run(self, res):
if self.content_type in res.response.headers["content-type"]:
yield res
else:
loggi... | true |
abcfba3bc1e7abb50d5ba88371e331ecc3992207 | Python | djrodgerspryor/cancer-automata | /cancer.py | UTF-8 | 7,057 | 2.875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
"""
A subclass of CellularAutomata which implements the cancer-growth model described by Qi et al. (1993)
"""
__author__ = 'Daniel Rodgers-Pryor'
__copyright__ = "Copyright (c) 2014, Daniel Rodgers-Pryor\nAll rights reserved."
__license__ = "MIT"
__version__ = "1.0"
__maintainer__ = __author__
__e... | true |
f13b6b7c32ef4a1143da5418cd5b96c20ec8115f | Python | hyj1116/LeetCode-HYJ | /1-Easy/14. Longest Common Prefix/Horizontal_scanning.py | UTF-8 | 619 | 3.65625 | 4 | [] | no_license | class Solution:
def longestCommonPrefix(self, strs):
if not strs:
return ""
pre = list(strs[0])
for i in range(1, len(strs)):
try:
while strs[i].index(strs[0]) != 0:
pass
except ValueError:
pre.pop() # 程... | true |
60e7886d8be1ff8380cf46f4222940304055ae66 | Python | elyordan/CIS3319 | /Lab2/server.py | UTF-8 | 3,022 | 3.21875 | 3 | [] | no_license | from Crypto.Cipher import DES
import socket
import random
#header is the maximum bit number for the message
HEADER = 64
PORT = 5050
#Get the ip address from the local network
SERVER = socket.gethostbyname(socket.gethostname())
#contains the ip and port
ADDRESS = (SERVER, PORT)
#format in which the bits are encoded or... | true |
c8ce06fa49e625e100a529c7e7fe8cc337d5563a | Python | arunavs94/EE232E_Hw1 | /hw1.py | UTF-8 | 9,258 | 3.625 | 4 | [] | no_license | # The code in this file is for Questions 1,2, and 4
# Question 3 was done in R
from igraph import *
import matplotlib as mpl
mpl.use('TkAgg')
from matplotlib import pyplot as plt
import numpy as np
import random as rnd
import pprint
import cairo
def main():
part1()
part2()
# part3()
part4()
def part1():
print ... | true |
4598dc5e20d59d52d0f0eb61f49c8658db97bc71 | Python | Vickyvanshaj/Assignment | /send_email.py | UTF-8 | 374 | 2.8125 | 3 | [] | no_license | import smtplib
class Solution:
def fn(self):
s=smtplib.SMTP('smtp.gmail.com',587)
s.starttls()
s.login("your_email","your_password")
SUBJECT=input("Subject?")
TEXT=input("Body?")
recipient=input("Recipient?")
message='Subject: {}\n\n{}'.format(SUBJECT, TEXT)
s.sendmail("your_email",recipient,message)
... | true |
9b301a61b3fbada0138218e4de8bd7b90aa76791 | Python | magickris93/msarc | /clusteralign/partition.py | UTF-8 | 9,997 | 2.6875 | 3 | [] | no_license | from numpy import ndarray, array, empty, empty_like, zeros, ones, arange, uint8
from ._partition import bestmove, calcgains_group, fixgains_group
class GraphPartitioner(object):
def __init__(self, graph):
from .graph import Graph
assert isinstance(graph, Graph), 'Parameter "graph" is not an instan... | true |
e874c4c743db5099f20b9626adca4baff4ce23af | Python | Riley-Robinson/Intro-Python-I | /hello.py | UTF-8 | 177 | 3.28125 | 3 | [] | no_license | # print('Hello world')
name = 'Sean'
# print('Hello' + name)
# print(f'Hello {name}'')
if name != 'sean':
print('who you be willis')
else:
print(f'hello {name}')
| true |
0af7c3cf7ac06a5c4f7ba2a977a9bcba83ed1466 | Python | johnlev/coderdojo-curriculum | /Week7/Animal.py | UTF-8 | 376 | 3.96875 | 4 | [
"MIT"
] | permissive | # This is an example answer. Students will have to code the Animal class as their assignment
class Animal:
def __init__(self, color, age, animal = "Animal"):
self.color = color
self.age = age
self.animal = animal
def getInfo(self):
print("I am a {}-furred {}, and I am ... | true |
05a5d2d96d960eaa4ae2ed3a9be91f147539d5e6 | Python | darshanpyadav/Hacker_rank | /interview/chaos.py | UTF-8 | 416 | 3.203125 | 3 | [] | no_license | t = int(input())
result = []
for i in range(t):
n = int(input())
ar = list(map(int, input().split()))
j = 0
bribe_val = 0
while j < len(ar):
# print(j)
val = abs(ar[j] - ar[j+1])
if val > 2:
result.append("Too chaotic")
break
j += val + 1
... | true |
cd986862f4542e077993304daeeefa4eabf9e97f | Python | Aasthaengg/IBMdataset | /Python_codes/p02272/s094470146.py | UTF-8 | 1,151 | 3.390625 | 3 | [] | no_license | import sys
from typing import List
COMP_NUM = 0
def merge(elements: List[int], left: int, mid: int, right: int) -> None:
global COMP_NUM
n1 = mid - left
n2 = right - mid
left_array = [0] * (n1 + 1)
right_array = [0] * (n2 + 1)
left_array[0:n1] = elements[left:left + n1]
left_array[n1] = ... | true |
0797a014cc1f6aa1c13f4d7ae7bd78850aa506ee | Python | kumar-sanchay/CompetitiveProgramming | /piece_of_cake.py | UTF-8 | 869 | 3.140625 | 3 | [] | no_license | class Solution:
def maxArea(self, h: int, w: int, horizontalCuts: List[int], verticalCuts: List[int]) -> int:
horizontalCuts.append(h)
verticalCuts.append(w)
horizontalCuts.append(0)
verticalCuts.append(0)
horizontalCuts.sort()
vert... | true |
e73b8d20e27a43745851b425c611d3c65cd9e75e | Python | kevinandrewbishop/mailtracker | /mailtracker/transaction_manager.py | UTF-8 | 1,810 | 3.1875 | 3 | [
"MIT"
] | permissive | from time import sleep
import csv, json
import os
class TransactionManager():
'''
Tracks the transactions in the database and monitors the email folder
for new transactions. Has "run" method that checks for new transactions
every so many seconds.
'''
def __init__(self, email_client, outfile, regex):
self.clien... | true |
92456e9156f3c20fdb2a5c83f3eac029939adc38 | Python | Rodas-Nega1/ICS3U-Unit5-03-Python-Grade_Percentage | /grade_percentage.py | UTF-8 | 1,650 | 4.28125 | 4 | [] | no_license | # /usr/bin/env python3
# Created by: Rodas Nega
# Created on: Oct 2021
# This program asks the user for their grade level and
# converts it into a middle percentage
def level_conversion(grade_level):
# calculate percentage from level
# process & output
if grade_level == "4+":
grade_percentage = ... | true |
09581fa66d63c1689368ab841df5c89c3217244c | Python | melissa1021/UTP20181 | /CB/pruebas.py | UTF-8 | 257 | 3.328125 | 3 | [] | no_license | import math as math
def fact(pr_n):
if pr_n <= 4: raise AssertionError("N < 5")
if pr_n == 5: return 120
return pr_n * fact(pr_n-1)
try:
print(fact(7))
except:
print("Error en factorial")
finally:
print("Ultima cosa que se hace") | true |
feb410cd7d3c57965572b6d7d2734cf76ba9c803 | Python | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_118/225.py | UTF-8 | 1,015 | 3.140625 | 3 | [] | no_license | from math import sqrt, ceil
# bases = []
def is_palindrome(num):
return str(num) == "".join(reversed(str(num)))
# def build_bases(a,b):
# for i in range(a,b+1):
# if is_palindrome(i) and is_palindrome(i**2):
# bases.append(i)
bases = [1, 2, 3, 11, 22, 101, 111, 121, 202, 212, 1001, 1111,... | true |
8d8240324bc4a3c290757b5910945b1b8b962ecf | Python | cptjack00/SmartParking | /find_user.py | UTF-8 | 509 | 2.828125 | 3 | [] | no_license | import sqlite3
def find_user_id(username):
try:
sqliteConnection = sqlite3.connect('db.sqlite3')
cursor = sqliteConnection.cursor()
sql_select_query = """SELECT * FROM auth_user WHERE username = ?"""
cursor.execute(sql_select_query, (username,))
record = cursor.fetchone()
... | true |
61dd9400b45a52c018db88d2c1de054cf39a5f75 | Python | nga-27/SecuritiesAnalysisTools | /libs/tools/statistics.py | UTF-8 | 739 | 3.453125 | 3 | [
"MIT"
] | permissive | """ statistics """
import pandas as pd
import numpy as np
def get_high_level_stats(fund: pd.DataFrame) -> dict:
"""Get High Level Stats
Arguments:
fund {pd.DataFrame}
Returns:
dict -- statistics
"""
stats = {}
len_of_fund = len(fund['Close'])
stats['current_price'] = fun... | true |
64066fb26c7731f8d10b1a29d527fc08917f84d7 | Python | hieutran106/leetcode-ht | /leetcode-python/medium/_1079_letter_tile_possibilities/test_solution.py | UTF-8 | 655 | 2.84375 | 3 | [] | no_license | import unittest
from .solution import Solution
class MyTestCase(unittest.TestCase):
def setUp(self) -> None:
self.s = Solution()
def test_case1(self):
actual = self.s.numTilePossibilities("AAB")
self.assertEqual(actual, 8)
def test_case2(self):
actual = self.s.numTilePoss... | true |
dd47c3b5564dcc4e162ff863ad438ed66e3f5da0 | Python | alexthegreat1/hackathon-tracking-car | /python-tracking-car/mapGUI.py | UTF-8 | 19,202 | 2.9375 | 3 | [] | no_license | from statistics import StatisticsError
import tkinter as tk
import serial
import time
import sys
import signal
import statistics
# max width and height that would accurately fit on my laptop screen
# 150 * 8 = 1200
# 150 * 7 = 1050
WIDTH = 1200
HEIGHT = 1055
ARENA_SIDE_LENGTH = 1050
# ARENA_X_START = 75
# ARENA_Y_STA... | true |
e131f9cbc69650852174cb422d0be1170becea57 | Python | steinunnfridriks/ALEXIA_ordtokutol | /alexia/prepare_data.py | UTF-8 | 1,525 | 2.796875 | 3 | [
"CC-BY-4.0",
"Apache-2.0"
] | permissive | """
This script prepares the files that populate the databases, such as adding headers
to them and removing a couple of noun phrases that do not belong there.
"""
def prepare_data(file):
"""
Prepares the argument file for SQL insertion
"""
with open(file, 'r', encoding='utf-8') as infile:
inf... | true |
303770668b10e61d07f5a6450a573b718876f2f8 | Python | kmd2410/2021python | /PythonWorkspace/gui_basic/1_create_frame.py | UTF-8 | 355 | 3.015625 | 3 | [] | no_license | from tkinter import * # 트킨터
root = Tk()
root.title("Taehee GUI") # 타이틀 설정
#root.geometry("640x480") # 크기 설정 가로x세로
root.geometry("640x480+300+100") # 크기 설정 가로x세로 + x좌표 + y좌표(나타내는위치)
root.resizable(False, False) # x너비, y너비 값변경불가 창크기변경불가
root.mainloop()
| true |
acf426fe077daa4b70da43e81f1e06ae84e6d738 | Python | dorellang/MysteryGraphBot | /mystery_graph_bot.py | UTF-8 | 2,109 | 2.53125 | 3 | [
"MIT"
] | permissive | import json
import sys
import logging
from mystery_graph_bot.serializers import Config
from mystery_graph_bot.util import load_data_with_schema_from_json_path
def main():
config = load_config()
setup_logger(config)
bot = MysteryGraphBot(config)
bot.start()
def load_config():
try:
config =... | true |
5a43e40d30e99aca9d48b48d59dee76894c17655 | Python | Yangjiaxin121/learnPython | /untitled1/property.py | UTF-8 | 749 | 3.78125 | 4 | [] | no_license |
class Student(object):
@property
def score(self):
return self._score
@score.setter
def score(self,value):
if not isinstance(value,int):
raise ValueError('score must be an interger')
if value < 0 or value > 100:
raise ValueError('score must between 0 ... | true |
7f8e87fab2b40b798433b954784b3c4894c9c755 | Python | philip30/xnmt | /xnmt/transducers/base.py | UTF-8 | 5,964 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | from typing import List
import numbers
import dynet as dy
from xnmt.modelparts import transforms
from xnmt.persistence import serializable_init, Serializable
from xnmt import expression_seqs
class FinalTransducerState(object):
"""
Represents the final encoder state; Currently handles a main (hidden) state and a ... | true |
8f24f93443848043bf208fb03352622632e949ec | Python | Jasmine-wu/iFlask1.2 | /flask_practise/01/flask_day01/s3_router_demo.py | UTF-8 | 2,647 | 3.234375 | 3 | [] | no_license |
from flask import Flask,render_template,request,redirect,session,url_for
app = Flask(__name__)
app.debug = True # 调试模式
app.secret_key = 'asdfsadfsdafasdfasdf' # 跟djangosetting中的秘钥一个意思
USERS = {
1:{'name':'张三','age':18,'gender':'男','text':"道路千万条"},
2:{'name':'李四','age':28,'gender':'男','text':"安全第... | true |
1f25a15519ffbc201eea9c51ce5777385b1528fb | Python | ting2313/operation_research_final_project | /utils/analytics.py | UTF-8 | 293 | 2.796875 | 3 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
def get_histogram(data, title, xlabel, ylabel, filename):
bins = max(data) - min(data)
plt.hist(data, bins)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.title(title)
plt.savefig(f"image/{ filename }.png")
plt.close() | true |
92784e844839812e18687b069a83360ae91a68e7 | Python | zifangu/dfa | /dfa.py | UTF-8 | 3,433 | 4.0625 | 4 | [] | no_license | #!/usr/bin/env python3
"""
dfa.txt structure:
Line 1: the states of the DFA (separated by commas, if there is more than one state)
Line 2: the alphabet of the DFA (separated by commas, if there is more than one symbol)
Line 3: the starting state of the DFA
Line 4: the final/accept states of the DFA (separated ... | true |
a711091de4aef35ec4973ba4ab2c45975296f3fd | Python | Alekhya-02/5B0_Alekhya | /even or odd.py | UTF-8 | 224 | 3.703125 | 4 | [] | no_license | a=int(input('enter number '))
if a%2==0 :
print('a is an even number')
else :
print('a is an odd number')
#expected output
#enter number 622
#a is an even number
#enter number 3147
#a is an odd number
| true |
cbee33f8e88931575575835bf26ca5fd15c70b86 | Python | Trietptm-on-Security/code | /Python InfoSec SPSE/Module-2/Lesson-7/shellExample.py | UTF-8 | 143 | 2.78125 | 3 | [] | no_license | #!/usr/bin/python
import subprocess
input = raw_input("Enter the directory you want listed: ")
subprocess.call("ls " + input, shell = True)
| true |
e22f565b4b5abf873f91b725ae5af67ea603ef99 | Python | beentaken/sgt | /misc/puzzles/torch.py | UTF-8 | 9,492 | 3.765625 | 4 | [] | no_license | #!/usr/bin/env python
# Solve the generalisation of the quickest-crossing puzzle.
#
# The setup: you have a finite number of people a,b,c,... who all
# wish to cross a bridge at night. The bridge will only take at
# most two of them; they need a torch to cross at all and they only
# have one; they all walk at potentia... | true |
5243c8a307116911cd60364c711a930f0f32ac66 | Python | LexiJess/NASA_MARS_web_scraping | /app.py | UTF-8 | 992 | 2.65625 | 3 | [] | no_license | from flask import Flask, render_template
import json
import scrape_mars
# Import our pymongo library, which lets us connect our Flask app to our Mongo database.
import pymongo
# Create an instance of our Flask app.
app = Flask(__name__)
# Create connection variable
conn = 'mongodb://localhost:27017'
# Pass connecti... | true |
87f4e474a1ddf2c0e7da749689945fe23b8dfbf8 | Python | ZstoneSa/TestTools_Python | /TeatData/demo/demo1.py | UTF-8 | 673 | 3.765625 | 4 | [] | no_license | # -*- coding: utf-8 -*-
# @Time : 2020-11-12 18:38
# @Author : Zstone
# @FileName: demo1.py
# @Software: PyCharm
'''
a = int(input("data:"))
print(type(a))
print('output:%d'%a)
'''
if True:# >1数字或True ,都判断为真,反之False同理
print("1")
else :
print("2")
issues = 6
if issues >= 0 and issues <= 10:
print('qua... | true |
1e9966196b2d7a250d61899481f2376a4a323a27 | Python | PielliaVasyl/servicebus_clients_performance_results | /qpid/perftest.py | UTF-8 | 1,541 | 2.828125 | 3 | [] | no_license | from __future__ import print_function, unicode_literals
import threading
import time
try:
import Queue
except:
import queue as Queue
from proton import Message
class PerfRate:
count = 0
start_time = time.time()
def print_rate(self):
end_time = time.time()
period = end_time - self... | true |
8f32cea3a3df9ec3ea4de2e27a67a76a5318a43f | Python | aitiwa/pythonTraining | /m3_2_forloopTest_003_001.py | UTF-8 | 1,000 | 4.0625 | 4 | [] | no_license | print("caseStudy: 반복문-문자열 읽어 오기")
print('m3_1_forloopTest_003_001.py\n')
print("1. str1 변수 선언과 초기화: ")
print(' str1 = "HelloKOREA" ')
str1 = "HelloKOREA"
print()
print("2. 문자열 함수")
print(' size = len(str1) ')
size = len(str1)
print()
print("2.1 결과값->")
print(' print(" 문자열 길이:", size) ')
print(' print() ... | true |
175cb786d5b197ec85d28a8448fc85ee3f7a9875 | Python | shagun19/Sudoku | /sudoku.py | UTF-8 | 6,906 | 2.640625 | 3 | [] | no_license | import sys
import copy
A=[
[[0],[1],[2],[0],[0],[8],[4],[0],[0]],
[[0],[0],[0],[2],[9],[7],[0],[0],[0]],
[[7],[0],[0],[0],[0],[0],[0],[0],[0]],
[[0],[0],[7],[0],[0],[6],[0],[0],[1]],
[[4],[3],[0],[0],[2],[0],[0],[9],[5]],
[[8],[0],[0],[3],[0],[0],[7],[0],[0]],
[[0],[0],[0],[0],[0],[0],[0],[0],[3]],
[[0],[0],[0],[5],[7... | true |
2fa2240793777376deaa3a51c6229c7fcce520ca | Python | xhan91/advent-of-code | /2017/day10/second.py | UTF-8 | 1,064 | 2.953125 | 3 | [] | no_license | LENGTH_OF_ARRAY = 256
def process(arr, length, current):
tmp_arr = []
for i in range(length):
pos = (i + current) % LENGTH_OF_ARRAY
tmp_arr.append(arr[pos])
tmp_arr.reverse()
for i in range(length):
pos = (i + current) % LENGTH_OF_ARRAY
arr[pos] = tmp_arr[i]
with open('... | true |
2be05349a8b606f860bc118c376d37650769823d | Python | ters81/Sea-battle-game | /Position_of_a_ship_with_4_slots.py | UTF-8 | 6,851 | 3.046875 | 3 | [] | no_license |
from random import choice, randint
# 0 - empty cell
# 1 - cell with a ship
# 8 - forbidden cell (no other ship can stand here)
# Create empty field
field = [
[8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],
[8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8],
[8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8],
[8, 0, 0, 0, 0, 0... | true |
1ea980c09d5d58de4db00b5579d42042583a2466 | Python | StevenLOL/kaggleScape | /data/script921.py | UTF-8 | 3,366 | 3.53125 | 4 | [] | no_license |
# coding: utf-8
# We are told there is a time-based train/test split. Let's have a look at it, and a small explore of the time-structure of the data in general.
# In[ ]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
get_ipython().run_line_magic('matplotlib', 'inline')... | true |
b6b0e9cd132d90bb0455f8b0e605ced243ec837d | Python | bgriessbach/Code_Training | /Last_word.py | UTF-8 | 384 | 3.203125 | 3 | [] | no_license | class Solution(object):
def lengthOfLastWord(self, s):
if s.isspace() or len(s)==0:
return 0
if " " not in s:
return len(s)
reverse=s[::-1]
reverse=reverse.lstrip()
index=0
counter=0
while index<len(reverse) and reverse[index]!=" ":
... | true |
a9bcac1e8fcd95aba39973ac0c0a6c77ecd3e883 | Python | hhe2/pylivetrader-demo | /livealgo_rsi.py | UTF-8 | 1,711 | 3.171875 | 3 | [] | no_license | import talib
from pylivetrader.api import order_target, symbol
def initialize(context):
context.i = 0
# what stock to trade - FAANG in this example
stocklist = ['FB', 'AMZN', 'AAPL', 'NFLX', 'GOOGL']
# make a list of symbols for the list of tickers
context.stocks = [symbol(s) for s in stockli... | true |
ae2158135225496b1e84e3c7aede0440fc37aa0e | Python | pimoroni/mote | /python/examples/set-all.py | UTF-8 | 352 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
import time
from mote import Mote
rgb = (128, 0, 0)
mote = Mote()
mote.configure_channel(1, 16, False)
mote.configure_channel(2, 16, False)
mote.configure_channel(3, 16, False)
mote.configure_channel(4, 16, False)
while True:
r, g, b = rgb
mote.set_all(r, g, b)
mote.show()
ti... | true |
ec84a42c6cd807e3fcaf08902e2cad9470607fbc | Python | DunnyDon/FYP_PredictingHumanBehaviour_Using_CallDetailRecords | /SVM_CrossVal.py | UTF-8 | 1,202 | 2.984375 | 3 | [] | no_license | import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import datasets
from sklearn import svm
import pandas as pd
from sklearn.model_selection import cross_val_score
dataframe = pd.read_csv("ML_Data.csv")
dataset = dataframe.values
# split into input (X) and output (Y) variables
#print d... | true |
dfa9960b9defb7ece63c8a83b2e1a89d0e08af69 | Python | sjindal22/python-programming | /parse-json.py | UTF-8 | 566 | 3.4375 | 3 | [] | no_license | # Example with sample_input.json file
from json import load as jsonLoad
def parseJson(file):
with open(file, 'r') as f:
jsonFile = jsonLoad(f)
for people in jsonFile["people"]:
if people["age"] >= 30:
print("Name: {name}, City: {city}".format(name=people["name"], city=people["city"]))
pars... | true |
dc4999337197716f191eae9a6850efc8d9700a4f | Python | zeroviral/leetcode_stuff | /clone-n-ary-tree/clone-n-ary-tree.py | UTF-8 | 330 | 3.09375 | 3 | [] | no_license | """
# Definition for a Node.
class Node:
def __init__(self, val=None, children=None):
self.val = val
self.children = children if children is not None else []
"""
from collections import defaultdict
class Solution:
def cloneTree(self, root: 'Node') -> 'Node':
return deepcopy(root)
... | true |
3525f2de941b7cd2e214b510af55d9938c784800 | Python | LogicJake/code-for-interview | /leetcode-cn/Python/220.存在重复元素-iii.py | UTF-8 | 940 | 3.109375 | 3 | [] | no_license | #
# @lc app=leetcode.cn id=220 lang=python3
#
# [220] 存在重复元素 III
#
# @lc code=start
from typing import List
class Solution:
def containsNearbyAlmostDuplicate(self, nums: List[int], k: int,
t: int) -> bool:
# 错误情况,绝对值肯定大于等于0
if k < 0 or t < 0:
retu... | true |
2b3e774c8d884676ae9cd372ddefb25d38146a86 | Python | hhxxss0722/double | /test_log/case_20.py | UTF-8 | 839 | 2.640625 | 3 | [] | no_license |
def function_20(col_dic):
err_result = {}
nameList = ['累计里程', '车速', 'DC/DC状态', '档位', '加速踏板行程', '制动踏板状态', ]
for key in nameList:
temp_list = ''
err_result[key] = []
for index in range(0,len(col_dic[key])):
if col_dic['车辆状态'][index] == '熄火' and col_dic['充电状态'][in... | true |
a1cedf531816bd6244e0bb62160120ff2b514de6 | Python | brentleejohnson/tkinter-VerifyForm | /newwindow.py | UTF-8 | 192 | 2.828125 | 3 | [] | no_license | from tkinter import *
root = Tk()
root.title("Member's Area")
root.geometry("300x155")
lbl = Label(root, text="Welcome, Player", font='monospace 21')
lbl.place(x=17.5, y=50)
root.mainloop()
| true |
a222014bd028e20f0e095ac3e78d7d17cb6ae33b | Python | tanlangqie/python_GUI | /python_GUI/Canvas_test.py | UTF-8 | 2,146 | 4.21875 | 4 | [] | no_license | '''
简单说明:
Canvas:画布,提供绘图功能(直线、椭圆、多边形、矩形) 可以包含图形或位图,用来绘制图表和图,创建图形编辑器,实现定制窗口部件。
什么时候用:
在比如像用户交互界面等,需要提供设计的图标、图形、logo等信息是可以用到画布。
'''
import tkinter as tk # 使用Tkinter前需要先导入
# 第1步,实例化object,建立窗口window
window = tk.Tk()
# 第2步,给窗口的可视化起名字
window.title('My Window')
# 第3步,设定窗口的大小(长 * 宽)
window.geo... | true |
22379af97cd265f0c867d873441f2e091f7b0081 | Python | toshit11/nlp-using-xgboost | /nlpp.py | UTF-8 | 3,743 | 2.8125 | 3 | [] | no_license | # Natural Language Processing
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.neighbors import KNeighborsClassifier
from sklearn.en... | true |
14d6dd7a8c9cb2a5725d9b23b54b61cb14967db6 | Python | tung491/algo-expert-2021 | /array/non_contructible_change/non_constructible_change.py | UTF-8 | 403 | 3.609375 | 4 | [] | no_license | def non_constructible_change(coins):
coins.sort()
max_created = 0
for coin in coins:
if coin > max_created + 1:
break
else:
max_created += coin
return max_created + 1
if __name__ == '__main__':
coins = [5, 7, 1, 1, 2, 3, 22]
expected = 20
print(f"Act... | true |
fb5866511442bc9ddd723c0b452640e29dee1080 | Python | 131441456/python | /stringfunction.py | UTF-8 | 306 | 3.25 | 3 | [] | no_license | # a= "gwalior, pninfosys w pninfosys abc w "
# print(len(a))
# print(a.endswith("w")) #pninfosys
# print(a.count("w"))
# print(a.capitalize())
# print(a.find("w")) #first index 0,1,2,3
# print(a.replace("pninfosys","MITS"))
a= "pn gwalior \n \t mits gwalior itm"
a = input("enter first number:\n")
print(a) | true |
10aa2079849c9aa196f18996f5d9b497d96dcdbe | Python | clicianaldoni/aprimeronpython | /src/basic/session.py | UTF-8 | 7,740 | 3.4375 | 3 | [] | no_license | def F(C):
return (9./5)*C + 32
a = 10
F1 = F(a)
F2 = F(15.5)
print F1, F2
Cdegrees = [10, 30, 60]
Fdegrees = [F(C) for C in Cdegrees]
Fdegrees
def F2(C):
F_value = (9.0/5)*C + 32
return '%.1f degrees Celsius corresponds to '\
'%.1f degrees Fahrenheit' % (C, F_value)
s1 = F2(21)
s1
c1 = 37.5
... | true |
ad96e0228b60dee07ea65af3344cf381a451d4d3 | Python | Byzarru/resource-src | /models/editor/signage/split.py | UTF-8 | 446 | 2.765625 | 3 | [] | no_license | from PIL import Image
from pathlib import Path
import itertools
img = Image.open('signage_70s.png')
folder = Path('F:/Git/BEE2-items/packages/signage/resources/BEE2/items/70s/BEE/signage')
num = itertools.count(1)
for x in range(0, 1024, 128):
for y in range(0, 1024, 128):
sheet = img.crop((x, y, x+128, y+128))
... | true |
ea6769c90582575fa628d24db58101004600c849 | Python | ambientlight/Ballcastmind | /src/model_state_saver.py | UTF-8 | 2,047 | 2.640625 | 3 | [] | no_license | from os import makedirs
from os.path import isdir
from typing import Dict, Any, Union, Optional, List
import json
from keras.callbacks import Callback
from keras import Model
class ModelStateSaver(Callback):
model: Model
params: Any
history: Dict[str, List[float]]
training_state: Union[Any, Any]
... | true |
8b55f5e2690e396b253b82b6ec9439956def88b9 | Python | LTilly/ups-on-bilibili | /bili/bili/pipelines.py | UTF-8 | 2,754 | 2.515625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
from twisted.enterprise import adbapi
import pymysql.cursors
class BiliPipeline(object):
def __init__(self, dbpool):
sel... | true |
4c6b8fa31a4bed2c9605f0427b2ea0a5d7ea7469 | Python | MartyTM/uniclick-mm | /net/login_server.py | UTF-8 | 5,275 | 2.75 | 3 | [] | no_license | import MySQLdb
import socketserver
class User:
userCount = 0
def __init__(self, db, uname=None, pword=None):
self.isLoggedIn = False
self.username = uname
self.password = pword
self.db = db
self.userCount += 1
def login(self, uname, pword):
... | true |
0090c311844c2664c56fc6f928009bf7d3cb51d3 | Python | NILGroup/TFG-1920-CarlosMoreno | /StyleAnalyser/extraction/extractor.py | UTF-8 | 8,216 | 2.9375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 12 14:32:54 2019
@author: Carlos Moreno Morera
"""
from __future__ import print_function
import abc
import quotaunits as qu
from abc import ABC
from abc import ABCMeta
from time import time
from time import sleep
from extraction.dataextractor import DataExtractor
from ht... | true |
dc9490a2663dce8cc352b300edad896f1ca571ee | Python | pokspoks/tictactoe | /rendering.py | UTF-8 | 1,381 | 3.5 | 4 | [] | no_license | import os
def render(board_state, height, width, cursor_pos):
printing_buffer = ''
horizontal_spacer = ''
clear_terminal()
# Create a proper width horizontal spacer
for i in range(width):
horizontal_spacer += '- - '
for index, row in enumerate(board_state):
for... | true |
be6b25385d9603563592de6c6b15a54d27a6ffd0 | Python | efgalvao/Practice | /Python - 1/Remove Outermost Parentheses.py | UTF-8 | 1,403 | 4.5 | 4 | [] | no_license | """
A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings.
A valid parentheses string S is primitive if it is nonempty, and there do... | true |
4d262dba9249416006366ee6bc97de78e93f07a1 | Python | Amit3200/Loan_Prediction | /program1.py | UTF-8 | 4,744 | 2.84375 | 3 | [] | no_license | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import KFold #For K-fold cross validation
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier, export_graphviz
... | true |
aeba9be02148847568066e902cf50fd0cda781f1 | Python | keyurijoban/python_workshop | /Solutions/Day_2/where_to_eat_partial.py.py | UTF-8 | 2,472 | 2.6875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 11 10:55:43 2017
@author: Gunnvant
"""
import os
import requests
import pandas as pd
base_dir='E:\Work\Python\Python Trainings'
os.chdir(base_dir)
key=open('google_places_api.txt','r')
k=key.read()
key.close()
url='https://maps.googleapis.com/maps/api/place/nearbyse... | true |
3525265d897e4f8c60a091fca8123716fe36a15f | Python | Bharanij27/bharanirep | /PyhuntS112.py | UTF-8 | 233 | 2.921875 | 3 | [] | no_license | n=list(map(str,input()))
m=list(map(str,input()))
f=[]
for i in range(0,len(n)):
for j in range(0,len(m)):
if n[i]==m[j] and j<=i:
if n[i] not in f: f.append(n[i])
for i in range(0,len(f)): print(f[i],end="")
| true |
c0364dc8fed1ee1a18e212a6eb672027f8e8dfc4 | Python | Bafou/SVL | /TP9/test_banque.py | UTF-8 | 1,479 | 3.203125 | 3 | [] | no_license | # CTD9 SVL - M. Nebut - 03/2016
# property-based testing
import unittest
from hypothesis import given, assume, example
from hypothesis.strategies import floats
from banque import *
class TestTomCrediteUnCompte(unittest.TestCase):
def test_echec_si_somme_negative_classique(self):
compte = Compte()
... | true |
e8eeee9ff1bd7dda7d6fcc8204774ea4e9b06ea7 | Python | xxxzc/public-problems | /PythonBasic/BuiltInFunctions/Iterable/filter/solution.py | UTF-8 | 195 | 3.125 | 3 | [] | no_license | '''TESTCASE
1 100
-
1 1000
-
45 500
-
1 10000
'''
#filter
import math
def is_sqr(x):
return int(math.sqrt(x)) ** 2 == x
n, m = map(int, input().split())
print(*filter(is_sqr, range(n,m+1))) | true |
3f5512295523efe338f127f8563596ba94509d25 | Python | LuisEnGuerrero/EjerciciosPythonAcademlo | /ficheros/readFile.py | UTF-8 | 388 | 3 | 3 | [] | no_license | texto = open('mbox-short.txt', 'r')
archivo=0
"""
for linea in texto:
linea=linea.strip()
if linea == '':
continue
else:
archivo = archivo + 1
print(archivo)
"""
count = 0
for line in texto:
line = line.strip()
if not line.startswith("From:"):
continue
count = coun... | true |
0ef7b40f67ed8ac71c7d4948c17a8017fea871f7 | Python | HeadhunterXamd/random-python-snippets | /foldersystem/foldersystem.py | UTF-8 | 1,777 | 3.03125 | 3 | [] | no_license | __author__ = 'niels van Schooten'
import os
class directory:
"""
objectify the foldersystem
"""
def __init__(self, path):
self.basepath = self.makepath()+path
self.index = len(self.makepath(False))
if not self.exists():
self.makedirectory()
def __str__(self):
return self.basepath
def __repr__(self... | true |
afbf432ce83973ec68fffca5b53d035f7e62b4ff | Python | thu-west/RDF-Association-rule-learning | /patient_and_zhuyuan.py | UTF-8 | 12,882 | 2.546875 | 3 | [] | no_license | # *_*coding:utf-8 *_*
from itertools import permutations
from apriori import apriori
import rdflib
import os, re, time, sys
import argparse
def get_index(g):
index = 1
dict_forward = {}
dict_reverse = {}
for subject, predicate, obj in g:
if not (subject, predicate, obj) in g:
rais... | true |
32f035a17ab2a40e11530ceab608da1b7c2b469c | Python | amssj/python | /archive/helloword/qinggan fenxi.py | UTF-8 | 2,281 | 3.046875 | 3 | [] | no_license | ## tokenization
import nltk
nltk.download('stopwords')
nltk.download('punkt')
nltk.download('wordnet')
nltk.download('brown')
nltk.download('averaged_perceptron_tagger')
from nltk.tokenize import word_tokenize, sent_tokenize
word_example = "I love Python and R,and I have typed 'hello, world' to prove my loyalty to the... | true |
5ba56d91e35f1a00d0fe3ce58366f86615f123d1 | Python | msaqibdani/LeetCode-Practice | /LC918_MaximumSubArrayCircular.py | UTF-8 | 579 | 2.921875 | 3 | [] | no_license | def maxSubarraySumCircular(self, A: List[int]) -> int:
total = local_max = local_min = 0
maximum = float('-inf')
minimum = float('inf')
for num in A:
total += num
local_max = max(num, local_max + num)
local_min = min(num, local_min + num)
... | true |
83260ffe644fc6d1ae28c8a6e6b2764af7e6b55a | Python | robertpolak1968/Python | /python2013/pythponBOOK/Rozdzial12/find.py | WINDOWS-1250 | 3,469 | 3.046875 | 3 | [] | no_license | import os, os.path
import re
from stat import *
# To pierwsza wersja. Uyj jej przy pierwszym wywoaniu
# testu test_find.py
def find (where='.*', content=None, start='.', ext=None, logic=None):
return ([])
# To druga wersja. Dodaje niektre funkcje, ale nie
# oblewa niektre teksty.
def find (where='.*', content=Non... | true |
7f346ec729f4a1ccc15f8fefc4515bc8382e797d | Python | stankiewiczm/contests | /ProjectEuler/UC solutions/Successful 150--/Q151.py | UTF-8 | 756 | 2.578125 | 3 | [] | no_license | from Numeric import *
PROBS = zeros(1113, Float);
PROBS[1111] = 1.0; # Pages of size A2, A3, A4, A5;
QUEUE = [1111]; PQ = 0;
def Itr(Qpos):
V = PROBS[QUEUE[Qpos]];
OldC = QUEUE[Qpos]
S = 0;
for i in str(OldC):
S += int(i);
for Card in arange(S):
Done = 0; Fig ... | true |
e4740e522b7f7e58b793b0978e72c57d84f86fa4 | Python | Adnene93/Deviant | /Deviant-Code/util/matrixProcessing.py | UTF-8 | 13,103 | 2.796875 | 3 | [] | no_license | '''
Created on 24 nov. 2016
@author: Adnene
'''
from cmath import sqrt
import csv
import math
from math import copysign
from csvProcessing import readCSVwithHeader, writeCSVwithHeader
def readCompleteMatrixFromFile(source) : #take into account headers and rowers
matrix=[]
with open(source, "rb") as f:
... | true |
aac751eaee04d4950cfd88fb15bfe90ba9072267 | Python | hariluk-fk/convertGoogleSheetToJson | /CSVToJson.py | UTF-8 | 4,491 | 2.8125 | 3 | [] | no_license | import csv, json, os
def CSVToJson(csvFile):
# Open the CSV
f = open( csvFile, 'r' )
reader = csv.DictReader( f, fieldnames = ( "DocTaxNo","TaxDate","TaxRate","TransNo","RefNo", "CreditTerm",
"TaxNo", "CompanyName", "Branch", "Address1", "Address2", "Address3", "DeliveryName", "DeliveryAddres... | true |
ce52420181d482d8ffb1548b88863e85fae95116 | Python | jlyang1990/LeetCode | /336. Palindrome Pairs.py | UTF-8 | 1,214 | 3.375 | 3 | [] | no_license | class Solution(object):
def palindromePairs(self, words):
"""
:type words: List[str]
:rtype: List[List[int]]
"""
# O(nk^2) time, where k is the average length of words
dic = {}
result = set() # use set to remove duplicated combinations
for i in range(... | true |
d9cd15acf1b5c49f89ce261c8f36b6a2ba374b04 | Python | jwall3/Python | /QiuboRot | UTF-8 | 5,950 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 12 11:29:31 2020
@author: joe
"""
import numpy as np
import pandas as pd
import math
from scipy.spatial import KDTree
###############################################################################
#FUNCTIONS FROM PAPER
#########################... | true |
7be114610dddbe42aa579514172fc4b9a00fb557 | Python | wang-xiaotian/myCode | /lab11_listsOfLists/complex01.py | UTF-8 | 262 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env python3
list1 = ["cisco_nxos", "arista_eos", "cisco_ios"]
print(list1)
print(list1[1])
list2 = ["juniper"]
list1.extend(list2)
print(list1)
list3 = ["10.0.0.1", "10.0.0.2", "10.0.0.3"]
list1.append(list3)
print(list1)
print(list1[4][1])
| true |
75ffeceeb33ced317d44affdf68c01356f1a49e8 | Python | Bannerli/Machine_Learning_Algorithms | /unsupervised_classification/K_means.py | UTF-8 | 2,397 | 3.140625 | 3 | [] | no_license | import numpy as np
import matplotlib.pylab as plt
# 这个类用于设置时间间隔
from matplotlib.pyplot import MultipleLocator
import numpy as np
np.random.seed(46)
def randomPoint(dimension, num):
# 随机生成矩阵,
matrix = np.random.random((num, dimension))
return matrix
def trainProduct(dimension, num):
# 随机生成矩阵,矩阵每个元素扩大10倍
matrix =... | true |
3830ca0d0fcd89792055a9d74e781b68555abcbe | Python | addycakes/Project_Euler | /Euler_99.py | UTF-8 | 1,012 | 3.796875 | 4 | [] | no_license | '''
Euler Problem 99
Comparing two numbers written in index form like 211 and 37 is not difficult,
as any calculator would confirm that 211 = 2048 < 37 = 2187.
However, confirming that 632382^518061 > 519432^525806 would be much more difficult,
as both numbers contain over three million digits.
Using base_exp.txt (r... | true |
f3bb9da79066589d8c5d7c43c6e86106024fa75b | Python | Lluisgar16/TFM | /merge_BBDDs.py | UTF-8 | 2,568 | 2.65625 | 3 | [] | no_license | # -*- coding: cp1252 -*-.
import sys
import os,glob
import unicodedata
import openpyxl as xls
def LevenshteinDistance(s1, s2):
if len(s1) < len(s2):
return LevenshteinDistance(s2, s1)
if len(s2) == 0:
return len(s1)
previous_row = range(len(s2) + 1)
for i, c1 in enumerate(s1):
c... | true |
0a90346924b184edfd3a0f5d9e5f69a6b79cd9c7 | Python | tonggh220/md_5_nsd_notes | /nsd2003/py01/day04/day04.py | UTF-8 | 132 | 3.484375 | 3 | [] | no_license | s1 = 'Python'
print(list(enumerate(s1)))
for data in enumerate(s1):
print(data)
for i, ch in enumerate(s1):
print(i, ch)
| true |
be010f8ada2be9219004b1749a13df3b66701314 | Python | xamonever/prices | /Prices/moduls/price_csv.py | UTF-8 | 1,343 | 2.53125 | 3 | [] | no_license | import csv
from ..abstruct.abs_price import AbstractPrice
# from .components import *
class CSVLoader(AbstractPrice):
"""docstring for CSVLoader"""
delims = {
'tab': '\t',
'coma': ',',
}
def __init__(self, instruction, ):
self.f_format = 'csv'
self.csv_delimiter = '... | true |
6ae9a53fccc1837f2694e93fe7ff4ed2681fa674 | Python | douangtavanh/python-homework | /factorial.py | UTF-8 | 237 | 3.75 | 4 | [] | no_license | number = int(input("Enter your number: "))
factorial = 1
if (number == 0):
factorial = 1
elif (number < 0):
print("can't calculate")
else:
b = 1
while (b <= number):
factorial *= b
b += 1
print(factorial)
| true |
9f614d76c29115b6f39ad17f17e38374bf257ab0 | Python | s-pedamallu/Games | /PokemonHangman/NewCode/pokemonhangman.py | UTF-8 | 402 | 2.6875 | 3 | [] | no_license | import welcome
import pygame
import levelshandler
import acknowledgements
class GameDriver:
def run(self):
pygame.init()
home = welcome.WelcomeScreen()
mode = home.get_mode()
game_play = levelshandler.LevelManager(mode)
final_score = game_play.start_levels()
last_screen = acknowledgements.Ga... | true |
7ca64c35186995a565df8a26a3bab11dfc44a57e | Python | Atis0505/pallida-exam-basics | /uniquechars/unique_chars.py | UTF-8 | 724 | 4.59375 | 5 | [] | no_license | # Create a function called `unique_characters` that takes a string as parameter
# and returns a list with the unique letters of the given string
# Create basic unit tests for it with at least 3 different test cases
def unique_characters(input_string):
letters_dict = {}
for letter in input_string:
if le... | true |
2468b5c3f41c49472fffeb1d23bb9f091e7d51c7 | Python | JaeDukSeo/Personal_Daily_NeuralNetwork_Practice | /000000_interview/d.py | UTF-8 | 1,375 | 3.390625 | 3 | [] | no_license | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# 1.
df = pd.read_csv("SampleCSVFile_11kb.csv",encoding="latin1")
added = df.ix[:,0] + np.random.randn(99)* 20.5
print("Original Mean :",df.ix[:,0].mean())
print("Original std :",df.ix[:,0].std())
print("Original var :",df.ix[:,0].var())
print('=... | true |
67f66792380a88a210a1968197ee6b66edf386ea | Python | dlemusg/AnalisisNumerico | /tareas/7/valoresPropios.py | UTF-8 | 2,674 | 3.453125 | 3 | [] | no_license | from tabulate import tabulate
import sys
from sympy import *
import numpy as np
x = Symbol('x')
def recolectarDatos():
n = int(input("Ingrese la dimension de la matriz, es decir, el valor de n: "))
A = []
for i in range(n):
A.append([0] * (n))
fila = str(input("Ingrese los... | true |
5d1317e5f25ce619a590eb781cb9237f6b1f91a5 | Python | Inflearn-everyday/study | /wookiist/python/10816.py | UTF-8 | 361 | 2.921875 | 3 | [] | no_license | import sys; input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
Amap = dict()
for i in A:
if Amap.get(i) is None:
Amap[i] = 1
else:
Amap[i] += 1
M = int(input())
B = [int(x) for x in input().split()]
for i in B:
if Amap.get(i) is None:
print(0, end=" ")
... | true |
7e69debdefbfb873b95aad410d4f17fc53ec97ca | Python | sspeng/python_note | /0004.py | UTF-8 | 558 | 3.421875 | 3 | [] | no_license | #! /usr/bin/python3
import sys
import re
def count_word(file):
word_count = {}
with open(file) as f:
for line in f:
words = re.split(r'[ \,\.\?\!\;\"\'\[\]\{\}\<\>\(\)]', line)
for word in words:
if word in word_count.keys():
word_count[word]... | true |
b6d9f647223749f4fe2df5301891aab5023162c7 | Python | alanguan100/tweetanalysis | /main.py | UTF-8 | 1,429 | 3.75 | 4 | [] | no_license | #Alan Guan Code
from sentiment_analysis import *
#program inputs
keyword = input("Please enter name of file with Tweet Keywords: ") #keywords with list of words and respective sentiment
tweet = input("Please enter name of file with tweets: ")
# variable to store tweet computation output
final_result = compute_tweets(... | true |
8d52376556e1a139b6c59f3d065f97317e4e996c | Python | 0xtinyuk/LeetCode | /Algorithms/556. Next Greater Element III.py | UTF-8 | 565 | 2.8125 | 3 | [] | no_license | class Solution:
def nextGreaterElement(self, n: int) -> int:
s = str(n)
for i in range(len(s)-2,-1,-1):
if s[i]<s[i+1]:
candidate = i+1
for j in range(i+2,len(s)):
if s[j]<s[candidate] and s[j]>s[i]:
candidate = ... | true |