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 |
|---|---|---|---|---|---|---|---|---|---|---|
583635e77e06dff0cdf15f0286c73d452442f83f | albertopuentes/python-exercises | /import_exercises.py | UTF-8 | 569 | 2.953125 | 3 | [] | no_license | import function_exercises
print(function_exercises.is_vowel('a'))
print(function_exercises.apply_discount(100, .25))
print(function_exercises.remove_vowels('testme'))
from function_exercises import calculate_tip
print(calculate_tip(.15, 100))
from itertools import product
# 2.a.
print(len(list(product('abc', '123... | true |
d96052b94890c8a3f2845f65d1a88d514b385599 | stigbd/ml-lab-industrial-code | /api/server.py | UTF-8 | 634 | 2.5625 | 3 | [] | no_license | from flask import Flask
from flask import request
from flask import jsonify
app = Flask(__name__)
@app.route("/", methods=['POST'])
def predict():
app.logger.info('Request to predict formaal: %s', request.get_json().get('formaal'))
## Predict based on input text
# model.predict(theText)
prediction = [... | true |
01ce66c5ee4f5b559032a6ca391a1193506a7b71 | DevepProd/holbertonschool-higher_level_programming-1 | /0x0A-python-inheritance/7-base_geometry.py | UTF-8 | 706 | 3.453125 | 3 | [] | no_license | #!/usr/bin/python3
"""Module that create a class BaseGeometry"""
class BaseGeometry():
"""Function that declare Class BaseGeometry"""
def area(self):
"""Function that raise exception of the
public method area"""
raise Exception("area() is not implemented")
def integer_validator(... | true |
d53c826c2c77b3f03c2f4661b21f47b9bc24835f | strawhatasif/python | /database/super_hero_info.py | UTF-8 | 1,228 | 3.75 | 4 | [] | no_license | # Displays super hero information (real names and universe) based on user input
# NOTE: I haven't figured out how to format the result, yet
import sqlite3
connection = sqlite3.connect('simple_database.db')
conn = connection.cursor()
def main():
super_hero_name = collect_super_hero_name()
retrieve_real_name(s... | true |
71610ba5a95776a033e55dd522ffacbbdd35ebfe | clintkittiesmeow/localizerB | /localizer/locate.py | UTF-8 | 2,608 | 3.265625 | 3 | [
"MIT"
] | permissive | import numpy as np
import pandas as pd
def locate_naive(series):
if len(series) > 360:
series = series[np.arange(0, 360)]
return series.idxmax()
def locate_interpolate(series_concat, method):
series_inter = series_concat.interpolate(method=method)[np.arange(0, 360)]
return series_inter.idx... | true |
a6f4d1b0ed5f153ee1c6d7b0a5669782110f2c66 | valemescudero/Python-Practice | /Class 2/02. Mr Owl Ate My Metal Worm.py | UTF-8 | 918 | 4.53125 | 5 | [] | no_license | # Write a function to find out whether a given word or sentence is a palindrome and return True or False accordingly
# The function should ignore spaces and punctuation marks and make no distinction between lower and uppercase.
def pal(str):
MARKS = set("ºª\!\"@·#$~%€&¬/()='?¡¿`^[+*]´¨{},;.:-_<>")
ACCENTS = {"á"... | true |
4c85582069345a693f40dda5549aaa6e96a01ffa | Ruth-ikegah/python-mini-projects | /projects/Convert_a_image_to_pdf/convert_image_to_pdf.py | UTF-8 | 637 | 2.84375 | 3 | [
"Python-2.0",
"MIT"
] | permissive | import sys
import img2pdf
import os
filepath = sys.argv[1]
if os.path.isdir(filepath):
with open("output.pdf", "wb") as f:
imgs = []
for fname in os.listdir(filepath):
if not fname.endswith(".jpg"):
continue
path = os.path.join(filepath, fname)
if... | true |
cff10ff37e44e8fc6bd79c9f89e98254bcedce12 | bastiendlf/Kaggle-Spotify-SDATA | /preprocessing.py | UTF-8 | 3,340 | 3.078125 | 3 | [] | no_license | import pandas as pd
from sklearn.preprocessing import LabelEncoder
from scipy.stats import zscore
from sklearn.preprocessing import scale
import numpy as np
import warnings
warnings.filterwarnings("ignore")
def encode_label(df):
print("Encode labels ...")
le = LabelEncoder()
return le.fit_transform(df)
... | true |
88a9f237b023b583f27ec2d8841f2d24ff07bff1 | lusineduryan/ACA_Python | /Sololearn/Functional programming/Recursion.py | UTF-8 | 273 | 4.125 | 4 | [] | no_license | def factorial(x):
if x == 1:
return 1
else:
return x * factorial(x - 1)
print(factorial(5))
def is_even(x):
if x == 0:
return True
else:
return is_odd(x-1)
def is_odd(x):
return not is_even(x)
print(is_odd(17))
print(is_even(23)) | true |
d3a0c876ded6b502a8dd0786a6647f908d5e07e8 | pombredanne/d1_python | /d1_libclient_python/src/examples/display_node_status.py | UTF-8 | 6,186 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This work was created by participants in the DataONE project, and is
# jointly copyrighted by participating institutions in DataONE. For
# more information on DataONE, see our web site at http://dataone.org.
#
# Copyright 2009-2016 DataONE
#
# Licensed under the Apache... | true |
56223383445d1af58056194abe4360789f571c51 | c14016057/ML2017 | /hw0/Q2.py | UTF-8 | 296 | 2.84375 | 3 | [] | no_license | import sys
import Image
a = Image.open (sys.argv[1])
b = Image.open (sys.argv[2])
w, h = a.size
c = Image.new("RGBA",(w, h))
for i in range(0, w, 1):
for j in range(0, h, 1):
if a.getpixel ((i, j)) != b.getpixel ((i, j)):
c.putpixel ((i, j), b.getpixel ((i, j)))
c.save("ans_two.png")
| true |
e6f1007bc39824f4fcfccd3fc920cec82c11d23b | gas-snake/tool | /Hayaku.py | UTF-8 | 1,094 | 3.265625 | 3 | [] | no_license | #!/usr/bin/python
#coding=utf-8
import requests
from bs4 import BeautifulSoup as bs
import cchardet
url = "http://2017.wuxianshua.com:81/web1/"
#设置提交方式,使用session()包含cookies
r = requests.session()
print('session',r)
print('cookies',r.cookies.get_dict())
#提交链接,获取网页
req = r.get(url)
print('session',r)
print('cookies',r... | true |
b7b0d9f50d8cce53a6553603c435047aa57bbe12 | sansonaa/colonel-cluster | /population/clustering.py | UTF-8 | 2,505 | 2.90625 | 3 | [
"MIT"
] | permissive | import itertools
import pandas as pd
import numpy as np
from scipy import linalg
import matplotlib.pyplot as plt
import matplotlib as mpl
from sklearn.mixture import BayesianGaussianMixture, GaussianMixture
color_iter = itertools.cycle([
'b', 'c', 'g', 'y','brown',
'lightgray', 'salmon', 'moccasin',
'pin... | true |
c59afbcc4826fc39b644882c4017d0b170638859 | peteradorjan/haystack | /rest_api/controller/request.py | UTF-8 | 3,557 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | import sys
from typing import Any, Collection, Dict, List, Optional, Union
from pydantic import BaseModel
from rest_api.config import DEFAULT_TOP_K_READER, DEFAULT_TOP_K_RETRIEVER
MAX_RECURSION_DEPTH = sys.getrecursionlimit() - 1
class Question(BaseModel):
questions: List[str]
filters: Optional[Dict[str, O... | true |
e235058f2696bb1cdd52ac89626fb17b761de30f | CiaoHe/BackUp | /axial_attention/axial_attention.py | UTF-8 | 8,892 | 2.84375 | 3 | [] | no_license | import torch
from torch import nn
from operator import itemgetter
from torch.nn import Parameter
from reversible import ReversibleSequence
# helper functions
def exists(val):
return val is not None
def map_el_ind(arr, ind):
return list(map(itemgetter(ind), arr))
def sort_and_return_indices(arr):
indi... | true |
27a5f9b273a3b15981acd029811b7a6ded498119 | aditya-sengupta/pwfs-archive | /new_pyramid.py | UTF-8 | 5,875 | 2.96875 | 3 | [
"MIT"
] | permissive | from wavefront_sensor import WavefrontSensorOptics, WavefrontSensorEstimator
from fraunhofer import FraunhoferPropagator
from plotting_field import imshow_field
from apodization import SurfaceApodizer, PhaseApodizer
from field import Field
from util import make_pupil_grid, make_focal_grid
import numpy as np
def pyram... | true |
182cdd362836dba1e872019f795bee4663e0122a | isundaylee/sparsebundle-s3 | /arc/unarchiver.py | UTF-8 | 2,256 | 2.671875 | 3 | [] | no_license | import struct
import gzip
import lz4.frame
from .common import *
class FileWrapper:
def __init__(self, file, offset, length, flags):
self.file = file
self.offset = offset
self.length = length
self.flags = flags
self.pos = 0
def _compute_cache(self):
self.fil... | true |
0d7a6d9c4be975b4be853cdb79e968bc77751771 | vertika-19/Wiki-Text-Categorization | /wiki10/MIML/clustering_DL_sanstop5/model_analysis.py | UTF-8 | 2,337 | 2.671875 | 3 | [] | no_license | from DataParser import DataParser as DataParser
from clustering_DL import clustering_DL as Model
import numpy as np
import os, sys
import math
def genAnalysis(modelfile,testfile,outputfile):
maxParagraphLength = 50
maxParagraphs = 10
filterSizes = [2,3,4]
num_filters = 64
wordEmbeddingDime... | true |
d757388f4a904fa4d31ae8ab2c87ebf51e14f1c2 | hhucNI/jdcrawler-selenium- | /jd/pipelines.py | UTF-8 | 1,485 | 2.671875 | 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 os
import csv
import pymongo
from scrapy.exceptions import DropItem
class MongoPipeline(object):
def __init__(self,m... | true |
b752f13bbccdaa31b182cae5e63eac6e281d0203 | ruancomelli/funcy | /funcy/tree.py | UTF-8 | 1,130 | 3.15625 | 3 | [
"BSD-3-Clause"
] | permissive | from collections import deque
from .types import is_seqcont
__all__ = ['tree_leaves', 'ltree_leaves', 'tree_nodes', 'ltree_nodes']
def tree_leaves(root, follow=is_seqcont, children=iter):
"""Iterates over tree leaves."""
q = deque([[root]])
while q:
node_iter = iter(q.pop())
for sub in n... | true |
8836a2279bd81559b6029c7f4b9c64fc431bb11a | prabin525/nepali-poem-generator | /poem_extractor.py | UTF-8 | 2,015 | 2.65625 | 3 | [] | no_license | import requests
import urllib
import time
from bs4 import BeautifulSoup
start_time = time.time()
main_url = "https://www.samakalinsahitya.com"
base_url = "https://www.samakalinsahitya.com/index.php?page=0&show=category&cat_id=3"
base_page = requests.get(base_url)
soup = BeautifulSoup(base_page.content, 'lxml')
last_p... | true |
e65b0e564ecb3e1b24840787a7253bfd8738e949 | Riadshah97/Django_introduction | /8th_class_03-08-21/Home_Work_Banker Details/result.py | UTF-8 | 273 | 2.859375 | 3 | [] | no_license |
from account import Account
rst = Account("Afiq rahman", "+8801701524845", "afiq@gmail.com", "Rangpur", 10000, 13000, 4000)
print(rst)
print(" Deposite:", rst.get_deposite(), "\n", "Total Balance:", rst.get_balance(), "\n", "Behind Withdraw, total balance:", rst.get_withdraw()) | true |
df10fcd8c6cc6f2da9609a8f5ecad32c91768ce7 | MontufarEric/Graphs | /TreeToArray.py | UTF-8 | 2,560 | 2.6875 | 3 | [] | no_license |
import nxviz as nv
import matplotlib.pyplot as plt
import numpy as np
from prim import *
from GraphToFile import*
from TreeGen import*
nodelist = [('1', {'label': 'inf'}),
('2', {'label': 'inf'}),
('3', {'label': 'inf'}),
('4', {'label': 'inf'}),
('5', {'label': 'inf'})... | true |
615eed276e1412bc909dc3881c810393450b183d | LuluwahA/100daysofcode | /Day 13.py | UTF-8 | 489 | 3.453125 | 3 | [] | no_license | list=[]
print(list)
num=[1,2,3,4,5]
print(num)
a=['january', 'march','may']
print(a)
c=['january', 'march','may',1,2,3]
print(c)
z=[12.3, 34.2, 99.5]
print(z)
a=['january', 'march','may']
print(a[1])
list=['january', 'march','may']
for x in list:
print(x)
num=[1,2,3,4,5]
for y in num:
p... | true |
ec57d609b7bf1b6dbae6999a3533e9b72576d8ad | paramoshin/advent-of-code-2020 | /day12.py | UTF-8 | 4,702 | 3.5 | 4 | [] | no_license | """Advent of code 2020 day 0."""
from dataclasses import dataclass
from typing import Literal, NamedTuple, Tuple
import pytest
from utils import read_input
Directions = Literal["N", "S", "E", "W"]
@dataclass
class Ferry:
_directions: Tuple[Directions, ...] = ("N", "E", "S", "W")
direction: Directions = "E... | true |
4c3c2b84f7f3941e40aef7af07f3eb371b2c9863 | benjmerales/Python-Dump | /Check Hovered Color.py | UTF-8 | 295 | 2.578125 | 3 | [] | no_license | import pyautogui as pag
import tkinter as tk
import time
window = tk.Tk()
frame = tk.Frame(master=window, width=100, height=100, bg="black")
frame.pack()
while True:
frame.pack()
im = pag.screenshot()
pos = pag.position()
color = im.getpixel(pos)
print(color)
| true |
6097f64e8b6ee1ca00c05b8f9dadb153f215b6a1 | qq184861643/wavenet-moduled-pytorch | /layer_utils.py | UTF-8 | 1,771 | 2.609375 | 3 | [] | no_license | import torch
from torch import nn
import torch.nn.functional as F
from utils import dilate
class CausalConv1d(nn.Module):
def __init__(self,in_channels,out_channels,kernel_size=2,stride=1,
dilation=1,bias=True):
super(CausalConv1d,self).__init__()
self.pad = (kernel_size - 1) * dilation
self.conv = nn.Con... | true |
0261a4d6454ba0fd8ca71f8bd6eca87a1f686dfd | nesaro/snippets | /cron_parser/cron.py | UTF-8 | 1,673 | 3.390625 | 3 | [] | no_license | import sys
def next_time(task_hour, task_minute, target_hour, target_minute):
"""Returns the next execution after the target time"""
carry_hour = 0
tomorrow = False
if task_minute == '*' and task_hour in ('*',target_hour):
minute = target_minute
elif task_minute == '*':
minute = 0
... | true |
4c8b841b25888e495b0cd0cf870089a6121fbd69 | nammn/algos | /introductionToAlgo/maxium_subarray.py | UTF-8 | 589 | 3.984375 | 4 | [] | no_license | # array with a stock price changes
# with n^2 solution
def max_sub_array(a):
abs_sum = -11111111111
low = 0
end = 0
for i in range(len(a) - 1):
sum = a[i]
for b in range(i + 1, len(a) - 1):
sum += a[b]
if sum > abs_sum:
abs_sum = sum
... | true |
6892e451a6afef04513eb4dfd5779cbf262383c7 | dcsparkes/chargen | /chargen.py | UTF-8 | 12,552 | 3.109375 | 3 | [] | no_license | # This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import argparse
import random
def dieRollN(n):
return random.randint(1, n)
def nDn(count, size):
rolls = []
... | true |
eb3aef13b4a40cd893b91bdd4fa1174aebc73b9d | adityarai0705/Chess | /main.py | UTF-8 | 24,415 | 3 | 3 | [] | no_license | import pygame
import sys
import time
import random
# GAME CO-ORDINATE SYSTEM
#
# 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1
# 1,2 2,2 3,2 4,2 5,2 6,2 7,2 8,2
# 1,3 2,3 3,3 4,3 5,3 6,3 7,3 8,3
# 1,4 2,4 3,4 4,4 5,4 6,4 7,4 8,4
# 1,5 2,5 3,5 4,5 ... | true |
6152bae0e0a1c2fe88c0af2a0d5efa28bab2debf | geonwoomun/AlgorithmStudy | /DP/BOJ9095.py | UTF-8 | 819 | 3.9375 | 4 | [] | no_license | # BOJ 9095 1,2,3 더하기
# dp는 역시 점화식을 잘 만들어야한다...
# 예제를 보면 4일 때 7이고 7일 때 44인걸 알 수 있는데 5, 6을 구해보면
# 7은 4 5 6 을 더한 값이라는 것을 알 수 있고, 1,2,3을 더하면 4인 것을 알 수 있다.
import sys
t = int(sys.stdin.readline());
dp = [0 for i in range(11)]
dp[0] = 0; # 0은 1,2,3으로 못만드니깐 0
dp[1] = 1; # 1은 1으로 만들 수 있다.
dp[2] = 2; # 2는 1+1, 2 2개로 만들 수 있다.
... | true |
8c5b7029b4c2ade30091d150c2e2eba6bffba454 | sizijay/python | /passn.py | UTF-8 | 418 | 2.96875 | 3 | [] | no_license |
from tkinter import *
root = Tk()
root.title("evaluator")
app = Frame(root)
app.grid()
label = Label(app, text = "enter expression", fg = "black", bg ="yellow")
label.grid(column = 0 , row = 0, columnspan = 2 , sticky = W)
password = Entry ()
password.grid (column =1 , row = 1 , sticky =W)
button =B... | true |
517673bd5541642e7a8d5bd59d2e679247283ea2 | HanHyunsoo/Baekjoon_Algorithm | /Python/10809.py | UTF-8 | 199 | 3.125 | 3 | [] | no_license | # 알파벳 찾
a=[chr(i) for i in range(97,123)]
S=list(input())
result=""
for i in a:
if S.count(i) > 0:
result += str(S.index(i)) + " "
else:
result += "-1 "
print(result)
| true |
de975a8125fa036a2182b49359a109f68147e7e9 | TrollzorFTW/writeups | /bsidesbos/warmups/y2k/solve.py | UTF-8 | 642 | 2.9375 | 3 | [] | no_license | #!/usr/bin/python3
import argparse
from pwn import *
def solve(ip,port):
conn = remote(ip,port)
q = conn.recvline()
payload = '__import__("os").system("cat flag.txt")'
conn.sendline(payload)
response = conn.recvline().decode('utf-8').split('}')[0]+'}'
return response
def main():
parser = argparse.ArgumentPa... | true |
dd830c9cba00e44a569feb07af56be956df20709 | jakehoare/leetcode | /python_1_to_1000/503_Next_Greater_Element_II.py | UTF-8 | 1,330 | 3.890625 | 4 | [] | no_license | _author_ = 'jake'
_project_ = 'leetcode'
# https://leetcode.com/problems/next-greater-element-ii/
# Given a circular array (the next element of the last element is the first element of the array), print the Next
# Greater Number for every element. The Next Greater Number of a number x is the first greater number to it... | true |
5ffbaa6a39fdda106117666508d5e63aec97356b | JnkDog/i-rheo-web | /algorithm/mot/mot.py | UTF-8 | 5,690 | 2.875 | 3 | [
"MIT"
] | permissive | import multiprocessing
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import math
import multiprocessing
from scipy.interpolate import interp1d
def manlio_ft(g, t, g_0=1, g_dot_inf=0, N_f=100, interpolate=True, oversampling=10):
""" Calculates the Fourier transform of numeric data. (slow ve... | true |
34636446580c66892b4c994ee2e45086ac01588d | zelinsky/hctf-2018-tasks | /namegame/webapp/app/app.py | UTF-8 | 1,780 | 2.890625 | 3 | [] | no_license | from flask import Flask, request, send_from_directory
app = Flask(__name__)
names = [
"theseus",
"jobs",
"wiesner",
"bezos",
"gates",
"stallman",
"selfridge",
"hal9000",
"schwalm"
]
BODY = """
<html><head><title>Know Your History</title></head>
<body>
<div style="margin: 0 auto">
... | true |
54128ac6e1c08887de3daf0c8e1e0d3d6a46bf3b | djohnson67/sPython3rd | /commision.py | UTF-8 | 564 | 3.9375 | 4 | [] | no_license | #calculates sales commisions
#control the loop
keep_going = 'y'
#calculate series of commisions
while keep_going == 'y':
#get a salespeson sales and commision rates
sales = float(input('Enter the amount of the sales: '))
comm_rate = float(input('Enter the commision rate:'))
#calc the commi... | true |
8455a213d47e6acf02e38054b739330c06ea83f2 | zeyh/webGL-camera | /tmp.py | UTF-8 | 259 | 3.375 | 3 | [] | no_license | def y(x):
return x*x + 2*x + 1
def main():
print("x")
x = []
h = 3
x0 = 3
for i in range(9):
x.append(x0 + i*3/8)
print(x)
result = 0
for i in range(1,9):
result += y(x[i])
print(result*3/8)
main() | true |
528d0c9fe084d12c38fc0815207ca03b5a8d81ea | xiaogengchen/di_ai_mu | /17/TestClass.py | UTF-8 | 745 | 3.515625 | 4 | [] | no_license | # !/usr/bin/env python
# -*- coding:utf-8 -*-
'''
python中的类 = 属性 + 方法
'''
class TestClass(object):
u'''测试类属性和实例属性'''
jishu = 100
my_list = []
def testJishu(self, number):
'''定义实例属性'''
self.jishu = number
def print_jishu(self):
print u'jishu, 我是实例变量:', self.jishu
if __na... | true |
e691d6b9f36138bb88336bc20cdb747ec595b0e2 | chinmairam/Python | /number_triangle.py | UTF-8 | 108 | 3.828125 | 4 | [] | no_license | for row in range(1,11):
for col in range(1,row+1):
print('{:3}'.format(col),end="")
print()
| true |
dbaabeacc6c924835777523bbfb1e8dd633784a9 | bluecollarcoders/weather-me | /app.py | UTF-8 | 4,124 | 2.671875 | 3 | [] | no_license |
import requests
from flask import Flask, render_template, request, flash, redirect, session, url_for
from flask_debugtoolbar import DebugToolbarExtension
from flask_sqlalchemy import SQLAlchemy
from forms import RegisterForm, LoginForm
from models import db, connect_db, User, City
import os
app = Flask(__name__)
... | true |
80dede4805b1d16ee433d9aedaf4a02db4d16986 | lorenzo314/pyxcosmo | /pyxcosmo/deriv_idl.py | UTF-8 | 1,204 | 3.625 | 4 | [] | no_license |
import numpy as np
def deriv_idl( x, y):
"""
Perform numerical differentiation using 3-point, Lagrangian
interpolation.
df/dx = y0*(2x-x1-x2)/(x01*x02)+y1*(2x-x0-x2)/(x10*x12)+y2*(2x-x0-x1)/(x20*x21)
Where: x01 = x0-x1, x02 = x0-x2, x12 = x1-x2, etc.
Copied from IDL deriv.pro
"""
... | true |
da8f232732d81b78b502a70df6f3113f8ffb42db | mkpjnx/MEO_Sat_Tracking | /TRTL Prototype/tracker_weird.py | UTF-8 | 7,615 | 3.46875 | 3 | [] | no_license | """Module to read the combined output from the 9-DOF sensor and GPS sensor."""
import serial
import time
import math
def format_date(d):
"""Convert the DDMMYY date format to YYYY/MM/DD format.
The DDMMYY is returned from the GPS and converted to a format usable by
PyEphem.
"""
y = d[4:6]
i... | true |
f6e5feed399d5ffa5432166f5ef402be074c4caa | fabriciofk/exercicio-entra21 | /cadastro_pessoa.py | UTF-8 | 930 | 3.65625 | 4 | [] | no_license | #--- Exercício 1 - Funções
#--- Escreva uma função para cadastro de pessoa:
#--- a função deve receber três parâmetros, nome, sobrenome e idade
#--- a função deve salvar os dados da pessoa em uma lista com escopo global
#--- a função deve permitir o cadastro apenas de pessoas com idade igual ou super... | true |
4d008462d86d44a8c2caf1842d4cb9db474151d4 | lightyears1998/lightyears-problemset | /LibreOJ/5.1.py | UTF-8 | 122 | 3.03125 | 3 | [] | no_license | # 918
from math import *
x = 0
while x <= 1231:
if x * (x - 31) == 815184 - x:
print(x)
x += 1
| true |
d7b1d2dec9daacf5a636a75be37edb95a637190f | lixinchn/LeetCode | /src/0141_LinkedListCycle.py | UTF-8 | 1,040 | 3.78125 | 4 | [] | no_license | class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
@staticmethod
def create(arr):
head = None
this = None
for val in arr:
node = ListNode(val)
if not head:
head = node
this = node
... | true |
0f003e5d28c335ae9d3c1569b63c2c70d53af760 | softicer-67/PARSING | /Lesson_7/1/1.py | UTF-8 | 2,867 | 2.953125 | 3 | [] | no_license | '''
1. Написать программу, которая собирает входящие письма из своего или тестового почтового ящика,
и сложить информацию о письмах в базу данных (от кого, дата отправки, тема письма, текст письма).
'''
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.except... | true |
b772dc243984c1208ec5a346a4044a1e907d0907 | ban-m/rust-python-binding | /src/caller.py | UTF-8 | 1,443 | 2.890625 | 3 | [] | no_license | import concurrent.futures
from concurrent.futures import ProcessPoolExecutor
from cffi import FFI
ffi = FFI()
ffi.cdef("""
int fold_c(int x,const int* ys,size_t ys_len);
typedef void* Folder;
Folder new_folder(const int* ys,size_t length);
int fold_struct(int x,Folder ys);
void free_struct(Folder ys);
""")
libtest = f... | true |
18ea81b254d7d4817794e0b272e2f7b11b41c44e | satojkovic/algorithms | /problems/tree_inorder_trav.py | UTF-8 | 956 | 4 | 4 | [] | no_license | class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# Time complexity: O(n)
# We need to visit every node in the tree.
#
# Space complexity: O(log(n)) at average case, O(n) at worst case
# Maximum depth of recursion tree is log(n) or n
#
# Algorithm:
# ... | true |
724a4ca31c6cbf7c4a98c9d88755a5b6346747ce | ahrav/Python-Django | /python_practice/interview_prep/stack_from_queues.py | UTF-8 | 440 | 3.640625 | 4 | [] | no_license | class Stack:
def __init__(self):
self.primary = []
self.secondary = []
def push(self, x):
self.secondary.append(x)
while len(self.primary) != 0:
[self.primary.pop()] + self.secondary
self.primary, self.secondary = self.secondary, self.primary
def pop(sel... | true |
ceb5de2b82d16f3f31c0c0e539cf3f9e32274645 | zzf531/book-code | /python_110/110例子/1-10.py | UTF-8 | 2,676 | 4.15625 | 4 | [] | no_license | # 1.一行代码实现1-100的和
print(sum(range(1, 101)))
print('第一题')
# 2.函数内部修改全局变量
a = 5
def add():
global a
a +=1
print(a)
add()
print(a)
print('第二题')
# 4.字典如何删除键和合并两个字典print(a)
dic = {
'name': 'zs',
'age': 18
}
del dic['name']
print(dic)
dic2 = {'sex': 12}
dic.update(dic2)
print(dic)
print('第四题')
"""
5、谈下... | true |
b2f848c6b7bf10edbecc52c055a0c6153fe56d3b | wuyifanisai/my_code | /ML_practice/President_speech/President.py | UTF-8 | 5,724 | 2.953125 | 3 | [] | no_license | # -*- coding: utf-8 -*-'
#对美国历年的国情咨文的文本的挖掘,分析历年总统的政治思想特征
import re
import pytagcloud
import jieba #导入结巴分词,需要自行下载安装
import random
import numpy as np
import pandas as pd
import math
import gensim
from gensim import corpora,models
from gensim.models import word2vec
import logging
print('#######################文本导入并分词###... | true |
c3f870c0346046576223bd4bbfdb7127dad21846 | 3194libin/Rectangle | /Rectangle.py | UTF-8 | 422 | 3.5625 | 4 | [] | no_license | class Rectangle:
def __init__(self,wide=0, height=0):
self.wide = wide
self.height = height
def __setattr__(self, key, value):
if key == 'square':
self.height = value
self.wide = value
else:
super.__setattr__(key,value)
def getArea(self):... | true |
77f2993ebc99db77016b883b5bc10eda8d924b46 | MrHamdulay/csc3-capstone | /examples/data/Assignment_6/msmona001/question3.py | UTF-8 | 741 | 3.6875 | 4 | [] | no_license | #program to count the number of votes for each political party in an election.
#print title
print("Independent Electoral Commission\n--------------------------------")
arrParties =[]
#Enter all parties till word is "DONE"
party = input("Enter the names of parties (terminated by DONE):\n")
while party.upper() ... | true |
32ddfc9629e1c223684d20fb2b48f45d5c069b1c | 21ivan/first-repository | /classwork3.py | UTF-8 | 3,829 | 4.34375 | 4 | [] | no_license | # 1. Сворити список цілих чисел, які вводяться з терміналу та визначити серед них максимальне та мінімальне число.
a = [x for x in range(21)]
print(a)
print(max(a))
print(min(a))
num_list = [int(input('enter int {}:'.format(i+1)))for i in range(6)]
print(num_list)
print('max num - ', max(num_list))
print('min... | true |
f4865ea6f8de8967244c8f2417d1fc1b19c99841 | anvo268/Udacity-Data-Analyst-Nanodegree | /Project Wrangle Open StreetMap Data/LoadData.py | UTF-8 | 3,305 | 3.21875 | 3 | [] | no_license | import sqlite3
import pandas as pd
import re
def clean_cell(s):
"""Strips the weird unicode indicators from a cell value"""
try:
m = re.match(r"b['\"](.*)['\"]", s)
try:
return m.group(1)
except AttributeError:
print(s)
return s
# Means it's not a... | true |
4be85f4be15322c292d07b59ef36d50fb2016d57 | jmcnamara/XlsxWriter | /xlsxwriter/test/worksheet/test_merge_range02.py | UTF-8 | 5,340 | 2.625 | 3 | [
"BSD-2-Clause"
] | permissive | ###############################################################################
#
# Tests for XlsxWriter.
#
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c), 2013-2023, John McNamara, jmcnamara@cpan.org
#
import unittest
from io import StringIO
from ..helperfunctions import _xml_to_list
from ...worksheet import... | true |
916b82d1b71a6ff85f2f5d325cb7e0eb8785ec5c | javipus/metaculus-stuff | /ai_progress/scoring.py | UTF-8 | 1,714 | 2.625 | 3 | [] | no_license | import numpy as np
from scipy.optimize import curve_fit
from model import logit, logit_pdf
from utils import (
get_histogram,
get_community_cdf,
get_norm_resolution,
interpolate
)
def scoring_(p_star, pc_star, pu, N):
B = 20 * np.log2(1 + N / 30)
A = 40 + B
abs_sc = A * np.log(max(p_star / pu, .02))
... | true |
24957d126d789fb4c1ab406969f6cd9d50b575c3 | Misael47/Final-Project | /RandomRecipeBook.py | UTF-8 | 1,766 | 3.046875 | 3 | [] | no_license | import requests
import docx
# API random recipes
first_recipe = requests.get('https://taco-1150.herokuapp.com/random/?full_taco=true').json()
second_recipe = requests.get('https://taco-1150.herokuapp.com/random/?full_taco=true').json()
third_recipe = requests.get('https://taco-1150.herokuapp.com/random/?full_taco=true... | true |
853ca7384209b6639ba8d41cf4b6cde68a5206eb | xilen0x/ejercicios-python | /inheritance.py | UTF-8 | 624 | 3.984375 | 4 | [] | no_license | class Persona:
nombre = ""
apellido = ""
edad = 0
def __init__(self, nombre, apellido, edad):
self.nombre = nombre
self.apellido = apellido
self.edad = edad
def saludar(self):
print("Bienvenido", self.nombre)
#creo la clase Estudiante q hereda de Persona sus propi... | true |
89f3ab59b53116af695e2d7e72aef2dce9df7efc | openelections/openelections-core | /openelex/base/load.py | UTF-8 | 4,730 | 2.765625 | 3 | [
"MIT"
] | permissive | from __future__ import print_function
import datetime
import json
from os.path import join
import re
import io
import unicodecsv
from openelex.models import RawResult
from .state import StateBase
class BaseLoader(StateBase):
"""
Base class for loading results data into MongoDB
Intended to be subclassed ... | true |
e7fb4c7a7e015b9d766f29be7a4e98c5c1974256 | csusb-005411285/CodeBreakersCode | /minimum-ascii-delete-sum-for-two-strings.py | UTF-8 | 819 | 2.859375 | 3 | [] | no_license | class Solution:
def minimumDeleteSum(self, s1: str, s2: str) -> int:
cache = [[float('inf') for i in range(len(s2) + 1)] for i in range(len(s1) + 1)]
for r in range(len(s1) + 1):
for c in range(len(s2) + 1):
if r == 0 and c == 0:
cache[0][0] = 0
... | true |
da480bd6823f6b52f4579474779fb6c31b0f77ce | mcohenmcohen/DataRobot | /data-science-scripts/shoop/sqlalchemy-playground/example1.py | UTF-8 | 478 | 2.53125 | 3 | [] | no_license | from sqlalchemy import create_engine, Column, Integer, String, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = "person"
id = Column("id", Integer, primary_key=True)
username = Column("username", String, unique=True)
#... | true |
ef37273f9688bcc16ccf8f41d0e02b63c9a6382d | ambuj991/Data-structure-and-algorithms | /Dynamic Programming/longest_increasing_subsequence.py | UTF-8 | 346 | 3.296875 | 3 | [] | no_license | # longest increasing subsequence ( strictly )
def lis(arr):
n = len(arr)
dp = [1]*n
for i in range(1, n):
for j in range(i):
if arr[i] > arr[j]:
dp[i] = max(dp[i], dp[j] + 1)
return max(dp)
nums = list(map(int, input().split()))
print(lis(nums))
# tim... | true |
a8e9085ed5fd9240d445d086a7646ab3ac683546 | mopat/TextEntrySpeed | /A6/klm.py | UTF-8 | 3,673 | 3.609375 | 4 | [] | no_license | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
class KlmCalculator(object):
def __init__(self):
# operator values of Card, Moran, Newell and Kieras
CMNKOperators = {
"k": 0.20,
"p": 1.1,
"b": 0.10,
"h": 0.40,
"m": 1.20
}
... | true |
a192547f0ab72d95c7935f748d4531df35584c67 | danse-inelastic/instrument | /instrument/DetectorMask.py | UTF-8 | 2,640 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env python
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Jiao Lin
# California Institute of Technology
# (C) 2004-2007 All Rights Reserved
#
# <LicenseText>
#
# ~~~~~~~~~~~~~~~~... | true |
c535ef4acdf96daa82862b6c7334ac08debfb2d5 | JCalderin91/proyecto_polinomio_lagrange | /Jesus_22998438.py | UTF-8 | 1,162 | 3.875 | 4 | [] | no_license | #!/usr/bin/env python3
"""
Proyecto Polinomio de Lagrange.
Cada participante debe completar su módulo y luego solicitar el Pull-Request.
"""
def li(x, i):
def _(var):
acum = 1
for j in range(len(x)):
if(i != j):
acum *= (var-x[j])/(x[i]-x[j])
return acum
re... | true |
2c21ab562f796f093828074e41fcf7bf0dc25be8 | hnbanack/Groebner | /groebner/polynomial.py | UTF-8 | 5,865 | 3.0625 | 3 | [] | no_license | from __future__ import division, print_function
import numpy as np
from scipy.signal import fftconvolve, convolve
import itertools
class Polynomial(object):
def __init__(self, coeff, order='degrevlex', lead_term=None):
'''
terms, int- number of chebyshev polynomials each variable can have. Each di... | true |
3e2e1985cb59016d7d9abd1bf413d6104a9c1292 | SatyamAS/venom | /SL_LAB/QB4.py | UTF-8 | 827 | 4.15625 | 4 | [] | no_license | ##4. Load the Titanic dataset into one of the data structures (NumPy or Pandas).
##Display header rows and description of the loaded dataset.
##Remove unnecessary features (E.g. drop unwanted columns) from the dataset.
##Manipulate data by replacing empty column values with a default value.
##Pandas for structure... | true |
06938bab79d06025e73ae19c6074e565e8342116 | thephillipsequation/PythonWorkshop | /mypackage/helloworld.py | UTF-8 | 920 | 3.765625 | 4 | [] | no_license | ''' i am a module '''
# pylint: disable=too-few-public-methods
import requests
class HelloRequests(object):
''' class for requests '''
@classmethod
def make_request(cls):
''' simple request method '''
response = requests.get('https://www.google.com')
return response.text
class H... | true |
a1a991abeb0386b697d183f275e3b2c31aa18731 | HarshPraharaj/LeetcodePractice | /Medium/167_TwoSumII.py | UTF-8 | 549 | 3.796875 | 4 | [] | no_license | ## Maintain two pointers and check two sum for them. Increment/Decrement left and right pointer based on the two_sum
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
l = 0
r = len(numbers) - 1
while l <= r:
two_sum = numbers[l] + num... | true |
1b82021c4a2e94c89314a72a20ab4e7921eda9d4 | bmdvt90/python_work | /movietickets.py | UTF-8 | 294 | 3.859375 | 4 | [] | no_license | prompt = "\nWelcome to the Theatre"
prompt += "\nHow old are you?: "
#active = True
age = ""
#while active:
age = input(prompt)
age = int(age)
if age < 3:
print("Your ticket is free.")
# break
else:
if age < 13:
print("Your ticket is $10.")
# break
else:
print("Your ticket is $15.")
| true |
59ad1821706f7f4671bc5839cd24161b13359a4d | MdGolam-Kibria/python | /VowelAndCon.py | UTF-8 | 289 | 4.03125 | 4 | [] | no_license | value = input(str("Enter a later: "))
var = "vowel" if value == 'a' or value == 'e' or value == 'i' or value == 'o' or value == 'u' else "consonant"
print(var)
print('a'.upper())
print('a'.lower())
print(type(value))
if type(value) is float:
print("String")
else:
print("Others")
| true |
f39c865643a7c111264075a57b1d877cf615d073 | corthan/stormstuff | /model_sd.py | UTF-8 | 2,327 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/python
import math
header = "xid,yid,date_id,hour,model,wind,error\n"
errors_file = "ModelErrorFile.csv"
values = {}
variances = {}
values_per_bucket = {}
variances_per_bucket = {}
counts = {}
counts_per_bucket = {0:{}, 1:{}, 2:{}, 3:{}, 4:{}, 5:{}, 6:{}, 7:{}, 8:{}, 9:{}, 10:{}}
bucket_titles=["0..5", "5... | true |
ff663c6035f119ce081f858e62f955027d0687c2 | green-fox-academy/belaszabo | /week-02/day-05/palindrome_searcher.py | UTF-8 | 371 | 3.546875 | 4 | [] | no_license | def search_palindrome(string):
strings = string.split()
print(strings)
palindromes = []
for i in range(0,len(strings)):
if len(strings[i]) % 2 == 0:
if strings[i][:len(strings[i])/2+1] == strings[i][len(strings[i])/2:]:
palindromes.append(strings[i])
return palind... | true |
3b51a21a0f0b6aba242c43b3854b8ed35516ef79 | adamlabadorf/overleaf2word | /tex2word.py | UTF-8 | 2,976 | 2.515625 | 3 | [
"MIT"
] | permissive | from collections import namedtuple
from ply import lex, yacc
tokens = ('CMD',
# 'LITERALNEWLINE',
'MANUALNEWLINE',
'WORD',
'COMMENT',
'COLSPEC'
)
t_CMD = r'\\(?P<cmd>[a-zA-Z0-9]+)'
#t_LITERALNEWLINE = '[\n]'
t_MANUALNEWLINE = r'\\\\'
t_WORD = r'(?<!\\)[a-zA-Z0-9|:!&]+|\\%'
t_COMMENT = r'[%].*'
t_CO... | true |
05712c313f7aa5f8ea3bb35c21acfa9b87c37d97 | guilherme-witkosky/MI66-T5 | /Lista 5/L5E01.py | UTF-8 | 382 | 4.46875 | 4 | [] | no_license | #Faça um programa para imprimir:
# 1
# 2 2
# 3 3 3
# .....
# n n n n n n ... n
#para um n informado pelo usuário. Use uma função que receba um valor n inteiro e imprima até a n-ésima linha.
#Exercicio 1
valor = (int(input("Informe o valor de n: ")))
def exec1(n):
for x in range(n):... | true |
64abe4cb9aa9223b20bb42f781cd04de3cc4757f | c-oreills/teabot | /weigh.py | UTF-8 | 737 | 2.53125 | 3 | [] | no_license | import spidev
from sample import repeated_proportional_sample
s = spidev.SpiDev()
s.open(0, 0)
# Default accuracy, takes about a half second to take this many readings
ACCURACY = 2000
tare_value = 0
def weigh_raw():
bytes = s.xfer2([1, 0, 0])
reading = bytes[1] & 3
reading = reading << 8
reading +=... | true |
31a34479b91b1e7853e91beedebc7a3196896c72 | k-bigboss99/ATTACK-DEFENCE | /python_base/python.py | UTF-8 | 256 | 3.078125 | 3 | [] | no_license | std_Score = int(input('Scores of stds: '))
if(std_Score < 60):
print('failed')
elif(60 < std_Score < 80):
print('okay')
else:
print('nice')
print('A')
print('A')
print('A')
print('A')
print('A')
print('A')
print('A') | true |
b91e7a13fdd07376996446177d0f811a71de6e66 | Ishita-Tiwari/competitive-programming | /Codeforces/1334A.py | UTF-8 | 432 | 3.09375 | 3 | [] | no_license | t = int(input())
for T in range(t):
n = int(input())
stats = []
ans = 'YES'
for i in range(n):
stats.append([int(x) for x in input().split()])
if stats[i][0] < stats[i][1]:
ans = 'NO'
for i in range(1, n):
d1 = stats[i][0] - stats[i - 1][0]
d2 = stats... | true |
730d3059226025c598dec12b3c486325628f293d | fengchuiguo1994/little_tools | /markgene.longest.py | UTF-8 | 13,619 | 2.59375 | 3 | [] | no_license | import sys
from collections import OrderedDict
def parseString(mystr):
d = OrderedDict()
if mystr.endswith(";"):
mystr = mystr[:-1]
for i in mystr.strip().split(";"):
tmp = i.strip().split()
if tmp == "":
continue
d[tmp[0]] = tmp[1].replace("\"","")
return d
... | true |
f11727dd43137c25f9095dbf72b8764d32599d5e | rsprouse/phonlab | /phonlab/utils.py | UTF-8 | 17,116 | 2.90625 | 3 | [
"BSD-3-Clause"
] | permissive | # Utility functions.
import os
import pandas as pd
import numpy as np
import re
import fnmatch
import shutil
from datetime import datetime
import dateutil
def get_timestamp_now(timespec='seconds'):
'''
Create a timestamp for an acquisition, using current local time.
Returns
-------
timestamp, o... | true |
cde37bb9aa79f294cd9f4285994a9eff0cca71d6 | jefffall/netapp_nmsdk_python_module_install_with_pip3 | /sample_nmsdk_usage.py | UTF-8 | 3,552 | 2.5625 | 3 | [] | no_license | from netapp_nmsdk import NaElement, NaServer # for NMSDK
def is_filer_7mode_get_ontap_ver(filer):
"""
Returns ontap version for 7 mode filer.
Uses NMSDK.
Keyword arguments:
filer -- A valid filer DNS name or IP address
Returns:
Error message "FAILED 7MODE" and reason if failed to get ont... | true |
d2b6989f7a5c6719592cd043af10c2ce2c521852 | jdewee/Practice | /tictac.py | UTF-8 | 250 | 3.328125 | 3 | [] | no_license | '''matrix = [['x','o','x'], ['x','o','x'], ['x','o','x']]
for x in matrix:
for i in x:
print(i)
print
'''
x = 0
while x < len(matrix):
i = 0
while i < len(matrix[x]):
print(matrix[x][i])
i += 1
x += 1
| true |
11cbe96a9837d179626cbde79753cd838179bf8f | Aasthaengg/IBMdataset | /Python_codes/p03829/s195653957.py | UTF-8 | 188 | 3.078125 | 3 | [] | no_license | n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ans = 0
maxwalk = b//a
for i in range(n-1):
if x[i+1]-x[i]>maxwalk:
ans+=b
else:
ans+=(x[i+1]-x[i])*a
print(ans) | true |
016810fcca285d2a373df864aec1b680acefb9c2 | jklhj222/bin | /ITRI_ADAT/OCR/OCR_test_plot_Label.py | UTF-8 | 1,412 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env python3
import matplotlib.pyplot as plt
from PIL import Image, ImageDraw, ImageFont
import os
import argparse
import glob
parser = argparse.ArgumentParser()
parser.add_argument('--img_dir', default=None)
parser.add_argument('--out_file', default='test.png', help='default: test.png')
parser.add_argument... | true |
e1cc16634cbe12116ba6b9564eb29479bc238c53 | Akki1994-DS/Data-Science-2020 | /Emails.py | UTF-8 | 2,504 | 3.203125 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 2 10:35:24 2020
@author: axays
"""
import pandas as pd
import numpy as np
import nltk
from nltk.corpus import stopwords
import string
import matplotlib.pyplot as plt
import seaborn as sns
mails=pd.read_csv('C:\\Users\\axays\\Downloads\\emails')
mails.... | true |
97c5905f673c66237efb1423c9318d7f507032d5 | Mespn520/400B_Klein | /Homeworks/Homework6/OrbitCOM.py | UTF-8 | 4,672 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env python
# coding: utf-8
# In[1]:
# Homework 6
# Michael Klein
# Worked with Trevor Smith and James Taylor
# import modules
import numpy as np
import astropy.units as u
from astropy.constants import G
# import plotting modules
import matplotlib.pyplot as plt
import matplotlib
# my modules
from ReadFi... | true |
69191c1a3c0850c7210d519c4df9c905f3f3b050 | heitorchang/reading-list | /grego_guia_conv/convert_book_to_html.py | UTF-8 | 3,878 | 3.015625 | 3 | [] | no_license | # For part_contents.txt
#
# make hyperlinks
# For part_content.txt
#
# idea: check code point of first character,
# if it's in the range of greek, apply a CSS class
# if first word is number and first char of second word
# is A-Z, then make it a header
# For part_appendix.txt
#
# create headers only
... | true |
f93f73331cea1e6bfc239e2586cced26a84e2755 | karanarya4196/Bag-of-Words-Classifier | /Spacy_Tagging.py | UTF-8 | 20,986 | 2.796875 | 3 | [] | no_license |
# coding: utf-8
# In[1]:
import spacy
from spacy import displacy
import re
import nltk
# In[2]:
nlp = spacy.load('en_core_web_lg')
#nlp = spacy.load('C:\\anaconda3\\lib\\site-packages\\en_core_web_sm\\en_core_web_sm-2.0.0')
# In[7]:
# doc=nlp(u'hello')
# b=doc.to_bytes()
def get_pos_entities_parsed(sent):
... | true |
3810baec947c4f454102456ae9cc971cc30153ac | gitRobV/DojoAssignments | /Python/OOP/product.py | UTF-8 | 2,052 | 3.859375 | 4 | [] | no_license | class Product(object):
"""docstring for ."""
def __init__(self, item_name, price, weight, brand, cost, status = "for sale"):
self.item_name = item_name
self.price = price
self.weight = weight
self.brand = brand
self.cost = cost
self.status = status
def sell(s... | true |
83f4e8d1c20b24bce6fc0324f7cfde8fd522bc9c | krishnamaddula/algorithmic-toolbox | /week1/max_pairwise_product.py3 | UTF-8 | 434 | 3.265625 | 3 | [] | no_license | def max_pairwise_product(n, a):
max1 = -1
max2 = -1
for i in range(0, n):
if (max1==-1 or a[i] > a[max1]):
max1 = i
for i in range(0, n):
if (i != max1 and (max2==-1 or a[i] > a[max2])):
max2 = i
return (a[max1]*a[max2])
if __name__ == '__main__':
n = in... | true |
131967d12c0a7ab9f004b74dd92c4421c78fd807 | Jeanne-Chris/Assert-code-sample-in-list | /sumList.py | UTF-8 | 362 | 4.125 | 4 | [] | no_license | # This sums up the numbers in list and return 0 if length of list is 0.
numlist = [1, 2, 3, 4, 5]
def sumList(numlist):
totalnum = 0
try:
totalnum = sum(num for num in numlist if len(numlist) != 0)
return totalnum
except ValueError: return 0
print(sumList(numlist))
assert sumList(numlist)... | true |
d918d2859fa310811539e3123d49a15879994422 | ViVaHa/Leetcode | /Strings/5.py | UTF-8 | 954 | 2.9375 | 3 | [] | no_license | class Solution:
def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
if len(s)==0:
return ""
n=len(s)
dp=[[False for j in range(len(s))] for i in range(len(s))]
x=0
y=0
maxlen=0
for i in range(len(s)):
... | true |
dfd9827858290c18cc0e2f636e398dcd20cbc9e8 | LeiLu199/assignment6 | /fs1214/interval/exceptions.py | UTF-8 | 946 | 3.125 | 3 | [] | no_license | '''
Created on Oct 26, 2014
@author: ds-ga-1007
'''
class IntervalInputException(Exception):
"""
Raise when the input of interval is a invalid form
"""
def __str__(self):
return "The input is not an interval! An interval must have: '(' or '[', two integers separated by ',', and ')' or ']'!"
... | true |
01a11cf646ef3c2595fc6067d71117bb3814c8ef | bazithali/aoc | /2020/day2.py | UTF-8 | 853 | 3.53125 | 4 | [] | no_license | """
Created on 02-12-2020
@author: Basit
"""
def check_first_policy(password_data):
min_c, max_c = map(int, password_data[0].split('-'))
alphabet = password_data[1][0]
alph_count = password_data[2].count(alphabet)
return min_c <= alph_count <= max_c
def check_current_policy(password_data):
pos1... | true |
c740f665fa0256339a57ab9bccb1691ddb86ae9b | m-note/100knock2015 | /sakaizawa_python/knock007.py | UTF-8 | 189 | 3.375 | 3 | [] | no_license | #!/usr/bin/python
# -*- coding:utf-8 -*-
def knock007(x, y, z):
return "%s時の%sは%s" % (str(x), y, str(z))
if __name__ == "__main__":
print knock007(12, "気温", 22.4)
| true |
a0d1859e0266dcfb4cf9f7777999461bced4f379 | Shivapunit/IT-Support-Tickets-Optimization-with-Machine-Learning | /Tickets classification with IBM Watson.py | UTF-8 | 12,497 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
"""
Created on Sat Jun 23 18:41:32 2018
@author: yipin
"""
import pandas as pd
import os
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('ggplot')
os.chdir("C:/Intern/Project/Final")
import pandas as pd
import os
import matplotlib.pyplot as plt
%matplotlib inli... | true |