blob_id large_string | language 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c492f537bff4c6009eefdb00f0240c12be2816d1 | Python | Temitope-A/multipol | /var.py | UTF-8 | 219 | 3.109375 | 3 | [] | no_license | #Import the variables into interactive mode or into a script and construct
# polynomials with python standard operators.
from multipol import MultiPol as pol
x = pol([0, 1], 1)
y = pol([0, 1], 2)
z = pol([0, 1], 3)
| true |
f5afad879e39740ce7a52332317d1bb5f1e4ad15 | Python | MLunov/Python-programming-basics-HSE | /Week 1: Integers, I-O, simple string operations/09.py | UTF-8 | 78 | 3.046875 | 3 | [
"MIT"
] | permissive | a = int(input())
h = a // 100
d = (a % 100) // 10
u = a % 10
print(h + d + u)
| true |
b11a734adb031a7ce09672d741e613620f27aee7 | Python | alexandraback/datacollection | /solutions_5658282861527040_0/Python/handorff/b-small.py | UTF-8 | 439 | 3.15625 | 3 | [] | no_license | t = int(raw_input())
a_list = []
b_list = []
k_list = []
for i in xrange(t):
[a, b, k] = map(int, raw_input().split(' '))
a_list.append(a)
b_list.append(b)
k_list.append(k)
outputs = []
for i in xrange(t):
a = a_list[i]
b = b_list[i]
k = k_list[i]
count = 0
for x in xrange(a):
for y in xrange(... | true |
d8c6ed3cac4d5316b0636d40e9d3516839067594 | Python | LorgneSchilooch/5IABD-ML | /contracts/__init__.py | UTF-8 | 1,226 | 2.671875 | 3 | [] | no_license | from typing import List
import numpy as np
class GameState:
def player_count(self) -> int:
raise NotImplementedError
def is_game_over(self) -> bool:
raise NotImplementedError
def get_active_player(self) -> int:
raise NotImplementedError
def clone(self) -> 'Ga... | true |
2549f5c11c06e7392e66e3ddff1e7f2c2129e5df | Python | zeushammer/Kung-fu | /flaskServer_view.py | UTF-8 | 3,682 | 2.53125 | 3 | [] | no_license | #terminate job->find job dir
#reads PID
#kills job
import os, controller
# Render HTML templates and access data sent by POST
# using the request object from flask. Redirect and url_for
# will be used to redirect the user once the upload is done
# and send_from_directory will send/show on the
# browser the file that t... | true |
67c87d1f7e6b76a19a0800cc8d7592cf69e1eba6 | Python | SarwarSaif/Artificial-Intelligence | /Lab6/Assignment6/main2.py | UTF-8 | 3,464 | 3.1875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 27 21:17:36 2018
@author: saif
"""
import csv #for csv files
import pandas as pd #for reading data from csv file and operating on them
import random as rd
import matplotlib #plotting
from matplotlib import pyplot as plt
import numpy as np #Faster matrix an... | true |
8e6a1c9227c73b570b3574da2bfe4545788302f2 | Python | haoranguovictor/AWS-Video-Classification-and-Delivery-System | /crawler/crawler.py | UTF-8 | 1,935 | 2.625 | 3 | [] | no_license | # coding: utf-8
import json
import os
import urllib2
from pytube import YouTube
from lxml import etree
from s3_helper import Bucket
from sqs_helper import SQS
maxNumber = 2
timeThreshold = 600
cur_count = 0
videoLists = []
def getHtml(url):
user_agent = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.13 (KHTML,... | true |
46c6b3dce058ae20fc6165354ff4b2db959c3c84 | Python | mzp0625/BeamCalculator | /helpers.py | UTF-8 | 1,096 | 2.75 | 3 | [] | no_license | import csv
import urllib.request
from flask import redirect, render_template, request, session
from functools import wraps
def apology(message, code=400):
"""Renders message as an apology to user."""
def escape(s):
"""
Escape special characters.
https://github.com/jacebrowning/memege... | true |
fb524b88664f429c59bdf83f18fe16d0605c54e7 | Python | robotpy/pyntcore | /tests/test_entry.py | UTF-8 | 1,331 | 2.671875 | 3 | [] | no_license | #
# Ensure that the NetworkTableEntry objects work
#
def test_entry_string(nt):
e = nt.getEntry("/k1")
assert e.getString(None) is None
e.setString("value")
assert e.getString(None) == "value"
assert e.getValue().value() == "value"
assert e.value == "value"
e.delete()
assert e.getStrin... | true |
053c9d27880da41b1a486faeb36fedf9afadec64 | Python | cf1998/automation_ops | /psutil(系统性能信息模块)/其他系统信息.py | UTF-8 | 398 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import psutil
import datetime
print(psutil.users()) # 使用psutil.users方法返回当前登陆系统的用户信息
print(psutil.boot_time()) # 使用psutil.boot_time方法获取开机时间,以Linux时间戳格式返回
# 转化成自然时间格式
print(datetime.datetime.fromtimestamp(psutil.boot_time()).strftime('%Y-%m-%d %H: %M: %S')) | true |
0ab19d2e569ca306d781eae4b596db9964306852 | Python | Eddie41/cws | /api/Common.py | UTF-8 | 1,605 | 2.6875 | 3 | [] | no_license | #-*- coding:utf-8 -*-
import time
import sys
import traceback
import json
from Crypto.Cipher import AES
import base64
KEY = "starwarsstarwars"
IV = "aaaaaaaaaaaaaaaa"
class Result:
def __init__(self):
self.code = 200
self.msg = ""
self.buf = {}
def set(self, key, value=None):
... | true |
747904a824ce6fd5057a3f164fa477c5a0c412b8 | Python | oska874/py-study-code | /snippet/gui_test/3rdParty/7941OT_Code/7941OT_8_code/8.07 formatting entry widget to display date.py | UTF-8 | 1,264 | 3.578125 | 4 | [] | no_license | """
Code illustration: 8.07
Formatting Entry Widget
tkinter GUI Application Development Hotshot
"""
from tkinter import *
class FormatEntryWidgetDemo:
def __init__(self, root):
Label(root, text='Date(MM/DD/YYYY)').pack()
self.entereddata = StringVar()
self.dateentrywidget = Entry(textvariab... | true |
39e8969a5272b10de00c51e653a8490cc451e979 | Python | daniel-reich/ubiquitous-fiesta | /6BXmvwJ5SGjby3x9Z_22.py | UTF-8 | 314 | 3.0625 | 3 | [] | no_license |
def hours_passed(time1, time2):
x = int(time1.split(':')[0]) + 12 if time1[-2] == 'P' else 0 if int(time1.split(':')[0]) == 12 else int(time1.split(':')[0])
y = int(time2.split(':')[0]) + 12 if time2[-2] == 'P' else int(time2.split(':')[0])
return str(y - x) + " hours" if y - x != 0 else "no time passed"
| true |
a773c431cb25b949dae854bce150bf139b28921c | Python | neal-o-r/sat-slides | /code/sat.py | UTF-8 | 1,133 | 3.03125 | 3 | [] | no_license | from props import Term, Clause, Circuit, Assignment, Solution
from itertools import product
import random as rd
from typing import List, Tuple
def eval_clause(clse: Clause, assigns: Assignment) -> bool:
return any([t.assign(assigns[t.variable]) for t in clse])
def eval_circuit(circ: Circuit, assigns: Assignment... | true |
e322fba7877e7b1aab35fbf06a6bad164e8022b9 | Python | velamen2009/leetcode | /Python/0009_palindrome_num.py | UTF-8 | 178 | 2.90625 | 3 | [] | no_license | class Solution(object):
if x < 0 or (x != 0 and x % 10 == 0):
return False
sum = 0
while x > sum:
sum = sum * 10 + x % 10
x = x // 10
return x == sum or x == sum // 10
| true |
bd3ae52e7711a0d297ca80fcf974dc7d3a90fb4a | Python | oculusstorystudio/kraken | /unittests/core/objects/components/test_component_input_port.py | UTF-8 | 4,308 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive |
import unittest
from kraken.core.objects.components.component import Component
from kraken.core.objects.components.component_input import ComponentInput
from kraken.core.objects.components.component_input_port import ComponentInputPort
from kraken.core.objects.components.component_output_port import ComponentOutputP... | true |
a0bbd8118e57e5cea2795add7a133bf8ce7e2e66 | Python | o-/ml_hw | /4/nn.py | UTF-8 | 8,708 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env python3
# Attribution note:
#
# I misunderstood the notes. I thought layer 2 would go from z^2 to a^2, but
# it turns out it goes from z^1 to a^2. I had a hard time to find this bug
# and had to resort to delta debugging against the following reference
# implementation: http://neuralnetworksanddeeplear... | true |
5e7c287032df3669c426467b6e1ca591fd993af9 | Python | Leoehz/Steam-Profit-Calculator | /main.py | UTF-8 | 2,202 | 3.203125 | 3 | [] | no_license | from colorama import init, Fore, Back, Style
from scan import single_scan, multi_scan
from sorter import sort_profit
from summary import single, multi
import time, os
def main():
init(autoreset=True)
print(Style.BRIGHT + "\nPuede introducir varios ID separados por una coma ','")
apps = input... | true |
09085051f86ff7141562a773605caa727d6dffeb | Python | kooksjuice/Sketches | /human-vs-machine.py | UTF-8 | 3,325 | 3.71875 | 4 | [] | no_license | #
# Person or machine? The rps-string challenge...
#
# This file should includes code for
# + extract_features( rps ), returning a dictionary of features from an input rps string
# + score_features( dict_of_features ), returning a score (or scores) based on that dictionary
#
# Here's how to machine-generate a... | true |
266d696f93f6af7a31ce0f718ab7253efcf2279b | Python | mattd429/flask-apollo-react-hooks-docker-graphql | /modules/app/models.py | UTF-8 | 1,318 | 2.671875 | 3 | [
"MIT"
] | permissive | # sqlalchemy
from sqlalchemy import Column, DateTime, ForeignKey, Integer, String, func
from sqlalchemy.orm import backref, relationship
# Local
from .database import Base
class Blog(Base):
__tablename__ = 'blog'
id = Column(Integer, primary_key=True)
title = Column(String)
text = Column(String)
cla... | true |
05d6c859d9a5f9655cbf5fa2569d1c239c2db05c | Python | anu1/python | /test_diamond.py | UTF-8 | 277 | 3.1875 | 3 | [] | no_license | n = 3
if n > 0:
for i in range(1,n):
for space in range(n-i):
print(" ",end="")
for j in range((2*i)-1):
print("*",end="")
print()
for i in range(n,0,-1):
for space in range(n-i):
print(" ",end="")
for j in range((2*i)-1):
print("*",end="")
print()
| true |
075c91ffa0fd3ee71a9d84d7dadcbe55ce0158ff | Python | vukakarthik/PyTrain | /06_functions/06_modules/02_import-from.py | UTF-8 | 468 | 3.890625 | 4 | [] | no_license | # import only pi from math module
# from math import pi
import math
# print("The value of pi is", pi)
# # import all names form
# # the standard module math
#
from math import *
print("The value of pi is", pi)
content = dir(math)
print(content)
# The dir() built-in function
# We can use the dir() function to fi... | true |
997ac531a493766041c4527c284e41031edbd218 | Python | juliomacr/python | /ejercicios.py | UTF-8 | 1,164 | 4.3125 | 4 | [] | no_license | # Create a `Test` class and add test methods
class Test(object):
# Define a function `count_vowels()`
def count_vowels(self, testText):
data = str(testText)
vowels = "aeiou"
total = 0
for char in data:
if char in vowels:
total += 1
return(total)
# Define a function `factor... | true |
5ff2c702bee7361090e82244c2ec395444b1d3a2 | Python | arrnos/whole_process_predict-tensorflow | /utils/tf_recorder_util.py | UTF-8 | 16,148 | 2.671875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
import tensorflow as tf
from config.global_config_text import *
from utils.date_util import DateUtil
class TFRecorder(object):
'''
helper function for write and read TFrecord files
'''
def _data_info_fn(self, one_example, var_fea... | true |
e17ffb8c03732dfc6f893498ff43defdc98994c1 | Python | colephalen/SP_2019_210A_classroom | /students/GKim/lesson04/dict_lab.py | UTF-8 | 2,946 | 4.59375 | 5 | [] | no_license | """
Dictionaries 1
Create a dictionary containing “name”, “city”, and “cake” for “Chris” from “Seattle” who likes
“Chocolate” (so the keys should be: “name”, etc, and values: “Chris”, etc.)
Display the dictionary.
Delete the entry for “cake”.
Display the dictionary.
Add an entry for “fruit” with “Mango” and display th... | true |
90a99694b0a37dc64052380dfbc20c3ca78c77da | Python | sgoutham2409/Kalman_filter_object_tracking | /main.py | UTF-8 | 1,977 | 2.984375 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from kalman_filter import KalmanFilter
plt.ion()
plt.figure()
kf = KalmanFilter(initial_x= 0.4, initial_v= 1.0, acceleration_variance= 0.1)
DT = 0.1
NUM_STEPS = 1000
MEASUREMENT_FREQUENCY = 20 # Assuming we get measurements every 20 steps
measureme... | true |
8a10bf9344c08f0ad039c2a3d3d783219b6e4570 | Python | ajimenezh/Programing-Contests | /Facebook Hacker Cup 2014/Round 1/Labelmaker.py | UTF-8 | 993 | 2.859375 | 3 | [] | no_license | import math;
input = open('input.txt', 'r');
output = open('output.txt', 'w');
t = int(input.readline());
for i in range(t):
s = input.readline();
vs = s.split(' ');
s = vs[0];
m = int(vs[1]);
print(m)
n = len(s);
if (n==1):
output.write("Case #" + str(i+1) + ": ");
f... | true |
3057c761148056290d28d23d1581a6316060f693 | Python | yanglo/leetcode_py | /292_Nim_Game.py | UTF-8 | 351 | 3.078125 | 3 | [] | no_license | #coding=utf-8
class Solution(object):
def canWinNim(self, n):
"""
:type n: int
:rtype: bool
"""
res = (n % 4 != 0)
return res
if __name__ == '__main__':
test = Solution()
# print test.canWinNim(4)
# print test.canWinNim(3)
print test.canWinNim(11)
... | true |
755208abc9b3500dacf2802addaf3096d279cb33 | Python | sainihimanshu1999/Data-Structures | /June2021/DP/MinimumJumps.py | UTF-8 | 1,048 | 3.34375 | 3 | [] | no_license | '''
Minimum jumps, a jump forward, b jump backward, can't jump backward twice, and we cannot jump to any forbidden position
'''
def minJumps(forbidden,a,b,x):
if not x: return 0
threshold = max(forbidden+[x])+a+b
forbidden = set(forbidden)
visited = set([0])
q = [[0,0]]
while q:
pos... | true |
18a78593eefa527bfc36e2cfd86689ef73942d6f | Python | JaniKoivisto/ML | /linear_regression/gradient_descent_reg.py | UTF-8 | 1,313 | 3.34375 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
learning_rate = 0.01
epsilon = 1e-7
def loadData(filename):
data = np.genfromtxt(filename, delimiter=',')
X = data[:,:2]
X = np.hstack((np.ones((X.shape[0], 1)), X))
Y = data[:,2].reshape(X.shape[0], 1)
return X, Y
X, y = loadData("training2.csv"... | true |
a1293e04990cab3e66df85f3845270ac1d4e9c48 | Python | jsonPlayer/python3-pymysql-scrapy | /zhihu/spiders/zhihuService.py | UTF-8 | 1,105 | 2.921875 | 3 | [] | no_license | import scrapy
from zhihu.items import zhihuItem
class zhihuService(scrapy.Spider):
name = 'zhihu'
allowed_domains = ["www.zhihu.com"]
offset = 0
url = 'https://www.zhihu.com/node/ExploreAnswerListV2?params={"offset":%s,"type":"day"}'
start_urls = [url % (offset)]
def parse(self, response)... | true |
828efd20ff7cc14ba5459ea2605dc0860dc11381 | Python | lenilunderman/coding-interview | /codeacademy/strings.py | UTF-8 | 884 | 4.875 | 5 | [] | no_license | #The " in " Syntax - is used to determine if a letter or a substring exists in a string.
game = "Popular Nintendo Game: Mario Kart"
print("p" in game)
# iterate an string
str = "love"
for s in str:
print(s)
# check the lenght of an string or lsit
word1 = "cavalo"
words = ["bala", "pera"]
print(len(word1)) # r... | true |
b26a793f67521d8c66a1f1e57c4b13c87f649ecf | Python | jjanelee/ICS3U1a201819-Processing | /Exploring_Processing_Assignment_.pyde | UTF-8 | 1,427 | 3.234375 | 3 | [] | no_license | x = 0
a = 4
keyboard = 0
y = 0
b = 3
press = 0
def setup():
global sat_img
global back_img
size(729, 425)
sat_img = loadImage("nemo.png") #nemo
back_img = loadImage("ocean.jpg") #background
def draw():
background (back_img)
#nemo bouncing off
global x
global a
... | true |
20796293a4336094fdfa06b907131804b1a2c92d | Python | dhruvin1151-glitch/LearnPython | /SchoolSys/pac_subject/Subject_Manager.py | UTF-8 | 3,308 | 3.0625 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
from pac_DB_Common import DB_Manager
from pac_subject import Subject
class Subject_Manager(object):
def __init__(self):
self.__data = {}
self.dbManager = DB_Manager.Subject_DB()
'添加一个课程的信息到课程数据库里边'
def add_subject(self, subject):
if isinstance(subject, Subje... | true |
aa0b18473b324d6e224ee32d9d1803f8d0f5e14a | Python | evansd/django-agile-thumbs | /agilethumbs/views.py | UTF-8 | 3,662 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | import os
import errno
from contextlib import contextmanager
from tempfile import mkstemp
from django.conf import settings
from django.http import Http404
from django.core.urlresolvers import get_callable
from django.utils._os import safe_join
from django.views.static import serve as django_serve_static
from agilethu... | true |
55fbc981a823a88aef3c291b623dc78d45c01607 | Python | bkittelmann/statblock | /test/test_skill.py | UTF-8 | 1,247 | 2.6875 | 3 | [
"MIT"
] | permissive | import pytest
from statblock.character import ActorBuilder
from statblock.skill import Balance
from statblock.skill import Jump
from statblock.skill import Skill
from statblock.skill import Tumble
def test_skill_general_methods():
skill = Skill("nothing", ranks=4)
assert skill.ranks == 4
assert skill.val... | true |
74311fd0bbb0d6c0ca31541165f508b2db84fed8 | Python | marie-0405/cooking_with_Vector | /vector/listen.py | UTF-8 | 4,781 | 2.90625 | 3 | [] | no_license | """"
音声認識のためのモジュール
ベクターには接続していないため、独立
"""
import difflib
import itertools
import nltk
import pyaudio
import speech_recognition as sr # 音声認識を行うためのライブラリ
from resources import utility
import time
# 準備
device_id = 1 # 1: Web camera
r = sr.Recognizer()
mic = sr.Microphone(device_index=device_id)
class Listen():
def... | true |
20ef31722b031dbe14154cdc2b2e198888748825 | Python | parsonsh/eaoTools | /pirep-collate.py | UTF-8 | 16,375 | 2.671875 | 3 | [] | no_license | #!/local/python/bin/python
'''
This script will go in and grab information from
a pi report form collate all the information and
produce stats/plots for board reports/those interested
This is not done on a strict by semester basis but is good enough for
the purposes of tracking user satisfaction.
Note I do not do ... | true |
71ea6c7ca221d69702a2d364cc33a169e554599b | Python | modolee/algorithm-practice | /programmers-python/python_tips/permutation_combination.py | UTF-8 | 422 | 4.0625 | 4 | [] | no_license | import itertools
pool = ['A', 'B', 'C']
print(list(map(''.join, itertools.permutations(pool)))) # 3개의 원소로 수열 만들기
print(list(map(''.join, itertools.permutations(pool, 2)))) # 2개의 원소로 수열 만들기
print(list(map(''.join, itertools.combinations(pool, 3)))) # 3개의 원소로 조합 만들기
print(list(map(''.join, itertools.combinations(pool, ... | true |
cfd84c9b30be2443929c7e70b7387c28c37e3dcb | Python | basarinan/DP_CS_Codee | /Python_Contest_Problems/RotatingLetters.py | UTF-8 | 284 | 3.546875 | 4 | [] | no_license | def rotatingletters():
word = input()
if len(word) > 30:
return "NO"
index = ["I","O","S","H","Z","X","N"]
for i in range(len(word)):
if word[i] not in index:
return "NO"
return "YES"
print(rotatingletters())
| true |
1ab5ce2c4e982b952d5e5db68d20cfd0554c3d29 | Python | cfsengineering/CEASIOMpy | /ceasiompy/CPACS2GMSH/func/engineconversion.py | UTF-8 | 17,806 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | """
CEASIOMpy: Conceptual Aircraft Design Software
Developed by CFS ENGINEERING, 1015 Lausanne, Switzerland
This script contains different functions to convert engine
Python version: >=3.8
| Author: Tony Govoni
| Creation: 2022-05-12
TODO:
- When TIGL new version is incorporated, check all the function of this... | true |
ad269443ede6f75aaa38d86cb924f351b90d7571 | Python | YoungHaYoo12/drawify | /tests/test_questions.py | UTF-8 | 9,408 | 2.546875 | 3 | [] | no_license | from base_cases import FlaskClientTestCase
from flask import url_for
from app.models import Drawing,Game,Hint,User,Question
from app import db
from datetime import datetime
class FlaskQuestionsTestCase(FlaskClientTestCase):
def test_question(self):
u1 = User(username='one',email='one@one.com',password='one')
... | true |
6fad7ebb2df463452c8399379c8683baa0847113 | Python | Howard-Hsiao/unctad_stat_crawler | /src/unctad_stat_crawler/itemcode_getter.py | UTF-8 | 4,996 | 2.5625 | 3 | [] | no_license | import requests
import xml.etree.ElementTree as ET
import json
from collections import namedtuple
from urllib.parse import quote, unquote
# Global PARAM ---------------------------------------------------------
Item_info = namedtuple("Item_info", ["name", "code"])
## itemCode info path
ITEM_CODE_PATH_TEMPLATE = "./co... | true |
0d2a1ad99ab75b27811e3fb179995c5ad6a4b07b | Python | camillebeland/design3 | /robot/treasure_angle_to_worldmap_positon_converter.py | UTF-8 | 3,382 | 2.859375 | 3 | [] | no_license | import math
class TreasureAngleToWorldmapPositionConverter:
def __init__(self, table_calibration_service, treasure_angles, robot):
self.table_calibration_service = table_calibration_service
self.treasure_angles = treasure_angles
self.robot_angle = robot.get_angle()
self.robot_posit... | true |
169ab88176b0ecbdfcd8da8f0455e3c060dae83d | Python | Rohansrivastav/Data-Acquisition | /Web Crawler Using Scrapy/beginning/beginning/spiders/quotes-spider.py | UTF-8 | 1,814 | 2.96875 | 3 | [] | no_license | # This package will contain the spiders of your Scrapy project
#
# Please refer to the documentation for information on how to create and manage
# your spiders.
import scrapy
class QuotesSpider(scrapy.Spider):
name="quotes_spider"#name of our spider
def start_requests(self):
urls=['http://quotes.toscrap... | true |
6f4a1ac6360153bbc13b3f5bfc1b6628a3cee877 | Python | LostOxygen/non_robust_data_poisoning | /evaluation_methods/single_model.py | UTF-8 | 8,915 | 2.65625 | 3 | [] | no_license | """library module with functions to analyze and plot the complete and adversarial
accuracy for a given model.
"""
import os
from datetime import datetime
import torch
import torch.nn as nn
from torch.utils.data import DataLoader
from torchvision.datasets import CIFAR10, CIFAR100
import torchvision.transforms as tran... | true |
35c3cdc8e2b4ba76ac1294ce99caa5ec5e46e88c | Python | daviddwlee84/LeetCode | /Python3/Array/LastStoneWeight/Heap1046.py | UTF-8 | 618 | 3.125 | 3 | [] | no_license | from typing import List
import heapq
class Solution:
def lastStoneWeight(self, stones: List[int]) -> int:
# heapq._heapify_max(stones)
if not stones:
return 0
heap_stones = []
for stone in stones:
# max heap
heapq.heappush(heap_stones, -stone)
... | true |
5dc39e16cceb4ee5a481f0da92ee4c28661d2b57 | Python | maoz666/maoz-rep | /week1/Task15.py | UTF-8 | 79 | 3.4375 | 3 | [] | no_license | a = int(input())
b = a % 2
if b == 0:
print(a + 2)
else:
print(a + 1)
| true |
687216be7590629421f58144fc48f18dd0446c9d | Python | mini338/mpf | /mpf/media_controller/core/bcp_server.py | UTF-8 | 6,542 | 2.703125 | 3 | [
"MIT"
] | permissive | """BCP Server interface for the MPF Media Controller"""
# bcp_server.py
# Mission Pinball Framework
# Written by Brian Madden & Gabe Knuth
# Released under the MIT License. (See license info at the end of this file.)
# The Backbox Control Protocol was conceived and developed by:
# Quinn Capen
# Kevin Kelm
# Gabe Knuth... | true |
95e652c4ee4128c7efdaa9abc8d3e4e220a1c03d | Python | mupotsal/Programming_Practice_IGIT | /substring_longest.py | UTF-8 | 481 | 3.421875 | 3 | [] | no_license | def longest_substring(s):
nums_list = []
y = len(s)
for i in range(y):
new_string = ""
v = s[i:]
print(v,i)
for j in v:
if j not in new_string:
new_string += j
else:
break
nums_list.append(len(new_string))
p... | true |
fead9f4b4a854ff390af8b1943df9ae3d54d958d | Python | GredziszewskiK/spoj | /PP0504B.py | UTF-8 | 504 | 3.03125 | 3 | [] | no_license | # link do zadania
# https://pl.spoj.com/problems/PP0504B/
import sys
def string_merge(a, b):
answer = ''
x = len(a)
if len(a) > len(b):
x = len(b)
for y in range(x):
answer = answer + a[y] + b[y]
return answer
answers = []
numberOfTests = int(sys.stdin.readline())
for i in range(n... | true |
b101dbe2de9f00e019398efe632215147bb3db97 | Python | choiboy98/imusi | /spotify_utils/spotify_utils.py | UTF-8 | 1,500 | 2.671875 | 3 | [] | no_license | import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
import os
client_id = os.environ.get('SPOTIPY_CLIENT_ID')
client_secret = os.environ.get('SPOTIPY_CLIENT_SECRET')
client_credentials_manager = SpotifyClientCredentials(client_id=client_id, client_secret=client_secret)
sp = spotipy.Spotify(client... | true |
7e627d7a55a169b0235806f013114507ea2bcf17 | Python | jstein91/goosepaper | /goosepaper/upload.py | UTF-8 | 5,763 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | from rmapy.document import ZipDocument
from rmapy.api import Client, Document, Folder
import argparse
from pathlib import Path
from .auth import auth_client
def sanitycheck(folder: str, client):
# First lets do a sanity check. Since RM cloud uses an object ID as a unique key
# it is entirely possible to hav... | true |
deaae2c919ac9d529a25b886210f670d014c2e6b | Python | kuras120/JsonTreeExtension | /Core/JTExt.py | UTF-8 | 2,677 | 2.9375 | 3 | [] | no_license | import json
import uuid
import string
import random
from typing import TypeVar
from treelib import Tree
JsonDictType = TypeVar('JsonDictType', dict, list, str)
class JTExt:
def __init__(self, tree: Tree = None):
if tree:
self.__tree = tree
else:
self.__tree = Tree()
... | true |
cd85b8fb3e6d9a9e14dbee882943b40f116eac88 | Python | SUREYAPRAGAASH09/Basic-Python-Programming | /RPS_paper_scissors_rock_program.py | UTF-8 | 2,935 | 3.828125 | 4 | [] | no_license | import os
#this function is used to check whether input entered by the user is correct or not.
# if the user input is in the list of words then the word are tken into account
# otherwise it prompt the user to enter the correct input to the fuction
def validate_user_input(user_input,first_players_name,second_players_... | true |
f8df8da6b5276523dca14e2edf2b521710696747 | Python | benjamingarrett/arora_analysis_2020_08_02 | /arora_discovery_2020_08_02.py | UTF-8 | 2,483 | 2.734375 | 3 | [] | no_license | # Usage: <csv_file>
# Assumes the csv contains two columns: cache_size,cache_misses
# Looking to discover the relationship here and confirm a conjecture
# in a separate script
import os, sys, matplotlib.pyplot as plt
from math import sqrt, log
import numpy as np
from scipy import stats
from sklearn.metrics import r2_... | true |
61e8c5471dc28ff0672fbdb39406c7221f7f27a8 | Python | zhangjunjie/MS-Thesis | /scripts/plotres.py | UTF-8 | 796 | 2.984375 | 3 | [] | no_license | import numpy as np
import matplotlib.pyplot as plt
from pylab import *
%matplotlib inline
ite =10000
x = np.linspace(0, ite, 11)
orig_accuracy = np.asarray([0.464,0.911,0.91,0.913,0.931,0.925,0.919,0.922,0.923,0.924,0.923])
spp_accuracy = np.asarray([0.51875,0.91875,0.921094,0.935938,0.916406,0.93125,0.939844,0.93515... | true |
320d6a3ac267e4d72c51182e5286a6a6b0bf6843 | Python | sayan2407/File-Handiling-Using-Python | /Simple Application.py | UTF-8 | 218 | 3.28125 | 3 | [] | no_license | import camelcase
# Every word 1st Letter will be Capital using camelcase
c=camelcase.CamelCase()
fread=open("sample.txt")
text=fread.read()
text1=c.hump(text)
file=open("sample1.txt","w")
file.write(text1)
file.close() | true |
f62194e0a2052e408474685ca060f88426b1d5d0 | Python | seligman/largebuddha | /Other/animated_render_settings.py | UTF-8 | 2,153 | 2.75 | 3 | [] | no_license | #!/usr/bin/env python3
# Turn this on to use multiple cores
USE_MULTIPROCESSING = False
# This shows the "ghost" Mandelbrot image before the
# main image is drawn
SHOW_GHOST = False
# The different settings:
# SIZE = The square size of the image to render
# OFF_X, OFF_Y = The offset of the image.
# The image width... | true |
4067821a344d10846a470f8ee094f67271bc1306 | Python | arakan-boku/pygraphics | /gr_snow_test.py | UTF-8 | 1,198 | 3.609375 | 4 | [] | no_license | import matplotlib.pyplot as plt
import numpy as np
tx = []
ty = []
def move(leng, lpx, lpy, angle):
x = lpx + leng * np.cos(angle * np.pi / 180.0)
y = lpy - leng * np.sin(angle * np.pi / 180.0)
tx.append(x)
ty.append(y)
return x, y
def turn(angle, chg_angle):
ang = angle + chg_angle
an... | true |
d744e0824400508379f0dbcd2473997b97bc7852 | Python | pragmaticLearner/dynamic-programming | /freeCodeCamp video problems/Memoization/fibonaaci.py | UTF-8 | 421 | 4.53125 | 5 | [] | no_license | # My first learnt DP algorithm
# Using recursion
def fib(n: int) -> int:
if n <= 1:
return n
else:
return fib(n - 1) + fib(n - 2)
print(fib(1))
# Fibonacci using DP method
def fib(n):
if n <= 1:
return n
table = [None] * (n + 1)
table[0], table[1] = 0, 1
for i in... | true |
6816a89be6c88949d8cd1d9fe6b95b6cd8c6d1aa | Python | nicholasjalbert/Thrille | /scripts/config/getpthreadfunctions.py | UTF-8 | 1,881 | 2.90625 | 3 | [] | no_license | ##
# getpthreadfunctions.py - outputs the pthread man page to mapthread.txt
# parses the latter, creates a dictionary with pairs
# (functionname, list of function args where last element is result type)
# marshals dictionary to pthreaddict file
#
# Author - Christos Stergiou (chster@eecs.berkeley.edu)
#
import os,re,... | true |
4262fe2536fb67c39a2459a49563a818e2214c47 | Python | valmunos/Project-Euler | /euler 37.py | UTF-8 | 651 | 3.203125 | 3 | [] | no_license | from sympy.ntheory import isprime
def truncate_left(n):
s = str(n)[1:]
return int(s)
def truncate_right(n):
s = str(n)[:-1]
return int(s)
def check_number(n):
if not isprime(n):
return False
a = n
while a > 10:
a = truncate_left(a)
if not isprime(a):
re... | true |
269ed73230f6d585672a3e7b7a0e906ee52ee6d7 | Python | hosang/coding-prep | /leetcode/025_reverse_nodes_in_k-group/reverse.py | UTF-8 | 813 | 3.21875 | 3 | [] | no_license | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reverseKGroup(self, head, k):
"""
:type head: ListNode
:type k: int
:rtype: ListNode
"""
prev, pr... | true |
914af3d695eae3caca973ab151bb56569d8958a8 | Python | shriharshs/AlgoDaily | /leetcode/213-house-robber-ii/main.py | UTF-8 | 1,074 | 3.5 | 4 | [] | no_license | """
1st approach: reuse leetcode 213
- since adjacent means only the i-1 and i+1, problem becomes to rob either
ouse[0]-House[n-2] or House[1]-House[n-1], depending on which choice offers more money
Time O(2n)
Space O(1)
8 ms, faster than 99.45%
"""
class Solution(object):
def rob(self, nums):
... | true |
328057161b82e9451ddfeb5b87fc1acde3e3f268 | Python | GianmarcoMidena/LIP-predictor | /lip_classifier.py | UTF-8 | 17,236 | 2.75 | 3 | [
"MIT"
] | permissive | import numpy as np
import pandas as pd
import logging
import math
from sklearn.metrics import f1_score, recall_score, precision_score, roc_auc_score
from sklearn.model_selection import GroupKFold, LeaveOneGroupOut
from Bio.SeqUtils import seq1
from multiprocessing import Pool
from functools import partial
from configpa... | true |
f5c7375c3b4fdd48ed1b72d6852aef4d1d457f52 | Python | jreiher2003/email_app | /email_app.py | UTF-8 | 3,562 | 2.5625 | 3 | [] | no_license | import time
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email.utils import formataddr
from config import BaseConfig
recipients = ['jeffreiher@gmail.com', 'jeffreiher@bulletmail.org', "jreiher2003@yahoo.com", "web-26x... | true |
d0f7a2e9bc4ccf385d9a3d4129714a239dfcfbc1 | Python | royqh1979/PyEasyGraphics | /examples/introduction.to.programming.with.turtle/windows_only/4-1-3.sun.py | UTF-8 | 366 | 2.96875 | 3 | [
"BSD-3-Clause"
] | permissive | from easygraphics.turtle import *
def arcl(side, degree):
for i in range(degree):
fd(side)
lt(1)
def arcr(side, degree):
for i in range(degree):
fd(side)
rt(1)
create_world(800, 600)
set_speed(100)
for i in range(9):
for j in range(2):
arcl(1, 90)
arcr... | true |
3793badec26ba52c49c5142a8a6b680a3c4d03b6 | Python | supersum9/DataCamp | /Statistical Thinking in Python-Part1/Continuous Variables/belmont_stakes_normal_distribution.py | UTF-8 | 548 | 3.296875 | 3 | [] | no_license | # Compute mean and standard deviation: mu, sigma
mu = np.mean(belmont_no_outliers)
sigma = np.std(belmont_no_outliers)
# Sample out of a normal distribution with this mu and sigma: samples
samples = np.random.normal(mu, sigma, size = 10000)
# Get the CDF of the samples and of the data
x, y = ecdf(belmont_no_outliers)... | true |
6c2dc2aa3063af5b1492b8200a514d7bd54ac4ed | Python | Astroua/TurbuStat | /turbustat/statistics/lm_seg.py | UTF-8 | 9,483 | 2.640625 | 3 | [
"MIT"
] | permissive | # Licensed under an MIT open source license - see LICENSE
from __future__ import print_function, absolute_import, division
'''
Port of the R seg.lm.fit function.
From the pysegmented package: https://github.com/e-koch/pysegmented
The MIT License (MIT)
Copyright (c) 2014 Eric Koch
Permission is hereby granted, free ... | true |
9e0943ab9f8aa3e2cbed62b79456b9a04e866ff4 | Python | jnxyp/ICS3U-II | /homeworks/problem_s3/q1.py | UTF-8 | 294 | 3.640625 | 4 | [] | no_license | # Course Code: ICS3U
# Author: jn_xyp
# Version: 2017-10-11
# Problem Set 3 - Question 1-5
# Question 1
def every_nth_character(s:str,n:int):
i = 0
r = ''
while i < len(s) or i < 0:
r += s[i]
i += n
return r
print(every_nth_character('Computer Science', 3))
| true |
bd43942bddbfb8b314789944f8f2e3f4661800eb | Python | franciscolevimd/navcomb | /game.py | UTF-8 | 995 | 3.203125 | 3 | [] | no_license | import pygame
from ship import Ship
from meteor import Meteor
BACKGROUND_PNG = 'assets/background.png'
class Game():
def __init__(self):
self.background = pygame.image.load(BACKGROUND_PNG).convert()
self.all_sprites = pygame.sprite.Group()
self.meteors = pygame.sprite.Group()
se... | true |
9820d938e41a31987248748190201b1ef30ef052 | Python | Ramon072003/Jogo-Pedra-Papel-Tesoura | /main.py | UTF-8 | 2,547 | 3.875 | 4 | [] | no_license | import random
v1 = 0
v2 = 0
empate = 0
print(' JOGO PEDRA PAPEL TESOURA')
print('1 - PARA PEDRA 2 - PARA PAPEL 3 - PARA TESOURA')
print('Para mostrar os resultador digite = 4')
print('Para sair digite = 5')
print('-'*20)
while(True):
try:
res = int(input('Digite aqui: '))
i... | true |
b66f36a522debf49c15fcc8aa414a6eb535d32cd | Python | crybx/project-euler | /python/problem_067.py | UTF-8 | 556 | 3.671875 | 4 | [] | no_license | # Problem 67 - Maximum path sum II
# (Larger version of problem 18.)
#
# Find the maximum total from top to bottom in
# triangle.txt (problem_067_original_triangle.txt in my repo),
# a 15K text file containing a triangle with one-hundred rows.
import problem_067_triangle as problem67
import problem_018_max_path_sum as... | true |
e378f0f0d74451c74c4b7b6ea31770500b4f5f7c | Python | KokoseiJ/CliPlayListPlayer | /keyinput.py | UTF-8 | 1,706 | 2.625 | 3 | [] | no_license | import os, queue, threading
if os.name == "nt":
import msvcrt, time
elif os.name == "posix":
import sys, tty, termios, select
else:
raise OSError("Unknown OS type")
def listen_key(timeout = None):
"""
Returns returned value of _listen_key_{os name}.
type of the timeout should be integer.
ti... | true |
af484c71c63f9cdf06b7ebfc278fc9aa7e32bbe4 | Python | blackdragonbonu/Puzzles | /Utils/PriorityQueue.py | UTF-8 | 620 | 3.53125 | 4 | [] | no_license | import heapq
import Queue
__all__=['PriorityQueue']
class PriorityQueue:
def __init__(self):
self.Queue=[]
self.size=0
def size(self):
return self.size
def push(self,item,heappush=heapq.heappush):
heappush(self.Queue,item)
self.size+=1
def pop(self,heappop=heapq.heappop):
if self.size:
self.size... | true |
bac6b1c0db70c3f9305926b2d0e20eec22c2972a | Python | zOFsky/hw | /happy_walker/users/custom_validator.py | UTF-8 | 1,415 | 2.609375 | 3 | [] | no_license | from cerberus import errors, Validator
import json
class CustomErrorHandler(errors.BasicErrorHandler):
messages = errors.BasicErrorHandler.messages.copy()
messages[errors.MIN_LENGTH.code] = 'input is too short!'
messages[errors.REGEX_MISMATCH.code] = 'incorrect format of data'
class CustomValidator(object... | true |
753e1de9f4c53efb72ada34cf27595122105694a | Python | Aniri2013/HomeWork2 | /Task7.py | UTF-8 | 75 | 3.390625 | 3 | [] | no_license | M = int(input("Цифра - "))
I = 2
while I <= M:
print(I)
I += 2 | true |
57f8f7df7556d53648e48c611f6cbe5d60dfb2d6 | Python | hoodielive/pysizes | /scraps/basics.py | UTF-8 | 1,527 | 4.09375 | 4 | [] | no_license | # Write a program that allows a user to add/delete items from a
# todolist. Display user input as list
# author: yclept insan
def main():
added = []
while True:
user_response = input()
if user_response == 'q':
print("Bye!")
exit()
elif user_response ==... | true |
125059a30a83fd3fcbcf703befdabbae196702b7 | Python | bemrdo/CTF-2019 | /watevrCTF-2019/challenges/misc/Unspaellablle/solve.py | UTF-8 | 622 | 3.375 | 3 | [
"MIT"
] | permissive |
def main(flag):
f1 = open("chall.txt", "r").readlines()
f2 = open("stargate.txt", "r").readlines()
total = ""
oddlines = []
for i in range(0, len(f2)-1):
if f2[i] != f1[i]:
oddlines.append((f1[i], f2[i]))
for odd in oddlines:
for i in range(0, len(list(odd[... | true |
c4819da3ae9310890acaeaee89d1d3b5ea44f4cd | Python | farshidtz/mss2015 | /data_plotter/plot_data.py | UTF-8 | 2,564 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 9 18:38:57 2015
@author: omaral-safi
"""
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import urllib.request as urllib
from sys import argv
class Plot:
def __init__(self, sensor_name):
#s = pd.Series([1,3,5,np.nan,6,8])
sel... | true |
98c2fdf0dfc9a660a3eb9a359aa9ca14d83c60ce | Python | lucasvianav/SME0300-NumericalAnalysis | /Trabalho02/test/lsq.py | UTF-8 | 1,339 | 3.140625 | 3 | [
"MIT"
] | permissive | import numpy as np
import sympy as sp
# (index: int, cos: bool)
# 0 1 1 2 2 3 3 4 4 5 5 ...
# {0, cos}, {1, cos}, {1, sen}, {2, cos}, {2, sen}, ...
alternatingRange = lambda m : [{'index': j, 'cos': True if k == 0 else False} for j in range(m + 1) for k in range(2 if j != 0 else 1)]
# data: "dict"
# data = {'x': [x-p... | true |
e0d2924d769450353789af5b15b1255e251bcfd8 | Python | TusharMore47/hello-world | /ProblemNo_3.20.py | UTF-8 | 682 | 2.9375 | 3 | [] | no_license | from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')
theta = np.linspace(0, 2 * np.pi, 200)
x = np.sqrt(5)*np.cos(theta)
y = np.sqrt(5)*np.sin(theta)
ax.plot(x,y,np.sqrt(5/2),'g', alpha =0.6 )
len = 10
x1, x2 = np.mesh... | true |
9477e3cf2b2ccbb7591bd73588a7e99eb81311d3 | Python | kim-yeji/Python_CodingTest | /Saving_a_Princess.py | UTF-8 | 467 | 3.203125 | 3 | [] | no_license | import sys
from collections import deque
sys.stdin=open("input.txt","rt")
n, k = map(int,input().split())
deq=list(range(1,n+1)) #list에 1~n+1까지 초기화 시킨것
deq=deque(deq)
while deq:
for _ in range(k-1):
current=deq.popleft() #deque의 맨 앞을 pop하는 것
deq.append(current)
deq.popleft()
i... | true |
7e8fc1fe69bf47e19d38b727cb08c820c5db2b00 | Python | anirban-roy/Artifitial-Intelligence | /SantanderCustomerSatisfaction/ShowPerformance.py | UTF-8 | 1,114 | 3 | 3 | [] | no_license | import matplotlib.pyplot as plots
from sklearn.metrics import accuracy_score
from sklearn.metrics import roc_auc_score, roc_curve
__author__ = "Anirban Roy, December 2015"
class PerformanceMetrics:
Y_test = None
def __init__(self, ytest):
'Initialize....'
self.Y_test = ytest
plots.fig... | true |
bf6bac9aa772f85789d6a1743a5582a215788501 | Python | wyaadarsh/LeetCode-Solutions | /Python3/0564-Find-the-Closest-Palindrome/soln.py | UTF-8 | 581 | 2.875 | 3 | [
"MIT"
] | permissive | class Solution:
def nearestPalindromic(self, n):
"""
:type n: str
:rtype: str
"""
length = len(n)
half = int(n[:(length + 1) // 2])
nums = [half, half + 1, half - 1]
cands = []
for num in nums:
s = str(num)
s = s + s[:le... | true |
69b0195ae28db41b9879c281deff9a13ced95dad | Python | BDGITAI/RL_P2_CONTINUOUS_CONTROL | /deep_rl/component/unity.py | UTF-8 | 5,166 | 3.03125 | 3 | [] | no_license | #######################################################################
# This file contains a class acting as a wrapper for the Unity ML #
# environment. It allows the modular code developped by Shangtong #
# Zhang(zhangshangtong.cpp@gmail.com) to interface with Unity instead#
# of an open ai gym environment... | true |
9561b76930619a84691bad37d6936b56007d26f5 | Python | millionszhang/spider | /总结/pyemail.py | UTF-8 | 1,895 | 2.796875 | 3 | [] | no_license | import smtplib
from email import encoders
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
#sender 是邮件发送人邮箱。password是服务器授权码,mail—host是服务器地址(这里是qqstmp服务器)
sender = 'zyw1819787473@163.com'
passWord = '0224zhangyw'
mail_host = 'smtp.163.com'
#receiver... | true |
ba468bc4045773be846e3cf9bff0c7d497d4c70a | Python | juliantrue/deep-sort-tf2 | /deepsort/deep/visualize.py | UTF-8 | 3,863 | 2.71875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | import os
from absl import app, flags, logging
from absl.flags import FLAGS
import cv2
import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
from tensorflow.keras.losses import SparseCategoricalCrossentropy
from tensorflow.keras.metrics import SparseCategoricalAccuracy
from tensorflow.keras.opt... | true |
4830ccac504ebd91f59df570547cfda237fe2f35 | Python | leksiam/PythonCourse | /Practice/Kolpakov/lect_8/#3.py | UTF-8 | 399 | 3.484375 | 3 | [] | no_license | def my_range(start, stop, step):
cnt = stop - start
if start < stop and step > 0:
while start < stop:
yield start
start += step
elif start > stop and step < 0:
while start < stop:
yield start
start -= step
elif step == 0:
yield None... | true |
9d52dbe03af87a6d4d9ee3c66b90a2748a2e59ff | Python | nmladenov/pragmatic-mobile-testing | /appium/appium-python-demos/tests/desktop_web/test_checkboxes.py | UTF-8 | 596 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | """
Tests for checkbox elements.
"""
import pytest
from pages.the_internet_app.checkboxes_page import CheckboxPage
class TestCheckboxes(object):
@pytest.fixture(scope='function', autouse=True)
def before_each(self, driver):
self.page = CheckboxPage(driver)
self.page.visit()
def test_chec... | true |
c947e88fc5830d4d02f8aa0531104cabed96f402 | Python | shubhamsg199/DataStructuresAndAlgorithms | /Buy&SellStockDynamicProgramming.py | UTF-8 | 326 | 3.484375 | 3 | [] | no_license | prices = [7,1,5,3,6,4]
def maxProfit(prices):
buy = prices[0]
max = 0
for i in range(1, len(prices)):
if prices[i] < buy:
buy = prices[i]
elif prices[i] - buy > max:
max = prices[i] - buy
if max > 0:
return max
else:
return 0
print(maxProfit(pr... | true |
5b1f593acb2fd953f7cb3248309de5b162a199ff | Python | racterub/yzu_python | /python/static/exercise8/3.py | UTF-8 | 364 | 3.0625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 2019-11-26 01:20:25
# @Author : Racter Liu (racterub) (racterub@gmail.com)
# @Link : https://racterub.io
# @License : MIT
def has_dups(data):
for i in data:
if data.count(i) > 1:
return True
else:
return False
... | true |
978068e4f2a48313355b4c01c0cdd5aa7617e9a6 | Python | Kori3a/M-PT1-38-21 | /Tasks/Blokhin/FinalProject/Pancakes/cart/cart.py | UTF-8 | 1,963 | 2.96875 | 3 | [] | no_license | from decimal import Decimal
from django.conf import settings
from mainApp.models import Dish
class Cart(object):
def __init__(self, request):
self.session = request.session
self.cart = self.session.get(settings.CART_SESSION_ID, {})
def save(self):
self.session[settings.CART_SESSION_I... | true |
3b65bcd83d11e1bc2567969134e5b844edc3f58a | Python | smritta10/PythonTraining_Smritta | /Assignment2_Task1/PythonAssignment_Task1.py | UTF-8 | 1,477 | 4.71875 | 5 | [] | no_license | # Exercise 1
firstname, age, female= 'Smritta', 29, True
print(firstname, age, female)
# Exercise 2
x= complex(1,2)
print(x)
y= 10
print(y)
print(type(y))
x, y = y, x
print(x)
print(y)
#Exercise 3
#Swap using a 3rd var
num1= 15
num2= 18
Print('Numbers before swap: '. num1, num2)
temp= num1
num1= num2
num2= temp
pri... | true |
5724bd1a8ee4ef7a616d5ca303fac0278a2e890d | Python | ashish-bisht/ds_algo_handbook | /subsets/generate_parentheses.py | UTF-8 | 633 | 3.765625 | 4 | [] | no_license | def generate_valid_parentheses(num):
result = []
helper(num, num, "", result)
return result
def helper(left_remain, right_remian, cur, result):
if left_remain > right_remian or left_remain < 0 or right_remian < 0:
return
if right_remian == 0:
result.append(cur)
return
... | true |
ff5a9ca1f3c3a82b787f0498045f7ba6ab73e205 | Python | victorien88/mam_manager | /modules/mailer.py | UTF-8 | 1,594 | 2.53125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
__author__ = 'fcp6'
import json
import smtplib
import configparser
from email.mime.text import MIMEText
class Mailer(object):
def __init__(self):
self.Config =configparser.ConfigParser()
self.Config.read('mail.conf')
def ConfigSectionMap(self,section):
... | true |
c0e2f809a7e9886a1710de91749e8aec8a32e240 | Python | prasanthunnam/Toshiba | /digital_twin/day3/specail functions/one.py | UTF-8 | 169 | 2.71875 | 3 | [] | no_license | lista = [12, 67, 98, 11, 8, 34]
listb = [0, "hello", [], None, 23]
tupc = (34, 78, 12, 9, 3, 6, 10)
cities = ["jaipur", "indore", "cuttack", "mangalore", "guwahati"]
| true |
0ea4b4891d2301a1347802c9250146809de19df6 | Python | saurabh-pandey/AlgoAndDS | /leetcode/queue_stack/stack/daily_temperatures.py | UTF-8 | 2,359 | 3.6875 | 4 | [] | no_license | #URL: https://leetcode.com/explore/learn/card/queue-stack/230/usage-stack/1363/
#Description
"""
Given an array of integers temperatures represents the daily temperatures, return an array answer
such that answer[i] is the number of days you have to wait after the ith day to get a warmer
temperature. If there is no fu... | true |
05b328e82ba66f68a92cd183908f1f51c668a356 | Python | karlcow/Grange-Tools | /canadaResidency/statusCanada.py | UTF-8 | 5,270 | 3.296875 | 3 | [] | no_license | #!/usr/bin/env python
# encoding: utf-8
"""
partir-canada.py
Created by Karl Dubost on 2010-11-10.
Modified on 2012-05-31
Copyright (c) 2010 Grange.
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php.
"""
import time
import datetime
import argparse
# CONSTANT
YEAR = 365
DATEFORMAT = "... | true |