blob_id large_string | repo_name large_string | path large_string | src_encoding large_string | length_bytes int64 | score float64 | int_score int64 | detected_licenses large list | license_type large_string | text string | download_success bool |
|---|---|---|---|---|---|---|---|---|---|---|
e83f162fcddd9001fb46afd8c499c760d3f60b85 | 0scarg/BigTechCompanyGrowth | /AllStats.py | UTF-8 | 696 | 2.890625 | 3 | [] | no_license | #Run this to see all companies' yearly revenue.
#All info comes from macrotrends.com
import pandas
AMZN = "Amazondata.csv"
Amazon = pandas.read_csv(AMZN)
print("")
print("Yearly revenue for Amazon:")
print(Amazon)
APPL = "Appledata.csv"
Apple = pandas.read_csv(APPL)
print("")
print("Yearly revenue for Apple:")
print(... | true |
0a647338ac1eafe14dd8b15604295acd1d89ed02 | alexander-zou/pycheats | /pyps/use_json.py | UTF-8 | 504 | 3.109375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@File : use_json.py
@Author : alexander.here@gmail.com
@Date : 2020-04-13 11:47 CST(+0800)
@Brief :
'''
import json
data = {
'STR': 'this is a string',
'integer': 123,
'float': 456.789,
'boolean' : True,
'list' : [ i for i in range( 1... | true |
323b2ae98b7a5bf1ad674869082b3c8f9bc1b041 | Davied-H/Auto_Promotion | /src/modules/db.py | UTF-8 | 1,869 | 2.671875 | 3 | [] | no_license | from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey # 区分大小写
from sqlalchemy.orm import sessionmaker
import configparser
cf = configparser.ConfigParser()
cf.read("conf/app.config")
# 创建连接
db_path = 'sqlite:///data/{}'.f... | true |
50c6378fd6138333b4659fd645c042bac11f3cfb | jeanpaulmactal/CS5001-Project | /function_password.py | UTF-8 | 1,182 | 4.25 | 4 | [] | no_license | def password():
password = input("\nEnter your password: ")
MINIMUM_LENGTH = 8
while len(password) < MINIMUM_LENGTH or password.isalpha() == True or password.isdecimal() == True:
'''Checks that the password length is at least 8 characters long and prompts the user to enter a new password
... | true |
5e9150ae114a8a033b7e4bf61cdb56fe25d02f9a | kopok2/CodeforcesSolutionsPython | /src/1032A/test_cdf_1032A.py | UTF-8 | 950 | 2.578125 | 3 | [
"MIT"
] | permissive | import unittest
from unittest.mock import patch
from cdf_1032A import CodeforcesTask1032ASolution
class TestCDF1032A(unittest.TestCase):
def test_1032A_acceptance_1(self):
mock_input = ['5 2 1 2 2 1 3']
expected = '1'
with patch('builtins.input', side_effect=mock_input):
Solut... | true |
fa8c71eca69a52f5f65804d5c2fb6b820d8d106d | mollyeaton/EvolutionaryPredatorPreyRobots | /projectController.py | UTF-8 | 7,607 | 2.59375 | 3 | [] | no_license | import pyrosim
import matplotlib.pyplot as plt
import numpy
from prey import Prey
from predator import Predator
from preyIndividual import PREY_INDIVIDUAL
from predatorIndividual import PREDATOR_INDIVIDUAL
from preyPopulation import PREY_POPULATION
from predatorPopulation import PREDATOR_POPULATION
from combined im... | true |
56a2f0f257bdc820ea76f5ed70a2c884962f7209 | jimAndTom007/PhySimulation | /basicFuc/basic.py | UTF-8 | 3,188 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@IDE :PyCharm
@Author :Zhang.Jing
@Mail : jing.zhang2020@kingsignal.com
@Date :2020-11-4 10:28
'''
import re
from functools import reduce
import numpy as np
import matplotlib.pyplot as plt
import copy
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcPara... | true |
486699966a3954cf41387d3d13e442d34018593c | wjqmichael/workspace | /leetcode/triangle.py | UTF-8 | 633 | 3.34375 | 3 | [] | no_license | class Solution:
# @param triangle, a list of lists of integers
# @return an integer
def minimumTotal(self, triangle):
if not triangle:
return None
min_sum = [triangle[0][0]]
for row in triangle[1:]:
tmp_min_sum = []
for i, num in enumerate(row):
... | true |
de9c581e8abe810ec8b652a3b6a89b69be7da539 | mbk282/PycharmProjects | /Homework/ok.py | UTF-8 | 2,852 | 3.578125 | 4 | [] | no_license | #fin = open(r"""C:\Users\Max\PycharmProjects\War_and_Peace.txt""")
def dict_inverter(d):
newdict = dict()
for key, value in d.items():
newdict.setdefault(value, []).append(key)
return newdict
def indexer(d):
counter = 0
index_list = []
for k in d:
index_list[counter] = d[k]
... | true |
add0e4543df31c11065c2385c809ef971565fbee | ornlneutronimaging/ImagingReso | /ImagingReso/resonance.py | UTF-8 | 47,805 | 2.765625 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | import json
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ImagingReso import _utilities
import plotly.tools as tls
class Resonance(object):
e_min = 1e-5
e_max = 1e8
stack = {} # compound, thickness, atomic_ratio of each layer with isotopes information
stack_... | true |
6259b7d10a682ac741c2c4bdf9dfc1d3f6a549d0 | electron0zero/MusicSurf | /musicsurf/main.py | UTF-8 | 2,864 | 2.828125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
# -*- coding: utf-8 -*-
'''
This program implements basic search operations using Elastic search API.
INPUT: query (search key), boolean values (filters), search index name
OUTPUT: raw results in JSON form.
'''
from flask import Flask, render_template, request, flash
from forms import QueryForm
impo... | true |
33cd0c3390107ff19812fc27df6368c2699a625a | WeilieChen/data-engineer-interview | /leetcode/python/meeting_rooms.py | UTF-8 | 1,427 | 3.75 | 4 | [] | no_license | """
920. https://www.lintcode.com/problem/920/description
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.
(0,8),(8,10) is not conflict at 8
Example1
Input: intervals = [(0,30),(5,10),(15,20)]
Output: false
Ex... | true |
4798fa32193c6ef7c30cf1d81106e468e0fc1b62 | minalchaudhari5695/PythonTutor | /agecheck.py | UTF-8 | 916 | 3.453125 | 3 | [] | no_license | __author__='minal'
import datetime
class Person:
def __init__(self,name,surname,birthdate,address,telephone,email):
self.name=name
self.surname=surname
self.birthdate=birthdate
self.address=address
self.telephone=telephone
self.email=email
#instance method
def age... | true |
d4de1ea649e8256cd2cd60f4410a370b21a17619 | rwerthman/tlen5410 | /hw1/8_10.py | UTF-8 | 166 | 3.625 | 4 | [] | no_license | '''
Exercise 8.10
'''
def is_palindrome(s):
return s == s[::-1]
def main():
s = 'racecar'
s = 'hello'
s = 'noon'
print is_palindrome(s)
main()
| true |
bd40d8c1d0ed23b28d94e51e478ac700ab12d7ce | YJL33/LeetCode | /current_session/daily_challenge/sort_colors.py | UTF-8 | 486 | 2.921875 | 3 | [] | no_license | from typing import List
import collections
class Solution:
def sortColors(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
nCnt = collections.Counter(nums)
i = 0
while i < nCnt[0]:
nums[i] = 0
i += 1... | true |
d2b8a80174c7de8a8b2b579b1aaa9d8074fac12e | lucascorrea122/Aerodrome_Weather_Conditions | /aerodrome_conditions.py | UTF-8 | 2,190 | 3.265625 | 3 | [
"MIT"
] | permissive | import requests
import time
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
ioc = input("informe o código ICAO que deseja buscar informações: ")
url = url = f"https://www.aisweb.aer.mil.br/?i=aerodromos&codigo={ioc}"
print("Aguarde, informações sendo coletadas!")
option = Option... | true |
947efffd987566bd137cb547f443c1bfff95df04 | recruiterz/code-ladder | /2020-05-04-decode-string/newinh.py | UTF-8 | 873 | 3.03125 | 3 | [] | no_license | class Solution:
def decodeString(self, s: str) -> str:
stack = []
for _s in s:
if _s == ']':
to_repeat = ''
while stack[-1].isalpha():
to_repeat = stack.pop(... | true |
665859f37159c4b5951a49c90d2ffbe2f591a636 | arcruz0/mides | /Empirical_analysis/Analysis/Code/1_tus_first_stage.py | UTF-8 | 11,900 | 2.625 | 3 | [] | no_license | import os, shutil
import pandas as pd
import numpy as np
import statsmodels.formula.api as sm
import matplotlib.pyplot as plt
from scipy.io.idl import readsav
from astropy.table import Table, Column
from copy import deepcopy
#from ggplot import *
#import binscatter
# Umbral AFAM: .22488131 (Mdeo) y .25648... | true |
0ea32994be9721c20d6703d1b45e60ade33161f9 | realpython/materials | /iterate-through-dictionary-python/sort-values-only.py | UTF-8 | 124 | 3.328125 | 3 | [
"MIT"
] | permissive | incomes = {"apple": 5600.00, "orange": 3500.00, "banana": 5000.00}
for value in sorted(incomes.values()):
print(value)
| true |
9ffa3538087e1b00e7d1e9c28f74d5c5e7b6b0d8 | ShivamDubey7/Competitive-Programming-Algos | /Sorting/SelectionSort.py | UTF-8 | 809 | 4.03125 | 4 | [] | no_license | # Selection sort takes n-1 passes to complete
# During every iteration index of minimum number/string is found in the innermost loop and then swapped once it comes out of that loop
# No flag like improvised Bubble Sort so even if we put sorted list it is still going to take O(n^2) time complexity
# Worst Time Complexit... | true |
2af8232cfbe9eecb980b66d03334af5da5dbaed9 | Adarsh08X/TicTacToe | /TicTacToe.py | UTF-8 | 2,746 | 3.765625 | 4 | [] | no_license | import itertools
def win(game):
def equal(l):
if l.count(l[0])==len(l) and l[0]!=0:
return True
else:
return False
#Horizontal
for row in game:
if equal(row):
print(f"Player {row[0]} is the winner!^_^")
return True
#... | true |
3d667bc42e9a4e13bc258193f717f9d53ea002ab | hask777/avpars | /avparser/brands.py | UTF-8 | 969 | 2.8125 | 3 | [] | no_license | import requests
from bs4 import BeautifulSoup
import json
base_url = 'https://av.by/'
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
}
r = requests.get(base_url)
soup = BeautifulSoup(r.content, 'html.parser')... | true |
de88b8f4a14fb4f9fd352327dede2d8d407596e5 | tyranitar/algorithms-i | /assignments/a2/quick_sort.py | UTF-8 | 1,686 | 3.765625 | 4 | [] | no_license | from math import ceil
from random import randint
def swap_in_place(a, i, j):
if a[i] != a[j]:
a[i] = a[i] - a[j]
a[j] = a[j] + a[i]
a[i] = a[j] - a[i]
def find_low(a, lo, hi):
return a[lo], lo
def find_high(a, lo, hi):
return a[hi - 1], hi - 1
def find_median(a, lo... | true |
d876628d6525c8a47d84ea02f1efae02dec28339 | bwproud/Side_Projects | /Python/550ExtraCreditBrennanProudfoot.py | UTF-8 | 2,666 | 3.265625 | 3 | [] | no_license | import functools
#node class to hold predecessor and distance
@functools.total_ordering
class Node:
def __init__(self, index, distance = float("inf"), pred = None):
self.index = index
self.distance = distance
self.pred = pred
def __lt__(self, other):
return self.distance<other.distance
def __eq__(self, oth... | true |
35a7930f1780dc588e40767e5851dd2b6877dee0 | sun5411/myPython | /exercise/test.py | UTF-8 | 744 | 3.03125 | 3 | [] | no_license | #!/usr/bin/python
#coding:utf8
class Ren(object):
name="ren"
high="180cm"
wigth="80kg"
__money="100rmb"
__age="30"
def run(abc):
print abc.name
print "running..."
def say(self):
print self.__money
def get(self,x):
if x == "money":
return s... | true |
771e2c3a4b338dd47d5d1c706752035f2d421295 | Sanyam07/automatic-hyperparameter-tuning | /codes/hyperopt/example/test_hyperopt_sample.py | UTF-8 | 971 | 2.765625 | 3 | [] | no_license | from hyperopt import hp
list_space = [
hp.uniform('a', 0, 1),
hp.loguniform('b', 0, 1)
]
tuple_space = (
hp.uniform('a', 0, 1),
hp.loguniform('b', 0, 1)
)
dict_space = {
'a': hp.uniform('a', 0, 1),
'b': hp.loguniform('b', 0, 1)
}
space = list_space
import hyperopt.pyll.stochastic
print hyperopt... | true |
a523c808b8d76f73b2d57810cd70eac2e73f409d | JinYeJin/algorithm-study | /November,2020~July,2021/2021-03-19/1343_이승민_폴리오미노.py | UTF-8 | 655 | 2.96875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# 폴리오미노
import sys
input = sys.stdin.readline
s = input().strip()
cnt = 0
check = 0
ans = ''
for i in range(len(s)):
if s[i] == 'X':
cnt += 1
check = 0
if i == len(s) - 1:
if cnt % 2 == 1:
print(-1)
quit(0)
else... | true |
c5e4ddeca7d52e39fcac6a77f7a88343ab8f0b7e | rajathithan/tura-labs-bootcamp | /ch1/ep3.py | UTF-8 | 1,425 | 2.734375 | 3 | [] | no_license | import pandas as pd
airport_types = {
"iata":"string",
"airport": "string",
"city":"string",
"state":"string",
"country":"string",
"lat":"float",
"long":"float64"
}
asc_df = pd.read_csv('ASC-airports-raw.csv', delimiter=",", dtype=airport_types)
# asc_df.info()
of_names = ["id", "name", "... | true |
d6c994a6bc4aea03ebf7f28b67beaf31988a23a6 | Adem54/Python-Tutorials | /4.Week-1/python2.py | UTF-8 | 267 | 3.515625 | 4 | [] | no_license | sayi1 = int(input("Bir sayı giriniz"))
if sayi1 < 0:
mutlak_sayi1 = sayi1 * -1
else:
mutlak_sayi1 = sayi1
sayi2 = int(input("Bir sayı giriniz"))
if sayi2 < 0:
mutlak_sayi2 = sayi2 * -1
else:
mutlak_sayi2 = sayi2
print(mutlak_sayi1 + mutlak_sayi2)
| true |
0e1542746d9c2f7efdf2833dd260404968f13245 | OlesyaLi/https-github.com-OlesyaLi-ex | /ex_1.py | UTF-8 | 99 | 3.234375 | 3 | [] | no_license | # Задание 1
a = 1
b = 1
c = a + b
print(c)
a = 8 + 3
b = 11
c = a + b
print(c)
| true |
46426ee0eec07d2905e16dead0fdb9f10e15be88 | ParulProgrammingHub/assignment-1-gaganlotey | /q7.py | UTF-8 | 232 | 4.1875 | 4 | [] | no_license | #PROGRAM TO ENTER 2 ANGLES AND FIND THIRD ANGLE
def thirdangle(angle1,angle2):
v3=180-(angle1+angle2)
print("Third angle ",v3)
v1=int(input("Enter the angle 1 "))
v2=int(input("Enter the angle 2 "))
thirdangle(v1,v2)
| true |
1a3a37d23c0d96b801952c09cdedb03c7005bd4f | AdityaMV1215/logistic_regression_project | /q02_data_cleaning_all/build.py | UTF-8 | 1,268 | 2.625 | 3 | [] | no_license | # %load q02_data_cleaning_all/build.py
# Default Imports
import sys, os
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from logistic_regression_project.q01_outlier_removal.build import outlier_remov... | true |
77e1799e83422e6b6eec190965201b8c7012014d | Steph-harris/py_exercises | /ex50/problem_sets/pb1.py | UTF-8 | 823 | 3.6875 | 4 | [] | no_license | def getVals():
annual_salary = float(input("What is your annual salary?"))
sal_pct = float(input("Salary Percentage to Save (as a decimal): "))
total_cost = float(input("Total home cost: "))
r = .04
portion_saved = 0
months = 0
portion_down_payment = .25
down_pymt_amt = total_cost * port... | true |
ad33b291e9353da21092371f5458c0fe8583babb | Isaiah186/Even-numbers-example | /Even number example.py | UTF-8 | 318 | 3.671875 | 4 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[6]:
list2 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
print(list2)
# In[7]:
for x in list2:
if x%2==0:
print(x)
# In[8]:
for y in list2:
if y%3==0:
print(y)
# In[10]:
for y in list2:
if y%5==0:
print(y)
# In[ ]:
| true |
cac69856a9bd447837fb34cbe161bf104dd35e2f | Choojj/acmicpc | /단계별/25. 우선순위 큐/02. 최소 힙.py | UTF-8 | 1,453 | 3.0625 | 3 | [] | no_license | import sys
N = int(sys.stdin.readline())
heap = []
for _ in range(N):
x = int(sys.stdin.readline())
if (x == 0):
if (heap):
# delete
print(heap[0])
heap[0], heap[-1] = heap[-1], heap[0]
heap.pop()
i = lower = count = 0
while (l... | true |
670555cbee2b2c885bf53213193dbe2c4f60bb33 | PPL-IIITA/ppl-assignment-JayeshChaudhari17897 | /Q8/q3_girl.py | UTF-8 | 567 | 2.53125 | 3 | [] | no_license | from q3_gift import gift
from abc import ABCMeta , abstractmethod
class girl(object):
_metaclass_ = ABCMeta
def __init__(self , name = None , attractiveness = None , intelligence = None , budget = None):
self.name = name
self.attractiveness = attractiveness
self.maintenance = budget
self.intelligenc... | true |
e059f6a47e79baf19088b87e8434420e221c35a2 | X3eRo0/my_aweful_emu | /assembler.py | UTF-8 | 1,867 | 2.703125 | 3 | [] | no_license | import sys
import struct
opcodes = {
"ADD" : {
"A" : 0x87,
"B" : 0x80
},
"SUB" : {
"A" : 0x97,
"B" : 0x90
},
"MVI" : {
"A" : 0x3e,
"B" : 0x06,
"E" : 0x0E,
"D" : 0x16,
"H" : 0x26
},
"PUSH" : {
"B" : 0xC5,
... | true |
7d4132377142d299b0e0c7828ba753484b6785a2 | mejialvarez/google_search_clone | /crawler_service/producer.py | UTF-8 | 862 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env python
import os
import time
import pika
class Producer:
def __init__(self, queue):
self.queue = queue
self.connection = None
def publish(self, body):
try:
time.sleep(5)
self.set_connection()
channel = self.connection.channel()
channel.queue_declare(queue=self.qu... | true |
f65b2fed50c05b3a941429afc056ecf5a71e78c2 | jhfu/Shanghai-Subway-Visualization | /Data Processing/historical/bj_ori.py | UTF-8 | 7,105 | 2.75 | 3 | [] | no_license | # coding: utf-8
def build_subway(**lines):
"""
Input is build_subway(linename='station1 station2...'...)
Ouput is a dictionary like {station:{neighbor1:line number,neighbor2:line number,...},station2:{...},...}
"""
for key in lines.keys():
value = lines[key]
lines[key] = value.split(... | true |
93c61828bc2966ea02b8630e40e5f8960e8dc6f0 | epw/pointclick | /getsession.py | UTF-8 | 633 | 3.203125 | 3 | [] | no_license | #! /usr/bin/env python
"""Handle simple sessions stored as pickle objects in a directory, indexed
by arbituary IDs (usually timestamps)"""
import pickle, os
session_path = "sessions/"
EXN = ".pkl"
def get (session):
"""Return object stored with session, or empty dict if none found."""
if os.path.exists (se... | true |
0a76925caef7a0291f530e7719484e6318a34909 | chihsuan/relationships-reconstruction | /modules/scene_change_detection.py | UTF-8 | 1,687 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
import sys
import cv2
def scene_change_detection():
if len(sys.argv) < 2:
print "Error - file name must be specified as first argument."
return
cap = cv2.VideoCapture()
cap.open(sys.argv[1])
if not cap.isOpened():
print "Fata... | true |
8d20a44841263e8f939f92dcf87cec4f95aea411 | mt-andrea/py | /2021.01.20/mateandrea1.py | UTF-8 | 503 | 3.53125 | 4 | [] | no_license | print("a - Bukarest\nb - Prága\nc - Budapest\nd - Pozsony\nKérem a helyes válasz betűjelét!")
valasz1=input("\tMagyarország főbárosa: ")
valasz2=input("\tCsehország fővárosa: ")
if valasz1=="c" and valasz2=="b":
print("\tJó megoldás!")
elif valasz1!="c" and valasz2!="b":
print("\tMagyarország fővárosa hibás!\n\... | true |
ad7dcc4744ec22bc096894a4d8289f0f924604d5 | FluffyFu/Leetcode | /350_intersection_of_two_arrays_2/solution.py | UTF-8 | 465 | 3.203125 | 3 | [] | no_license | from collections import Counter
class Solution:
def intersect(self, nums1, nums2):
counter = Counter(nums2)
res = []
for num in nums1:
if num in counter and counter[num] > 0:
res.append(num)
counter[num] -= 1
return res
"""
nums1 = [1,... | true |
1f38a2b1a7cd947a0cbec1561d0ef3db73170e57 | frozencure-test/heroku-test | /mysite/recommender/processor.py | UTF-8 | 1,048 | 2.640625 | 3 | [] | no_license | from django.apps import apps
from urllib.parse import urlparse as parse
from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
import os.path
def getTopQuestions(question_id, top=5):
recommender_config = apps.get_app_config('recommender')
sparseDf = recommender_con... | true |
ac8d5453df8f82c1509cd3c1559a07a26b8bd207 | Stanzione/Node_plus_python | /src/python_script/script.py | UTF-8 | 160 | 2.890625 | 3 | [] | no_license | import sys
a = round(float(sys.argv[1]))
b = round(float(sys.argv[2]))
def teste (x,y):
c = (x ** y)
print(a,b,c)
teste(a,b)
sys.stdout.flush() | true |
5423944423e7b88298b3b1ea6cfefde0e028c724 | rhzx3519/leetcode | /python/97. Interleaving String.py | UTF-8 | 919 | 3.21875 | 3 | [] | no_license | class Solution(object):
def isInterleave(self, s1, s2, s3):
"""
:type s1: str
:type s2: str
:type s3: str
:rtype: bool
"""
n1, n2, n3 = len(s1), len(s2), len(s3)
if n1+n2!=n3: return False
dp = [[False]*(n2+1) for _ in range(n1+1)]
dp[0... | true |
b92c3a4c946fedb037604f55890d461d31284706 | yemao616/CSC591-791 | /pomdp/Iohmm_ghmm4.py | UTF-8 | 19,618 | 2.6875 | 3 | [] | no_license | import sys
import numpy as np
import scipy.stats
# this is the version using mpmath
# this code is the log version. alpha denotes the log of real alpha.
# multivariate gaussian HMM
# scaled version
class Iohmm_ghmm4:
def __init__(self, outputs=None, Nseq=0, Ns=2, Nx=2, Dy=1, max_iter=1, cov_type='full', scale=Tru... | true |
61c813018ec1f2f8f56a9769fd584683ba44caa9 | charlesartbr/hackerrank-python | /30-days-of-code/day-2-operators/python3-oneliner.py | UTF-8 | 72 | 2.765625 | 3 | [] | no_license | print(round(float(input()) * (1 + (int(input()) + int(input())) / 100))) | true |
155149f1705081bed05bf0c68608180c2d9ea70f | julianhatwell/Py_Basics | /strings_ex_1.py | UTF-8 | 120 | 2.515625 | 3 | [] | no_license | text = "X-DSPAM-Confidence: 0.8475";
opos = text.find("0")
epos = len(text)
flo = float(text[opos:epos+1])
print(flo) | true |
031432b51826fee1f03ca921947479e73311b01b | benblack769/ptb_game_solver | /envs/surround/surround.py | UTF-8 | 4,893 | 3.25 | 3 | [] | no_license | '''
A Partially observable version of the old atari surround game
'''
import numpy as np
from ..basic_env import BasicEnv
from gym.spaces import Discrete,Box
EMPTY = 0
FULL = 1
def action_to_dir(action,olddir,player):
if action == 0:
return olddir
else:
if action == 1:
dir = (-1,0... | true |
dfa2994c05b023424a1975259affa43239baea90 | auliawiguna/sabtuceria | /decision_tree.py | UTF-8 | 1,156 | 2.671875 | 3 | [] | no_license | __author__ = 'ahmadauliawiguna'
import numpy as np
import os #import library untuk akses fitur OS
import graphviz
from sklearn import tree
cwd = os.getcwd()
raw_data = cwd + "/dataset/heart.csv"
dataset = np.loadtxt(raw_data, delimiter=",",dtype=None)
jumlah_baris = dataset.shape[0]
jumlah_kolom= dataset.shape[1]
#
... | true |
d244ead4b122c615c751667929a2d54143a27084 | TudosaEduard/block-cryptosystems | /main.py | UTF-8 | 3,936 | 2.578125 | 3 | [] | no_license | import random
import string
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
# Node MC implementation
key_length = 128
# Generate keys randomly for encrypting and decrypting keys
K = str.encode(''.join(random.choices(string.ascii_letters + string.digits + string.punctuation, k=key_length //... | true |
21b8186158a112c5363fbff47ca758d91d4fffbd | SCiarella/hoomd-blue | /hoomd/hpmc/util.py | UTF-8 | 39,196 | 2.890625 | 3 | [
"BSD-3-Clause"
] | permissive | # Copyright (c) 2009-2019 The Regents of the University of Michigan
# This file is part of the HOOMD-blue project, released under the BSD 3-Clause License.
R""" HPMC utilities
"""
from __future__ import print_function
from __future__ import division
# If numpy is unavailable, some utilities will not work
try:
imp... | true |
4458cdc969f717e1425d8f4bdd3b504222d4c01f | chrishaig14/aspl | /parser.py | UTF-8 | 5,706 | 3.1875 | 3 | [] | no_license | from colorama import Fore, Back, Style
class Parser:
def __init__(self, scanner):
self.scanner = scanner
self.current_token = ""
self.previous_token = None
def parse_assign_exp(self):
# assignment => id = expression
lvalue = self.parse_expression()
if self.mat... | true |
04c4e71efbced964498deab23bb45a095dd139f9 | swlew369/Bioinformatics_Stuff | /virus5.py | UTF-8 | 6,028 | 3.515625 | 4 | [] | no_license | #!/usr/bin/env python
# For Coursera DNA Sequencing course final project
# where you reconstruct a virus sequence
import bisect
from itertools import permutations,combinations
def readFastq(filename):
sequences = []
qualities = []
with open(filename) as fh:
while True:
fh.readline() ... | true |
79afbb8a1e735b8081fc2b1f10bdd5195452684e | BoatInTheRiver/codes_algorithm | /leetcode/Dynamic_programming/1155. 掷骰子的N种方法.py | UTF-8 | 802 | 3.3125 | 3 | [] | no_license | #coding:utf-8
'''
这里有 d 个一样的骰子,每个骰子上都有 f 个面,分别标号为 1, 2, ..., f。
我们约定:掷骰子的得到总点数为各骰子面朝上的数字的总和。
如果需要掷出的总点数为 target,请你计算出有多少种不同的组合情况(所有的组合情况总共有 f^d 种),模 10^9 + 7 后返回。
'''
class Solution:
def numRollsToTarget(self, d, f, target):
dp = [[0] * (target + 1) for _ in range(d + 1)]
for i in range(1, min(f,... | true |
ac2576bf3991e573ef2caab24e51607edae6cd76 | drugotosto/RS_CF_ItemBased_Spark | /main.py | UTF-8 | 6,466 | 2.65625 | 3 | [] | no_license | __author__ = 'maury'
import os
import time
import numpy as np
import pandas as pd
from numpy.random import choice
from conf.confRS import nFolds, typeRecommender, numTags
from conf.confDirFiles import datasetJSON, dirPathOutput, dirPathInput, dirTrain, dirTest, dirFolds
from conf.confItemBased import typeSimilarity,... | true |
7541efd9797cfdda57d4db11a75c91424ce2265b | aernesto/Data_IO_Clicks_Project | /create_db.py | UTF-8 | 5,848 | 3.046875 | 3 | [
"MIT"
] | permissive | """
The aim of this script is to create a database in hdf5 format
"""
# import copy
import time
import sys
from official_fcns import *
def create_hfd5_data_structure(hdf5file, groupname, num_trials, num_samples, max_trials=1000000):
"""
:param hdf5file: h5py.File
:param groupname:
:param num_trials: ... | true |
08e4b2122f0ec525cd6a1291a7723b7f4b991c18 | anay-jain/Python-NLP | /grammar_lib.py | UTF-8 | 2,696 | 3.5 | 4 | [] | no_license | from collections import Counter
import re as regex
ALPHABETS = "abcdefghijklmnopqrstuvwxyz"
FILE = "data.txt"
'''
mail to
sachinsingh31@outlook.com
'''
# function to extract all the words from the big file
def get_words_from_file(file):
# getting the contents of the file
file_content = open(file).read()
# extrac... | true |
bea00d0185642945d5f42ac77c8bf42c2f0c0649 | AnindoTonoy/python-practice-with-exercises | /exercise 8 - oh soldier prettify my folder.py | UTF-8 | 652 | 3.28125 | 3 | [] | no_license | import os
def soldier(path, file_name, file_extension):
os.chdir(path)
with open(file_name) as f:
text = f.read().split("\n")
# print(text)
# print(os.listdir())
i = 1
for item in os.listdir():
if item not in text:
os.rename(item, item.capitalize())
if i... | true |
81742d7d0f067942d1d4407fbe40826185066de7 | Aasthaengg/IBMdataset | /Python_codes/p03427/s641360048.py | UTF-8 | 257 | 2.6875 | 3 | [] | no_license | n = input()
ans = 0
for i in range(len(n)):
tmp = [9]*len(n)
for j in range(9, -1, -1):
tmp[i] = j
s = int(''.join(map(str, tmp)))
if s <= int(n):
ans = max(ans, sum(map(int, str(s))))
break
print(ans) | true |
08bc2ff387aa69ab771351e76a2dd8effb10cb53 | tabha/hop | /simulation.py | UTF-8 | 5,571 | 2.53125 | 3 | [] | no_license | import simpy
import random
import json
from sympy.stats import Normal, sample_iter
data ={}
class TI(object):
"""
this class represent a technical issue
"""
def __init__(self, ti_obj):
self.name = ti_obj["name"] # example : mechanical structural damage
self.weight = ti_obj["weight"] # 0... | true |
09d66ae9b8b16b01d533b515bb57a2a608ae7474 | rheiland/biovis2014 | /showMatrixThresh.py | UTF-8 | 374 | 2.59375 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
fname = '1X4I9DF0_adjacency_matrix_pcc.txt'
try:
A = np.genfromtxt(fname, delimiter='\t')
except:
print("Error opening " + fname)
threshold = input ('Enter threshold: ')
cutoff = A < threshold
A[cutoff] = 0
plt.imshow(A, interpolation='nearest')
plt.colorbar(ori... | true |
db6a3cacef9393e715489508216cb6a11b808478 | Alex-ZhaoR/python-for-analysis | /usa.gov.py | UTF-8 | 2,303 | 3.34375 | 3 | [] | no_license | import json
from collections import defaultdict
path = r'E:\数据分析\pydata-book-master\ch02\usagov_bitly_data2012-03-16-1331923249.txt'
o = open(path)
records = [json.loads(line) for line in o]
# print(records[0])
# print(type(records[0]))
#用python代码对列表中的值进行计数
time_zone = [rec['tz'] for rec in records if 'tz' ... | true |
2a74a6d5f3c3b03c6adc78066c25a552c1f7a7fb | jdevries3133/nicks_birthday_2021 | /birthday_puzzle/mail/riddles/riddle_three.py | UTF-8 | 1,553 | 3.03125 | 3 | [] | no_license | from pathlib import Path
from typing import Union
from .base import RiddleBase
class RiddleThree(RiddleBase):
"""
One day, Nick decides that he's hungry for a snack. He collects the
following ingredients:
1. All-purpose flour
2. Baking powder
3. Granulated sugar
4. Salt
5. Unsalted b... | true |
4196366fadf3b3b6b8b82b7c0bc745e980f57414 | bejiol/TFM | /dateTimePicker.py | UTF-8 | 3,293 | 2.65625 | 3 | [] | no_license | import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import datetime
tm = ""
dt = QDate.currentDate()
tmfin = ""
dtfin = QDate.currentDate()
class EventDetailsPicker(QWidget):
def __init__(self):
super(EventDetailsPicker, self).__init__()
self.initUI()
... | true |
45dd5b702908e80b305493a4dcc504e6d432cbe3 | Eshchock1/Competitive-Programming | /DMPG'18B2-MimiandModulus.py | UTF-8 | 147 | 2.875 | 3 | [] | no_license | numsInput = input().split(" ")
nums = list(map(int, numsInput))
A = nums[0]
B = nums[1]
max = 0
if A >= B - 1:
print(B-1)
else:
print(A) | true |
dc7fd2397306184f5f4def01022a6be608973a35 | imanaghili/interactive-tutorials | /main.py | UTF-8 | 5,618 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | from flask import Flask, render_template, request, url_for, make_response
import json
import constants
import re
import markdown
import os
import cgi
import urllib
app = Flask(__name__)
sections = re.compile(r"Tutorial\n[=\-]+\n+(.*)\n*Tutorial Code\n[=\-]+\n+(.*)\n*Expected Output\n[=\-]+\n+(.*)\n*", re.MULTILINE | ... | true |
814a70ef3597c9e853722ff956f9e6de5ddee67a | afspies/SGEjobScripts | /addLog.py | UTF-8 | 948 | 2.765625 | 3 | [] | no_license | """ Python script to create a log of batch submission
By Alex Spies
"""
import datetime as dt
import sys
import os
import pwd
# Create string to be written
logEntry = "------------------------------------------------------\n"
try:
logEntry += "Job name: " + sys.argv[1] + "\n"
except IndexError:
print("E... | true |
01a2dc0f758c4f08616a6931fd2a80fa352e6e2f | asdf2014/algorithm | /Codes/GinRyan/LeetCode/Python-3-Solves/9_palindrome_number.py | UTF-8 | 1,255 | 4.3125 | 4 | [
"Apache-2.0"
] | permissive | """
判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。
示例 1:
输入: 121
输出: true
示例 2:
输入: -121
输出: false
解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。
示例 3:
输入: 10
输出: false
解释: 从右向左读, 为 01 。因此它不是一个回文数。
进阶:
你能不将整数转为字符串来解决这个问题吗?
"""
"""
解题思路:
还是转换成字符串简单一点。
头尾对称方式找i对应的位置len - i - 1 ,看是否相同,
当一次循环下来找到不同值的那么这个数就不是回文数。
""... | true |
19ec5dc62f931a8a529cde2847a866ce93ce2166 | peopleticker/jeev-modules | /modules/geocode.py | UTF-8 | 957 | 2.578125 | 3 | [] | no_license | from jeev.message import Attachment
from jeev.utils.importing import import_dotted_path
import module
module.opt(
'using',
'The geopy geocoder (or similar interface) to use.',
default='geopy.geocoders.Nominatim')
@module.opt_validator('using')
def validate_is_geocoder(name):
try:
module = imp... | true |
b80f04fb9b712e5d312be53e92dc6f56d497c7a5 | dykim822/Python | /ch07/user1.py | UTF-8 | 588 | 3.53125 | 4 | [] | no_license | class User:
pass
user1 = User()
user2 = User()
user3 = User()
print(type(user1))
print(type(user2))
print(user1 == user2) # 각각의 인스턴스이므로 당연히 다르다
user1.name = "영희"; user1.age = 20; user1.email = "young@korea.kr"
user2.name = "철수"; user2.age = 45; user2.email = "chul@korea.kr"
user3.name = "길동"; user3.age = 25; ... | true |
ccc6bfd6569a55f0708c9083a3b7928d794240f0 | wreck-count/Fast-Simple-Polygon-Triangulation | /src/make_simple_polygon.py | UTF-8 | 864 | 2.890625 | 3 | [
"MIT"
] | permissive | import geopandas as gpd
from shapely.geometry import Polygon
lat_point_list = [50.854457, 52.518172, 50.072651, 48.853033, 50.854457]
lon_point_list = [4.377184, 13.407759, 14.435935, 2.349553, 4.377184]
polygon_geom = Polygon(zip(lon_point_list, lat_point_list))
crs = {'init': 'epsg:4326'}
polygon = gpd.GeoDataFrame... | true |
e8ba773233bfb905fc68805497b901c57ec17ffc | build3r/programming-contest | /Facbook Hacker Cup/2012/Qualification/Alphabet Soup/alphabet_soup.py | UTF-8 | 335 | 3.0625 | 3 | [] | no_license | import sys
T = int(sys.stdin.readline())
for t in xrange(1, T+1):
count = {' ' : 0}
for c in xrange(ord('A'), ord('Z')+1):
count[chr(c)] = 0
line = sys.stdin.readline().strip()
for c in line:
count[c] += 1
count['C'] /= 2
print "Case #%d: %d" % (t, min(map(lambda c: count[c], "... | true |
d210772b9c56c5280abf59953bc011ec651780e3 | ananthapadmanabhans/Programming-Lab | /CO1/3c.py | UTF-8 | 86 | 3.109375 | 3 | [] | no_license | a="Hello World"
print(a)
l=["a","e","i","o","u"]
n=[v for v in l if v in a]
print(n)
| true |
d58a99b82db9e048753e3e4ef49a70811a6172bf | hitesh-goel/ds-algo | /grokking-tci/13_k_elements/connect_ropes.py | UTF-8 | 1,143 | 4.09375 | 4 | [] | no_license | # Given ‘N’ ropes with different lengths, we need to connect these ropes into one big rope with minimum cost.
# The cost of connecting two ropes is equal to the sum of their lengths.
#
# Example 1:
#
# Input: [1, 3, 11, 5]
# Output: 33
# Explanation: First connect 1+3(=4), then 4+5(=9), and then 9+11(=20). So the total... | true |
420d63c5a0ddb706ff3eb59789c7e92f2f071403 | wangvei/matplotlib-3d | /elevation.py | UTF-8 | 2,799 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | # -----------------------------------------------------------------------------
# Copyright (c) 2020 Nicolas P. Rougier. All rights reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
# This example shows how to display a mesh
# ----------... | true |
0557fd59a04ff039741628789c3a36fc4f3f4835 | sizijay/python | /test.py | UTF-8 | 379 | 4.0625 | 4 | [] | no_license | print("Ex: 1/2 , 1/4 , 1/10")
fraction=input("Enter the fraction of apples gave away: ")
frac=int(fraction[2]) #convert fraction input to a integer
person=int(input("Enter the no. of people that gave apples away: "))
rem=int(input("Enter the remainig no. of apple: "))
while person!=0:
rem=frac*(rem+1)
... | true |
7f9c446b2f582ba9925fe17c5c2213aa5fdda691 | gokulvasan/CapacityShifting | /ss_list.py | UTF-8 | 3,180 | 3.3125 | 3 | [] | no_license |
class list_node:
def __init__(self, data, nxt, prev):
self.data = data
self.nxt = nxt
self.prev = prev
def get_nxt(self):
return self.nxt
def get_prev(self):
return self.prev
def get_data(self):
return self.data
def set_prev(self, prev):
self.prev = prev
def set_nxt(self, nxt):
self.nxt = nxt
d... | true |
00da155daca1cd2f16246c1430ccc15ee92d8adf | MSU-NEU-ATL/DFTND | /FSGAN/fsgan/preprocess/produce_masks.py | UTF-8 | 1,930 | 2.625 | 3 | [] | no_license | import os
import shutil
from glob import glob
from tqdm import tqdm
import numpy as np
import cv2
from PIL import Image
def main(root_dir, out_dir, rel_dir=None, min_ratio=0.1):
in_dir = root_dir if rel_dir is None else os.path.join(root_dir, rel_dir)
seg_files = []
# For each sub-directory in the input ... | true |
c337603c55beb27ac046b743e046c43d53cced3a | udayhegde07/PycharmProjects | /OOP/transpose.py | UTF-8 | 163 | 3.46875 | 3 | [] | no_license | m = [(1,2,3),(4,5,6)]
for row in m:
print(row)
tm = zip(*m)
for row in tm:
print(row)
m = [7,8,9]
tm =[10,11,12]
for i,j in zip(m,tm):
print(i," ",j) | true |
160aaf4f276dedbf5414d45dc6765cd113f3382e | brickgao/leetcode | /src/algorithms/python/Majority_Element_II.py | UTF-8 | 987 | 3.296875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
class Solution:
# @param {integer[]} nums
# @return {integer[]}
def majorityElement(self, nums):
if nums == []:
return []
num1, num2 = -0xffffffff, -0xffffffff
cnt1, cnt2 = 0, 0
for num in nums:
if cnt1 == 0 or num1 == num:
... | true |
cf4896cd2ab212b752134244d85b03d01c3decf2 | SnowSuo/python | /doubanmovieTop250/pipelines2mysql.py | UTF-8 | 1,477 | 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: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import pymysql
class DoubanmoivePipeline(object):
def process_item(self, item, spider):
dbserverIp='localhos... | true |
8bd135492d6a4de5ecc69541ced1b702e490ab33 | theochiu/datetrix | /convert.py | UTF-8 | 2,546 | 3.15625 | 3 | [
"MIT"
] | permissive | import pandas as pd
from pprint import pprint
import sys
def read_spreadsheet(path):
df = pd.read_excel(path)
# with pd.option_context('display.max_rows', None, 'display.max_columns', None):
# print(df)
heading = list(df.columns)
matrix = df.values.tolist()
matrix.insert(0, heading)
return matrix
def find_ind... | true |
91ad69eb616dbc118aeb0c28f058287f04b29e4f | Yonahel/Spyndra | /spyndra/include/spyndra/standingGait.py | UTF-8 | 1,960 | 2.765625 | 3 | [
"MIT"
] | permissive |
import math
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
#points array of values from 0-1 (to be mapped)
#All femurs 400 except 4 which is 370
#All tibia 450
def spline_gen(points_femur, points_tibia, period, cycles):
freq=60
y_femur=np.array(points_femu... | true |
8bbd74c954183fb88f8540d539d3b02d85c57530 | nuhnuh/raster_server | /shp2tif.py | UTF-8 | 1,235 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env python3
"""
Convert an OGR File to a Raster
Tip: open the resulting .tif file with gimp
"""
from osgeo import gdal, ogr
# Define pixel_size and NoData value of new raster
# pixel_size = 25
pixel_size = 1
pixel_size = .25
NoData_value = -9999
# Filename of input OGR file
vector_fn = 'test.shp'
vec... | true |
78c6158e2efce3cd1d8aca09bed8eaa8954094d0 | wanchai-saetang/meme-generator | /src/QuoteEngine/TXTIngestor.py | UTF-8 | 1,054 | 3.171875 | 3 | [] | no_license | """Read text file and extract body and author content from each line."""
from typing import List
from .IngestorInterface import IngestorInterface
from .QuoteModel import QuoteModel
class TXTIngestor(IngestorInterface):
"""Class for validate extension and a parse text file."""
allowed_extensions = ["txt"]
... | true |
5f0f06a88ed13ff447815bfff00bb6f12829139f | LBJ-Wade/hierarc_SGL | /hierarc/Likelihood/LensLikelihood/td_mag_likelihood.py | UTF-8 | 4,553 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | import numpy as np
from lenstronomy.Util import constants as const
from lenstronomy.Util.data_util import magnitude2cps
class TDMagLikelihood(object):
"""
likelihood of time delays and magnification likelihood
This likelihood uses linear flux units and linear lensing magnifications.
"""
def __in... | true |
667a82fed276c4d7906b247fdd34b8af6364f977 | Zanzan666/2017A2CS | /Ch23/queue.py | UTF-8 | 1,357 | 3.203125 | 3 | [] | no_license | #Jenny Zhan Option3
np=-1
class QueueNode:
def __init__(self):
self.value=''
self.nextP=np
class Queue:
def __init__(self,length):
self.sp=np
self.fp=0
self.ep=np
self.records=[]
for i in range(length):
newNode=QueueNode()
newNode.... | true |
0af3c4ebed4d9ecefbea26c51e032ea84733236b | Shamim-38/Eye-Detection-Using-Retinal-Data | /src/eye_classification_model.py | UTF-8 | 1,728 | 2.921875 | 3 | [] | no_license | """Our TeaNet for diabetic retinopathy eye classification task"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# python moduels
import os
from keras import layers, Input, Model, backend
from keras.layers import Dense, ZeroPadding2D, Conv2D, MaxPooling2D,... | true |
d3bf1cfee73636f64fdb22cb050ce9d59e56e961 | eragond/Proyectos-Criptografia | /Proyecto1/hill/mats.py | UTF-8 | 451 | 3.171875 | 3 | [] | no_license | import sys
palabrasr = []
alfabeto = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
with open(sys.argv[1]) as txt:
for i in txt:
for j in i.split():
palabrasr.append(j)
for p in range(0, len(palabrasr), 2):
print(palabrasr[p], end=' ')
print(palabrasr[p+1], end=' ')
for i in palabrasr[p]:
p... | true |
5cc1d0d5680671885a238058623bf7ed2e5640be | suprajaarthi/Chatbot-for-Kidney-disease | /no_pattern.py | UTF-8 | 140 | 2.96875 | 3 | [] | no_license | import re
string = "Tiger is the national animal of india"
pattern1 ="Tiger"
pattern2 ="lion"
res=re.search(pattern2,string)
print(res) | true |
a732e5d6914455583710edc31ea129f3dffe3944 | fireinrain/python_programing | /useful_tools/simple_pascal_interpreter.py | UTF-8 | 1,943 | 3.71875 | 4 | [] | no_license | # Token types
#
# EOF (end-of-file) token is used to indicate that
# there is no more input left for lexical analysis
INTEGER,PLUS,EOF = 'INTEGER','PLUS','EOF'
class Token(object):
"""docstring for Token"""
def __init__(self, type,value):
#token type:INTEGER,PLUS,EOF
self.type = type
#token value:0,1,2,3,4,5,... | true |
94a144a46b719f9baa0049958b86ad1b6e2b25ea | AlexQianYi/Leetcode | /279 Perfect Squares.py | UTF-8 | 701 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 12 17:24:39 2018
@author: yiqian
"""
class Solution(object):
def numSquares(self, n):
"""
:type n: int
:rtype: int
"""
s = [i*i for i in range(1,int(math.sqrt(n))+1)] # Square numbers <= n
l = 0 ... | true |
9562f7071d99c71fd673a818ff4139accfd3317f | auliss09/is12-programmeerimise_algkursus | /numeric_types.py | UTF-8 | 971 | 2.59375 | 3 | [] | no_license | <<<<<<< HEAD
print 5+8
print 14-7
print 7*4
print 16/4
print 2//8
print 3%5
print -6
print +6
print abs(5)
print int (3.4)
print long (3)
print float (9)
print divmod (5, 6)
print pow (7, 9)
print 3 ** 3
print 4 | 8
print 37^16
print 7&15
print 14<<7
print 14>>7
print ~ 9
n= -26
print bi... | true |
a6b9786c9ecec59954d42c1d2349784457921637 | blackpointdev/Battleship | /src/Ai.py | UTF-8 | 3,547 | 2.890625 | 3 | [] | no_license | from src.Utility import create_ship
from src.Utility import spotted_shot
import random
class AI:
def __init__(self, surf, board_ai, board_player):
self.__surface = surf
self.__board_ai = board_ai
self.__board_player = board_player
self.__shot = [x for x in range(100)]
self.... | true |
254a2ce3dc3bbb6ceea8002bacbe968dddb77a88 | nsimms25/algorithmic_solutions_python | /gcd.py | UTF-8 | 436 | 4.21875 | 4 | [] | no_license | '''
Find the Greatest Common Denominator (GCD) of two user inputted numbers.
Print the GCD of the numbers to the screen.
'''
# Example input() statement
number = int(input('Please enter a number: '))
number2 = int(input('Please enter a number: '))
if(number > number2):
smallest = number2
else:
smallest = num... | true |
a8d25367b856d898ff53f72dda9a0a4e4dd65197 | JulyKikuAkita/PythonPrac | /cs15211/3SumClosest.py | UTF-8 | 6,299 | 3.625 | 4 | [
"Apache-2.0"
] | permissive | __source__ = 'https://leetcode.com/problems/3sum-closest/'
# https://github.com/kamyu104/LeetCode/blob/master/Python/3sum-closest.py
# Time: O(n^2)
# Space: O(1)
#
# Description: Leetcode # 16. 3Sum Closest
#
# Given an array S of n integers,
# find three integers in S such that the sum is closest to a given number, t... | true |
6628a7da4038437efa70ec772a730abcd14781f0 | waffledunker/route4me-python-sdk | /examples/routes/delete_routes.py | UTF-8 | 903 | 2.640625 | 3 | [
"ISC"
] | permissive | # -*- coding: utf-8 -*-
from route4me import Route4Me
API_KEY = "11111111111111111111111111111111"
def main():
route4me = Route4Me(API_KEY)
route = route4me.route
print('Getting Latest 2 Routes')
response = route.get_routes(limit=2, offset=0)
if isinstance(response, dict) and 'errors' in respons... | true |
577116caf454312bc58c36a5aa248b0965efd083 | xiaohuanlin/Algorithms | /Leetcode/326. Power of Three.py | UTF-8 | 1,084 | 4.3125 | 4 | [] | no_license | '''
Given an integer, write a function to determine if it is a power of three.
Example 1:
Input: 27
Output: true
Example 2:
Input: 0
Output: false
Example 3:
Input: 9
Output: true
Example 4:
Input: 45
Output: false
Follow up:
Could you do it without using any loop / recursion?
'''
import unittest
class Solutio... | true |