blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b0aef07a91f900947a13900a2fdeaa0d46ac336b | mrbahrani/File-Managment-AP-Project | /search.py | 6,306 | 3.890625 | 4 | """
| This file including all functions and variables needed for searching inside directories of all of the memory.
| The list of including functions:
| 1.return_equals
| 2.return_equals_step_by_step
| 3.search
| 4.step_by_step_search
|
| Including variables:
| 1.search_list:list
"""
from os import listdir
from funcs ... |
89e712cf0ccc852076c7994a0822af1f00262849 | kushinyi/Class0221_Project | /ClassP01.py | 249 | 3.546875 | 4 | grades=[[5,14,7],[23,36,28],[88,80,92]]
print(grades[0])
print(sum(grades[0])/len(grades[0])) #國文平均
print(sum(grades[1])/len(grades[1])) #英文平均
print(sum(grades[2])/len(grades[2])) #數學平均
grades.append([94,90,96])
print(grades) |
d405e3040ebb118d397716cce763b1309dfde8ca | asuhail1270106/ITMD-413_FP | /src/myDatabase.py | 4,038 | 3.90625 | 4 | # Programmed by Abdullah Suhail
# myDatabase.py
# 04/21/2018
# ITMD 413 Spring 2018 - Final Project
# Professor James Papademas
# This program will allow users to view and rate television shows
# from a database called shows.db using a GUI interface
# the sqlite3 module lets you create databases and manipulate... |
a7ea1ea8e34a87ba829a58a542dd7ddb7d9fea6d | Nadine02/github_oer | /crawling/GitHubRepoFinderByTopic.py | 2,945 | 4.0625 | 4 | """ Find suitable repositories on Github, given a list of relevant topics.
Potentially interesting topics are listed in the topics list in the searching folder.
This script communicates with the Github API to request all known repositories, that are tagged with at least one of the given topics.
For each to... |
d5b6a8d45514a33695ac231e635bd0e107096c38 | GreStas/PyBase20200110 | /lesson03_def.py | 140 | 3.578125 | 4 | def f1(val):
# тут Python выполняет va = переданное значение
print('val =', val)
a = f1(25)
print(a)
|
9551472aa37f2f47e4a8a86c0254ddc1cada5379 | Daewooer/CoolProblem | /main.py | 326 | 3.5625 | 4 | import random
def estimate_pi(n):
num_point_circle = 0
num_point_total = 0
for _ in range(n):
x = random.uniform(0,1)
y = random.uniform(0,1)
distance = x**2 + y**2
if distance <= 1:
num_point_circle += 1
num_point_total += 1
return 4 * num_point_circle/num_point_... |
106bc497fec81823250a248de6912a5c3458fcbf | Omkar-M/Coffee-Machine | /Problems/The Louvre/task.py | 377 | 3.9375 | 4 | class Painting:
def __init__(self, title1, artist1, year1):
self.title = title1
self.artist = artist1
self.year = year1
def print_value(self):
print(f'"{self.title}" by {self.artist} ({self.year}) hangs in the Louvre.')
title, artist, year = [input() for x in range(3)]
paintin... |
d6ec5353a03833a20ebe4789d1a250762a79a6f0 | J4VJ4R/pythonCourse | /conditionals/ifarray.py | 117 | 3.625 | 4 | #!/usr/bin/python3
house1 = ['sr', 'ms', 'young', 'villain']
if 'villain' in house1:
print ("we found villain") |
71a4461971b219110e35c97714a7fdac5cb18c2f | ydyrx414/learn_py | /chapter6/exercise6-6.py | 324 | 4.03125 | 4 | favorite_language = {
'jen': 'python',
'sarah': 'c',
'edward': 'ruby',
'phil': 'python',
}
names = {'jen': 'python','sarah': 'c'}
for name in favorite_language.keys():
if name in names.keys():
print("Thank you for your participation")
else:
print("Please take the investigation"... |
fe162ee1d9ee4d13aedc26d2ffa75b0b6d2ff709 | hakancemG/Python-FaceRecognitionOnVideo | /Python Face Recognition on Video/face_recognition_video_pogram.py | 1,130 | 3.65625 | 4 | # Author : Hakan Cem Gerçek / hkncm-github.
# Face recognition by input video
#import 'OpenCV' & 'face recognition' libraries.
import cv2
import face_recognition_models
#Get a reference to video.
video_capture = cv2.VideoCapture('videoname.mp4')
#Declare path of Haarcascade.
face_cascade = cv2.CascadeClas... |
1dcd813e96f82ce2f7af94b6481cb54acea83d81 | srikanthpragada/pythondemo_21_june_2019 | /funs/pass_by_value.py | 356 | 3.625 | 4 | # Cannot change actual parameter through formal parameter as object is immutable
def change(n):
print(id(n))
n = 0
print(id(n))
# Can change actual parameter through formal parameter as object is mutable
def add_to_end(lst, v):
lst.append(v)
a = 100
print(id(a))
change(a)
print(id(a))
print(a)
l = ... |
3b6bf20b899b7dee3f63b15c84551fe9faae4c52 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/largest-series-product/1ebacb70a5944f35b45f2086a3d057fc.py | 786 | 3.53125 | 4 | class Series(object):
def __init__(self, numbers) :
self.numbers=[int(n) for n in numbers]
def slices(self, n) :
"""Produces all series of length n from the sequence
Raises ValueError if n<=0 or longer than the sequence
"""
if n <= 0 or n > len(self.numbers) :
... |
e5db940fd61bba76dafc849b54ea26e8aaf15aed | Ryxai/harp | /heapqueue.py | 6,243 | 3.859375 | 4 | from typing import *
from math import floor
class HeapQueue:
"""
Derived from Skeina's heapqueue implementation provides a heapq like interface with the a key function
(and type annotations!), does not require mappings to reorder a priority queue. Note that implicitly this is a
minheap and can be turn... |
65272af12146c9cd1f47e084a68d557f1d1073dd | uloga/python_misc | /classes/switch.py | 813 | 4.03125 | 4 | #######################
# simple switch class
class Switch:
def __init__(self, case=None):
self.case = case
def __iter__(self):
yield self.match #yield match once
raise StopIteration
def match(self, *args):
if self.case in args:
return True
else:
... |
f733f6d9a8c06061bb5ed1e69e1ce3b3a9a0b9b4 | liyl0663/liyl | /python/day05/zhan.py | 634 | 3.8125 | 4 | stack = []
def push_it():
item = input('item to push:')
stack.append(item)
def pop_it():
if stack:
print('\033[33mfrom stack poped %s\033[0m' % stack.pop())
def view_it():
print(stack)
def show_menu():
cmd = {'0':push_it,'1':pop_it,'2':view_it}
prompt = """(0)push it
(1)pop it
(2)view... |
65c8255a5322263c489c6657bfd3badec9ec8122 | YoungHo-Jo/algo | /Backjoon/02166_포도주_시식/main.py | 491 | 3.625 | 4 | n = int(input())
cups = []
for _ in range(n):
cups.append(int(input()))
cache = [[0 for _ in range(3)] for _ in range(n)] # [the index of the cup][the number of cups that was drunken]
for wineIdx in range(n):
if wineIdx == 0:
cache[wineIdx][1] = cups[wineIdx]
continue
cache[wineIdx][0] = max... |
c103b75e0243d8f6faa151868ea32e6c291694fb | YoyinZyc/Leetcode_Python | /Google/Pro270. Closest Binary Search Tree Value.py | 965 | 4.03125 | 4 | '''
题意:
找到BST中和target最接近的数字
注意这个target是float类型的
本质是遍历BST
'''
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def closestValue(self, root, target):
"""
:type root: TreeN... |
56f79c894d52bc721f9551f0e965b82a5f8fc186 | xdr940/utils | /grd_depth/test3.py | 629 | 3.515625 | 4 | #d(dx,alpha,h)
#当dx增大时, d的关系为越大越正比
import numpy as np
import matplotlib.pyplot as plt
import math
from math import pi
from numpy import sin,sqrt,tan
#x = [0:0.1:pi]
theta = np.linspace(0,pi/4,100)
#ag = 45
#alpha = ag*2*pi/360
alpha45 = pi/8
alpha30 = pi/36
h=50
dx = np.linspace(0,30*h,100)
#print(temp)
#y= (sin(alph... |
e7501d120782211ff24415b53cbb39e9a1948644 | haoxu13/ud120-projects | /outliers/outlier_cleaner.py | 765 | 3.78125 | 4 | #!/usr/bin/python
def outlierCleaner(predictions, ages, net_worths):
"""
Clean away the 10% of points that have the largest
residual errors (difference between the prediction
and the actual net worth).
Return a list of tuples named cleaned_data where
each tuple is of the f... |
8d0cedd8f61f6e7aef01946913a4d833dc3c6554 | Caaddss/livros | /gui.py | 4,479 | 3.828125 | 4 | from tkinter import *
class gui():
window = Tk()
window.wm_title("Minha Biblioteca")
# Variáveis
txtTitulo = StringVar()
txtSubtitulo = StringVar()
txtEditora = StringVar()
txtAutor1 = StringVar()
txtAutor2 = StringVar()
txtAutor3 = StringVar()
txtCidade = StringVar()
txtAno = ... |
14b4258232a1c746f58ffaa7d862715ff76552bd | Programmerryoki/Matrix | /MatrixClass.py | 1,042 | 3.515625 | 4 | from typing import List, Tuple
class Matrix:
matrix = None
_size = None
def __init__(self, size: Tuple[int] = None,
matrixlist: List[List[int]] = None,
matrix: "Matrix" = None,
**kwargs):
if size:
self._size = size
def size(self)... |
00235c84fbcc27127eb166d416161cdc4f2daca2 | moonseokho85/TIL | /A.I/10_Keras/keras15_LSTM3_verbose.py | 1,215 | 3.5625 | 4 | from numpy import array
from keras.models import Sequential
from keras.layers import Dense, LSTM
# 데이터 준비
x = array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12], [20, 30, 40], [30, 40, 50], [40, 50, 60]])
y = array([4, 5, 6, 7, 8, 9, 10, 11, 12, 1... |
840cfd3c122dba5807f38e7bb62b39bc952f126a | Krishna219/Fundamentals-of-computing | /Principles of Computing (Part 2)/Week 2/my_solution.py | 2,154 | 3.84375 | 4 | def triangular_sum(num):
"""
Sum of n numbers
"""
if num == 0:
#base case
return 0
else:
return num + triangular_sum(num - 1)
#recursive case
for i in range(11):
print triangular_sum(i)
def number_of_threes(num):
if num//10 == 0:
if num == 3:
... |
6f00c9332978c5bb23d1255d66197ac79d899c68 | cosJin/LeetCode | /old/Hash/136.py | 392 | 3.59375 | 4 | class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
nums.sort()
dic = 0
for i in range(len(nums)):
if i%2 == 0:
dic+=nums[i]
elif i%2 == 1:
dic-=nums[i]
... |
4e604e60fdf3f403e59c2b77c0704eb70d1669ef | sebastinaa/python-learn | /数据分析/code/numpy/03-NumPy数组属性.py | 1,019 | 3.5 | 4 | # -*- coding:utf-8 -*-
import numpy as np
'''
ndarray.shape
这个数组属性返回一个包含数组维度的元组,它也可以用于调整数组大小
'''
# a = np.array([[1,2,3],[4,5,6]])
# print(a)
# print(a.shape)
#调整数组大小
# a = np.array([[1,2,3],[4,5,6]])
# a.shape=(3,2)
# print(a)
'''
reshape 调整数组大小
'''
# a = np.array([[1,2,3],[4,5,6]])
# b = a.reshape(3,2)
... |
b11e53e7e8eb9728742da025cf1cb147ef3e7a6c | ryanyuchen/Data-Structure-and-Algorithms | /1 Algorithmic Toolbox/Week 2 Algorithmic Warm-up/week2_algorithmic_warmup/1_fibonacci_number/fibonacci.py | 811 | 3.703125 | 4 | # Uses python3
import random
def calc_fib(n):
if (n <= 1):
return n
return calc_fib(n - 1) + calc_fib(n - 2)
def calc_fib_fast(n):
if (n <= 1):
return n
else:
res = [None] * (n+1)
res[0] = 0
res[1] = 1
for i in range(2,n+1):
res[i] = res[i-1... |
3b44be6e0ff4632d9d0aab239c1e371f25990e18 | arpanmangal/Abusive-Language-Style-Transfer | /model/convert.py | 448 | 3.609375 | 4 | """
Converting the Abusive Speech to Normal Speech
"""
import re
from . import translate as tr
from . import preprocess as pp
def convert (sentence, mode='fr'):
"""
Remove the hate and convert to non-offensive sentence
"""
processed_sentence = pp.preprocess(sentence)
if (len (processed_sentence... |
b83cbc8ce1f749e6468e397192a6b3bda08a2822 | alehpineda/python_morsels | /orderedset/orderedset.py | 1,744 | 3.59375 | 4 | from collections.abc import MutableSet, Sequence
class OrderedSet(MutableSet):
def __init__(self, items):
self.items = dict.fromkeys(items, None)
def __iter__(self):
for item in self.items:
yield item
def __len__(self):
return len(self.items)
def __contains__(sel... |
e51e438204075eb19f20cbd51aed8915e43365e1 | erjan/coding_exercises | /number_of_closed_islands.py | 4,265 | 3.546875 | 4 | '''
Given a 2D grid consists of 0s (land) and 1s (water). An island is a maximal 4-directionally connected group of 0s and a closed island is an island totally (all left, top, right, bottom) surrounded by 1s.
Return the number of closed islands.
'''
class Solution:
def closedIsland(self, grid: List[List[int]]) -> i... |
c3a073ad2a536f86db97e1b4850fb956d516e547 | ryeLearnMore/LeetCode | /078_subsets.py | 1,978 | 3.96875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#@author: rye
#@time: 2019/3/20
# 这是什么神仙思路啊,好难。。。
'''
想到有可能用递归去做,但是真的不知道怎么实现。多学习。。。
其他解题思路:https://github.com/ryeLearnMore/awesome-algorithm/blob/master/docs/Leetcode_Solutions/Python/078._Subsets.md
19.3.23。又看了一遍,觉得这种回溯方法设计的很巧妙,值得多学习,多看几遍。
'''
class Solut... |
c314c987271d06da9caf75f949517c4d30d95da9 | HEKA313/lab_8 | /Task.py | 3,436 | 4.03125 | 4 | import math
import sys
def is_there_the_triangle(a1, b1, c1, a2, b2, c2): # Проверка существования треугольника
check = True
if a1 <= 0 or b1 <= 0 or c1 <= 0 or a2 <= 0 or b2 <= 0 or c2 <= 0:
print("Треугольника с отрицательными сторонами не бывает)")
check = False
if not (a1 + b1 > c1 and a1 + c1 > b1 and b1... |
43cc94ecb08bb6ef18a3c57c4c6d2034df30f78b | NikhilaBanukumar/GeeksForGeeks-and-Leetcode | /insertionsort.py | 234 | 3.734375 | 4 | # O(n2)
def insertion(a):
for i in range(1,len(a)):
key=a[i]
j=i-1
while j>=0 and key<a[j]:
a[j+1]=a[j]
j-=1
a[j+1]=key
return a
a=[12,11,13,5,6]
print(insertion(a))
|
9eddee6a143a46e42055bdac8f016a98a8d7a748 | python-practice-b02-927/vernovskaya | /lab2/task72.py | 189 | 3.59375 | 4 | import turtle
from math import sin
from math import cos
from math import pi
t = turtle.Turtle()
t.shape('turtle')
for i in range(1, 100):
t.goto(i*sin(pi/10), i*cos(pi/10))
input()
|
78c99a618d4d0f7f72b9af5c6cf11fee1d8dc716 | santoshpy/algorithms-1 | /heap.py | 2,087 | 3.859375 | 4 | import sys
MAX_INT = sys.maxint
'''
Heap data structure
-------------------
Maintains a balanced binary tree, where the value of each node is never larger than the values of its children.
The tree is represented using an array, since it is easy to calculate the index of the parent/child of a given
element (see __find_... |
8b673813e87f5615b55bfaf22cd7c0b5c56a4f6f | Fulvio7/curso-python-guppe | /guppe/exercicios_secao_8/ex_11.py | 1,087 | 4.15625 | 4 | """
11- Elabore uma função que receba três notas de uma aluno como
parâmetros e uma letra. Se a letra for 'A', a função deve retornar a
média aritmética das notas do aluno; se for 'P', deverá calcular a média
ponderada, com pesos: 5, 3 e 2.
"""
def calcula_media(nota1, nota2, nota3, tipo_media):
if tipo_media == ... |
91559591ccce766559c896dde76cbbd368897f8a | kindlyhickory/Homework_1 | /lesson02/ex2_3.py | 1,573 | 3.890625 | 4 | while True:
try:
month = int(input('Введите номер месяца: '))
months_dict = {1: 'зима январь',
2: 'зима февраль',
3: 'весна март',
4: 'весна апрель',
5: 'весна май',
6: 'лето июнь',
... |
2dced53043e090a185945611e7b0f893e88e297d | max180643/PSIT-IT | /Week-16/BloodDonation.py | 527 | 3.796875 | 4 | """
BloodDonation
Author : Chanwit Settavongsin
"""
def main(age, weight, time, answer):
""" BloodDonation check """
if age == 17 or (age >= 60 and age <= 70):
cert = input()
if age >= 17 and age <= 70 and weight >= 45 and \
(time > 0 or (time == 0 and age <= 55)) and cert == "True":
... |
25b2315e39eed9bb7c810a434b483371181f3cb8 | entrkjm/pythonAlgorithms | /2675.py | 216 | 3.53125 | 4 | num = int(input())
for i in range(num):
R, S = input().split()
R = int(R)
# split : distinguish input value by blank
S = str(S)
for j in range(len(S)):
print(R * S[j], end ='')
print() |
5d292459a0555526abb3c8f984dedc5245e3a056 | greenfrog82/DailyCoding | /Codewars/4kyu/4kyu_valid_braces/src/other_1.py | 457 | 4.15625 | 4 | def validBraces(string):
while '{}' in string or '()' in string or '[]' in string:
string = string.replace('{}', '')
string = string.replace('()', '')
string = string.replace('[]', '')
return '' == string
print validBraces('(){}[]') == True
print validBraces('([{}])') == True
print val... |
0f2f19336e93d61cc33161ec3307cdead1677ee5 | shawnq8861/Python-Examples | /PythonPractice.py | 1,392 | 3.71875 | 4 | """
Practice from Chapter 12, 13
"""
if 1:
print('hello')
x = 'spam'
while x:
print x,
x = x[:-1]
print '\n'
a = 0
b = 10
while a < b:
print a,
a += 1
def funct1():
pass
print '\n'
x = 10
while x:
x -= 1
if x % 2 != 0: continue
print x,
print '\n'
x = 10
while x... |
e1ecd71413bbb91aa449fdff63a093eb91333e5b | menglingshu/Python_Exercises | /MyTimer.py | 1,448 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 21 16:46:01 2018
@author: Lingshu
"""
import time as t
class MyTimer():
def __init__(self):
self.unit = ['years', 'month', 'day', 'hour', 'min', 'second']
self.prompt = 'not yet begin timer'
self.lasted = []
self... |
cbe44fe160f83d90c07feceb4da38b4b0b4aeb70 | DFYT42/Python---Beginner | /Python_Turtle_Clock.py | 2,073 | 4.6875 | 5 | ##Create a clock image with Turtles
##Import Turtle module
import turtle
##Initialize Turtle Screen
wn = turtle.Screen()
##Set Background color
wn.bgcolor("Black")
##Set Window Title
wn.title("Python Turtle Clock")
##Initialize Turtle
alex = turtle.Turtle()
##Set Turtle color and shape
alex.color("ora... |
f4d46512cd3aadbd47e782df5fc0e2b65714012e | andersonOlliver/criptography-aes | /util/params.py | 1,258 | 3.546875 | 4 | from typing import TextIO
from util.mode import Mode
class Param:
sizeKey: int
key: str = ''
file: TextIO
pathFile: str = ''
operationMode: Mode = Mode.UNDEFINED
def __init__(self, mode: Mode):
self.operationMode = mode
print("Já vamos começar! Mas primeiro precisamos de alg... |
cc6fbc7c2097a37440c18775d314e8e7dc15070b | danielsummer044/EDUCATION | /find_count.py | 308 | 3.5625 | 4 | arr = [21, 23, 31, 34, 11, 111, 17, 12, 7, 5]
a = 2
b = 4
def find_count(n):
count = 0
while n > 0:
digit = n % 10
n = n // 10
count = count + 1
return count
for i in range(len(arr)):
count = find_count(arr[i])
if count > a and count < b:
print((arr[i]))
|
886876c0027331761ab8290207d001d7c7b0806c | LXSkyhawk/cp2015 | /practical4/q5_count_letter.py | 424 | 4.03125 | 4 | def count_letter(str, ch):
str = str.lower()
ch = ch.lower()
if len(str) == 1:
if str[0] == ch:
return 1
else:
return 0
elif str[len(str) - 1] == ch:
return 1 + count_letter(str[:-1], ch)
else:
return count_letter(str[:-1], ch)
string = input(... |
398670cfbceb0d423b1f25297302d71ad628e843 | yuichiro-cloud/coder | /pai/1.py | 408 | 3.609375 | 4 | leet = list(input())
print(len(leet))
for i in range(len(leet)):
if leet[i] == 'A':
leet[i] = '4'
elif leet[i] == 'E':
leet[i] = '3'
elif leet[i] == 'G':
leet[i] = '6'
elif leet[i] == 'I':
leet[i] = '1'
elif leet[i] == 'O':
leet[i] = '0'
elif leet[i] == 'S':
leet[i] = '5'
elif lee... |
e5bccbb3c9be373eaf2bd9091b01e747a70d1749 | mvind/hangman | /hangman.py | 14,402 | 4.0625 | 4 | # Problem Set 2, hangman.py
# Name:
# Collaborators:
# Time spent:
# Hangman Game
# -----------------------------------
# Helper code
# You don't need to understand this helper code,
# but you will have to know how to use the functions
# (so be sure to read the docstrings!)
import random
import string
WORDLIST_FILENA... |
0e632642560677d7ea3ff28b58eef0026ac5c305 | vijaynitrr/python-code | /code/inheritance.py | 344 | 3.640625 | 4 | class First(object):
def __init__(self):
print "first"
class Second(object):
def __init__(self):
print "second"
class Third(object):
def __init__(self):
print "third"
class Fourth(First ,Second, Third):
def __init__(self):
super(Fourth, self).__init__()
print "... |
884a34a1878b9e4b93ccb0d98f03ceaf62c31ddf | bhagavansprasad/students | /rahul/python/strings.py | 4,139 | 3.5625 | 4 | test_str = "Aura Networks Bangalore"
print test_str
for byte in test_str:
print byte,
print ""
print len(test_str)
i = 0
while (i < len(test_str)):
print test_str[i],
i += 1
print ""
print test_str[0]
print test_str[1]
print test_str[-1]
print test_str[-2]
print test_str[1:6]
print... |
bbb2a3c28d4cb5043f8e65bab209d7e822843719 | AbhijeetKrishnan/codebook | /CodeChef/APRIL17/SIMDISH.py | 525 | 3.59375 | 4 | t = int(input())
for test in range(t):
dish1 = input().split()
dish1.sort()
dish2 = input().split()
dish2.sort()
similar_ingredient_count = 0
i, j = 0, 0
while i != len(dish1) and j != len(dish2):
if dish1[i] == dish2[j]:
similar_ingredient_count += 1
i += 1
... |
87c7109d2527931cf1afc84802e7189b00aee531 | roykroth/Project_Euler | /problem14.py | 383 | 3.859375 | 4 | import numpy as np
def collatz(n):
yield n
while n != 1:
if n % 2 == 0:
n = n/2
else:
n = 3*n + 1
yield n
def coll_len(n):
return len([i for i in collatz(n)])
longest = 0
longest_num = 3
for i in xrange(3, int(1e6)):
l = coll_len(i)
if l > longest:... |
83944d37a537eb098f45826c5ec82c320cea7383 | JamieCass/pynotes | /regex.py | 10,042 | 3.59375 | 4 | #######################################################################
# Regular Expressions (REGEX)
#######################################################################
##########################################
# What are Regular Expression
##########################################
# - A way of desscribing patt... |
532ccfeeeb90f0253f797033fe95b1fd3f1634c4 | jkpubsrc/python-module-jk-console | /examples/colorizedoutput.py | 282 | 3.5 | 4 | #!/usr/bin/env python3
#
# This example demonstrates how to write colored text to STDOUT.
#
from jk_console import Console
print(Console.ForeGround.CYAN + "Hello World!" + Console.RESET)
print(Console.BackGround.rgb256(128, 0, 0) + "Hello World!" + Console.RESET)
|
54dd16013ae3d8305ee28a192a8d133e83650182 | AlyxMoon/Project-Euler-Solutions | /Python34/Problem24.py | 771 | 3.546875 | 4 | def get_nth_lexic_permutation(digits, goal):
count = 1
while(count < goal):
end = len(digits)
i = end - 1
while(digits[i - 1] >= digits[i]): i -= 1
j = end
while(digits[j - 1] <= digits[i - 1]): j -= 1
digits[i - 1], digits[j - 1] = digits[j - 1], digits[i - 1]
i += 1
j = end
while(i <... |
a2cf45e96c7cdffb441a5dc68530b5b32397afe6 | Kourtz/coding_bootcamp | /Common_courses/Python/day_2/ex_05.py | 511 | 3.59375 | 4 | import math
y= int(input('Enter year between 1900-2099:'))
if y>2099 or y<1900:
print("Error")
a=y%4
b=y%7
c=y%19
d=(19*c+15)%30
e=(2*a+4*b-d+34)%7
month=math.floor((d+e+114)/31)
day=(d+e+114)%31+1
day2=day+13
if month==3 or month==5:
if day2>31:
day2=day2-31
month=month+1
else:
... |
353cda36345449e9403d4d1ebf4ad3ed8e8a2874 | ykumards/project-euler | /python_sols/problem17.py | 2,304 | 3.90625 | 4 | import math
"""
Problem 17
Learn to spell out all the numbers properly before attempting this!
There's scope for memoization, but the speed issue only arises when scaled
much higher
"""
def getDigit(n):
if n == 1:
return "one"
elif n == 2:
return "two"
elif n == 3:
return "three"
... |
c12e5db1a086f41fb81baf81b73b23bc54823090 | dario-castano/holbertonschool-higher_level_programming | /0x0A-python-inheritance/1-my_list.py | 263 | 3.765625 | 4 | #!/usr/bin/python3
class MyList(list):
"""Class who inherits from list"""
def __init__(self):
"""Initializer"""
super().__init__()
def print_sorted(self):
"""Returns the list but sorted"""
print(sorted(self.copy()))
|
e9c8a825e6d5020826676e1696ab3b530047b3a8 | roque-brito/ICC-USP-Coursera | /icc_pt2/week3/poo/exemplos_basico.py | 711 | 3.859375 | 4 | class Carro:
pass # classe vazia
# cria uma instância "meu_carro":
meu_carro = Carro()
print(meu_carro) # nome da instancia __main__, junto com o endereço na memória
# podes criar outra instância:
carro_ime = Carro()
print(carro_ime) # observar o endereço diferente na memoria
# criar atributos ao objeto (instanc... |
b57753327799a69efcb0d3fa09b6182059231406 | yin-hong/cs231n-assignment | /cs231n-assignment1/linear_svm.py | 3,551 | 3.578125 | 4 | import numpy as np
def svm_loss_naive(W,X,y,reg):
"""
Structured SVM loss function, naive implementation (with loops).
Inputs have dimension D, there are C classes, and we operate on minibatches
of N examples.
note delta = 1
Inputs:
- W: A numpy array of shape (D, C) containing weights.
... |
e89e76ed33aa5c259424459f7a77cc9f4a6df78d | kurumeti/Market-Basket-Analysis | /edm/apriori.py | 4,420 | 3.90625 | 4 | """
Description:
An Effectively Python Implementation of Apriori Algorithm for Finding Frequent
Sets and Association Rules
"""
from collections import defaultdict
import csv
class Apriori(object):
def __init__(self, minSupp, minConf):
""" Parameters setting
"""
self.minSupp =... |
bf96519dbebb33053341b02de2e6932938d50797 | daily-boj/dryrain39 | /P14405.py | 400 | 3.75 | 4 | if __name__ == '__main__':
pikachu_str = input()
while "pi" in pikachu_str or "ka" in pikachu_str or "chu" in pikachu_str:
pikachu_str = pikachu_str.replace("pi", "_OK_")
pikachu_str = pikachu_str.replace("ka", "_OK_")
pikachu_str = pikachu_str.replace("chu", "_OK_")
pikachu_str = ... |
0bfa7e8c611b970cde47dd23e522a087dc3535ad | GermanVelasco06/GermanAndresVelascoBossa | /tareas/tarea de polinomio.py | 843 | 3.890625 | 4 | respuesta = "si"
print ( " Digite el grado de su polinomio ")
gradoDelPolinomio =int ( input())
coeficientes = [0 for i in range (gradoDelPolinomio+1)]
exponentes = [0 for i in range (gradoDelPolinomio+1)]
i = 0
contador = 0
def resolverPolinomio (grado,coeficientes,x,contador):
resultado = 0
resultado = in... |
69679fef28a1534518ab9c49fcc3c0cefdb4a953 | Lucas-Severo/python-exercicios | /mundo01/ex028.py | 801 | 4.46875 | 4 | '''
Escreva um programa que faça o computador "pensar" em um número inteiro entre 0 e 5
e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador.
O programa deverá escrever na tela se o usuário venceu ou perdeu.
'''
from cores import Cores # necessário o arquivo cores.py
from random import r... |
3636adac4c35d790019a66b4873bc47e546a22fb | maruV/_Learning | /Python/Programs/labQuiz/untitled1.py | 1,072 | 3.625 | 4 | # Vishal Maru
# Lab Quiz
def getList(filename):
open_file = open(filename, 'r')
strList = open_file.readlines()
global S_list
S_list = []
for str in strList:
# if str[-1] == '\n' or str[-1] == " ":
# str = str[:-1]
S_list.append(str.rstrip())
def Longe... |
9b439ef2bac54b49d96adf824987344c740f7398 | Himanshu-Mishr/projecteuler | /projecteuler/problem51.py | 655 | 3.5 | 4 | #!/usr/bin/python3
# coder : Himanshu Mishra
# about : problem 51
# algorithm used : not decided till now
# links : http://projecteuler.net/problem=51
import time
def primechecker(num):
"""
primechecker() :checks prime or not
"""
x= num//2
while x>1:
if num%x == 0:break
x -= 1
el... |
6c0c5acddf20b88e5c90917bc35931601b1892d9 | tanghl1994/MCGS | /final_data_produce_tree_2.py | 381 | 3.953125 | 4 | import random
print(13)
for i in range(2):
print(i+1,end=',')
print(3)
for i in range(3):
for j in range(2):
print((i+1)*3+j+1,end=',')
print((i+2)*3)
for i in range(9):
print()
for i in range(3):
print('min')
for i in range(9):
a = random.random()
while (a==0):
a = rando... |
3e7f2bc82a91a1fffb39af895c11d63f857babc1 | NAIST-SD-PBL-PAL/Teddy-plus | /python-idioms/npi-enumerate.py | 1,013 | 3.796875 | 4 | ## Non-idiomatic enumerate
# No.1
def n7():
for i in range(len(l)):
x = l[i]
try:
x = next(i for i, n in enumerate(l) if n > 0)
except StopIteration:
print('No positive numbers')
else:
print('The index of the first positive number is', x)
# No.2
def n8():
x = next(... |
558434c757130a0db5d5065c78e49a58fd63210b | soonler/Python000-class01 | /Week_02/G20200343030035/week02_G20200343030035_ex01.py | 1,261 | 3.984375 | 4 |
# 客人 (原总价、商品数)
class Cus_Pay(object):
def __init__(self, original_pay, quantity):
self._original_pay = original_pay
self._quantity = quantity
def pay(self):
return self._original_pay
class Normal_Cus_Pay(Cus_Pay):
def __init__(self, original_pay, quantity):
sup... |
bc58b39c091e1bd92c16809703b1c158ce6fadc4 | yaolizheng/leetcode | /46/permutations.py | 371 | 4.09375 | 4 | def helper(l, temp, result):
if len(temp) == len(l):
result.append(temp)
else:
for x in l:
if x not in temp:
helper(l, temp + [x], result)
def permutations(l):
temp = list()
result = list()
helper(l, temp, result)
return result
if __name__ == '__ma... |
c4a57db2bb6a5b0c14aac0712a28496908e11ca8 | chrisschnabel/adventofcode2020 | /day13/shuttle.py | 1,457 | 3.75 | 4 | import time
import numpy as np
def get_wait(time, nums):
"Input a time and a list of busses, return array wait times"
out = []
for num in nums:
if num < time:
w = num - time % num
if num == w:
w = 0
elif num == time:
w = 0
if n... |
f1e3c106a15893b3c1bb12a67e2ad3fc06fcb87c | aragon08/Python3-101 | /Python101/vectores_matrices.py | 671 | 3.609375 | 4 | # vectores y matices
import numpy as np
# vector = np.array([6,7,1,2,3])
# print(vector.astype(str))
# print(vector.astype(float))
# a = np.array([6,7,1,2,3])
# b = np.array([6,7,5,8,1])
# print(a + b)
# print(a * b)
# print(a > b)
# V = np.array([6,7,1,2,3])
# print(V[3])
# print(V.max())
# print(V.min())
# prin... |
5f242bc99bd463422674c3027e84382e928a4c7b | addisgithub/dividend-Yeild-project | /list.py | 2,036 | 3.59375 | 4 | class Stock:
def __init__(self, name, high, low, date):
self.name = name
self.high = high
self.low = low
self.date = date
def remove(stonks):
temp = []
temp = stonks
temp_high = getTopstock(temp)
temp.remove(temp_high)
temp_low = getlasthighstock(te... |
c329b28c1e8a2674899dfe4ee5b7ba6ca325ffff | faker-hong/testOne | /leetcode(多线程,DP,贪心,SQL)/二刷DP与贪心LeetCode/每日练习/剑指47. 礼物的最大价值/solution.py | 1,253 | 3.625 | 4 | '''
在一个 m*n 的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值(价值大于 0)。
你可以从棋盘的左上角开始拿格子里的礼物,并每次向右或者向下移动一格、直到到达棋盘的右下角。
给定一个棋盘及其上面的礼物的价值,请计算你最多能拿到多少价值的礼物?
输入:
[
[1,3,1],
[1,5,1],
[4,2,1]
]
输出: 12
解释: 路径 1→3→5→2→1 可以拿到最多价值的礼物
'''
class Solution(object):
def maxValue(self, grid):
"""
:type grid: List[List[int]]
... |
d1b1767a948f53f62fecddf4531313c47fadabb6 | pasinimariano/masterUNSAM | /clase06/rebotes.py | 586 | 3.734375 | 4 | # Ejercicio 1.5: La pelota que rebota
# rebotes.py
def rebotes():
altura = 100 # medida expresada en mts
rebotes = [] # se crea lista vacia donse se guardaran los rebotes que haga la pelota
cantidad = 0 # especifica la cantidad de rebotes que se realizaron
while len(rebotes) < 10:
altura =... |
3489abcbe0a9a2e702fa84a6219b47329945ac3d | CairoBars/MyPython | /basic/day8/threading_ext4_daemon.py | 589 | 3.578125 | 4 | #Author:Cairo Li
import threading
import time
def run(n):
print("task",n)
time.sleep(2)
print("task done",n,threading.current_thread())
start_time=time.time()
t_objs=[]
for i in range(50):
t=threading.Thread(target=run,args=("t-%s"%i,))
# t.setDaemon(True)#把当前线程设置成守护进程
#设置成守护线程,主线程退出后,不管子线程有没有执... |
042b45636db98724492fa9566b38f0c598ad3f4d | deniseicorrea/Aulas-de-Python | /python/ex003.py | 144 | 3.75 | 4 | n1 = int(input('Digite o primeiro número:'))
n2 = int(input('Digite o segundo número: '))
s = n1+n2
print(f'A soma entre {n1} e {n2} é {s}' ) |
50a380fc90575a20c61f465ae2f37213238cfcfc | grance1/b | /args.py | 322 | 3.734375 | 4 | #!/usr/bin/python2.7
def fn(*args):
print args
print fn()
print fn('a')
print fn('a','b')
print fn('a','b','c')
def aversge(*args):
sum = 0.0
if len(args) == 0:
return sum
for x in args:
sum = sum + x
return sum / len(args)
print aversge()
print aversge(1,2)
print aversge(1,2,2,3,4)... |
eb2de8d823cc67c88934776536ec726bf29b2178 | Randle9000/pythonCheatSheet | /pluralsight/advanced_python/advanced_flow_control/dispatching_on_type/E0_initial_problem.py | 1,136 | 3.578125 | 4 | class Shape:
def __init__(self, solid):
self.solid = solid
class Circle(Shape):
def __init__(self, center, radius, *args, **kwargs):
super().__init__(*args,**kwargs)
self.center = center
self.radius = radius
def draw(self):
print("\u25CF" if self.solid else "\u25A1... |
d5e43d970824c07364eac3137a21574cb6422517 | julianddd/StockScreener | /utilities/ioUtils.py | 610 | 3.578125 | 4 | import csv
def writeCSV(array, filePath='C:\\Users\\Julian\\Development\\StockScreener\\scratchPad\\', fileName='temp.csv'):
writer = csv.writer(open(filePath + fileName, 'w'), delimiter=',', lineterminator='\n')
for x in array:
writer.writerow([x])
def readCSV(filePath='C:\\Users\\Julian\\Developmen... |
fa21cc7628de7735cd5b69ae1128f512c96e5873 | deocampo/bsd-tensorflow | /introduction/operations.py | 981 | 3.90625 | 4 |
import tensorflow as tf
# Basic constant operations
# The value returned by the constructor represents the output
# of the Constant op.
c1 = tf.constant(4)
c2 = tf.constant(5)
# Launch the default graph.
with tf.Session() as sess:
print("c1=4, c2=5")
print("Addition with constants: %i" % sess.run(c1+c2))
... |
5f13694870caec29f801156e42523dbb11037297 | 2dam-spopov/di | /P5_Sergey-4.py | 1,768 | 4.25 | 4 | #!/usr/bin/python3
# Escriba un programa que permita crear una lista de palabras y que,
# a continuación, pida una palabra y elimine esa palabra de la lista.
# 1-Inicialización de variables.
# 2-Pregunta e introducción de número de palabras en la lista.
# Se usa contro... |
31c272d873f818e4721df7228e627ea237598f1e | geekw/algorithms | /applications/myutils/combinatorial.py | 798 | 3.6875 | 4 |
# Returns the list of permutations of a list
class Permutation:
def __init__(self, the_list):
self._list = the_list
def __len__(self):
return len(self._list)
def solutions(self):
return self._permute(self._list)
# This implementation is extremely inefficient!!!
def _permu... |
26b65e2fbecfb044c26dbd26e1fde7f743238243 | Mpanshuman/Oretes_test-19-02-21- | /Q3.py | 581 | 3.796875 | 4 | size = int(input('Enter Number of marks:'))
alice = list(map(int,input('Enter marks of alice with spaces:').split()))
bob = list(map(int,input('Enter marks of bob with spaces:').split()))
alice_point = 0
bob_point = 0
# comparing marks of alice and bob and assiging points
for i in range(size):
if alice[i] < bob[i... |
fbce673a20b80418cf84822f846b3bd686d1cb04 | ralphS16/Euler-Project | /euler_prob4.py | 576 | 3.71875 | 4 | #Project Euler - Problem #4 : https://projecteuler.net/problem=4
"""
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
import math
def ispal(num):
... |
95eb0d7377ef4b27bc2782f6036c0a39e3b12a47 | lak4az/python-work | /hw4.py | 11,112 | 4.125 | 4 | ## Name: Logan King
## File: assignment04.py (STAT 3250)
## Topic: Assignment 4
##
import numpy as np
import pandas as pd
import re
## This assignment requires the data file 'airline_tweets.csv'. This file
## contains records of over 14000 tweets and associated information related
## to a number of airline... |
d6cfed1b99f3cb5be9591fe948d92e15b707ab7a | shrutipatil12/python_basic | /python/FirstName.py | 165 | 3.9375 | 4 | #Program to accept and display user name.
print("Enter the first name")
FirstName=input ()
print("Enter last name")
LastName=input()
print( LastName , FirstName) |
19d9f78e2e3d70767de3f917ae7b46f42bc0f85a | dheeraj1010/Hackerrank_problem_solving | /Repeated_string.py | 315 | 3.859375 | 4 | import math
def repeatedString(s, n):
x = math.floor(n/len(s))
first_repeat = x*(s.count('a'))
x = n%len(s)
s = s[:x]
second_repeat = s.count('a')
repeation = first_repeat+second_repeat
return repeation
s = input().strip()
n = int(input())
result = repeatedString(s, n)
print(result)
|
0c1362828e276674dbae0511361c5ed21f4b5119 | rmgard/python_deep_dive | /secondSection/theClassRoom.py | 3,650 | 3.8125 | 4 | ################################################
# Classes & OOP
################################################
################################################
# Class with Getters and setters
################################################
class RectangleGetSet:
def __init__(self, width, height):
se... |
80aa7f96e957e0bb973a08f6064f423d032b007b | csenn/alg-practice | /general/stack.py | 612 | 3.796875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Stack:
def __init__(self):
self.head = None
def add(self, data):
node = Node(data)
node.next = self.head
self.head = node
def pop(self):
if not self.head or not self.h... |
2486b778270ef6ea369dd0b685ec2f9a7489f9e7 | jsdelivrbot/prototipos | /Python/01.Vanilla/01.September/01.Object_And_Data_Structure_Basics/04.lists.py | 1,368 | 3.953125 | 4 | my_list = [1, 2, 3]
# 1st, 1st, 3rd
my_list = ['string', 5, 6.2]
# ['string', 5, 6.2]
# print(my_list)
print(len(my_list))
# 3
# indexing andslicing
my_list = ['one', '2', 3]
print(my_list[0])
# one
print(my_list[1:])
# ['2', 3]
print(my_list[:2])
# ['one', '2']
# ========================... |
b9e885e02965fac2da59bf9529d88bfbcdee980e | BaileyKindrick96/CSCI-220-and-220L-Python | /HW2BookProblems-1.py | 3,680 | 3.96875 | 4 | '''Homework for Chapter 2
Name: Bailey Kindrick
I certify that is entirely my work.
Chapter 2
Book questions (30%)
T/F
1. F
2. T
3. F
4. T
5. F
6. T
7. T
8. F
9. T
10. F
Multiple Choice
1. C
2. A
3. D
4. A
5. B
6. D
8. A
10. D
Discussion
4a. 0
1
4
9
16
4b. TypeError:... |
57fa6892c9c72deeecddc089a6e92ba2e8eb12a8 | hayley01145553/Web_Scraping_Project | /NationalParkVisitation/NationalParkVisitation/spiders/np_visitation_spider.py | 4,356 | 3.515625 | 4 |
from scrapy import Spider
from NationalParkVisitation.items import NationalparkvisitationItem
# for문 이름
# for문 입장료
# 이름, 입장료를 zip으로 묶어서 튜플로 되고 이거를 List에 넣음
# 만든 최종 리스트를 가지고 item에 넣어서 yield
class NPVisitationSpider(Spider):
name = "np_visitation_spider"
allowed_urls = ['https://www.nps.gov']
start_urls = [... |
f56efd9750752337e58469f3574c36307419a031 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2194/60617/289423.py | 531 | 3.921875 | 4 | def find_Primes():
row=input().split(" ")
left=int(row[0])
right=int(row[1])
res=[]
for i in range(left,right+1):
if i==1:
continue
if(is_Prime(i)):
res.append(i)
for num in res:
if num!=res[-1]:
print(num, end=" ")
else:
... |
75d1077dfec745448caa021389e5d2acc48ff12f | saulQuirogaDVL/Estadistica | /Estadistica.py | 7,883 | 3.640625 | 4 | import numpy as np
import math
import matplotlib.pyplot as plt
datos = input('Coloque la ruta del archivo txt: ')
cantDatos=list()
ListaSO=np.loadtxt(datos)
#elimina los repetidos de la lista
def eliminar_repetidos(lista):
nueva=[]
for elemento in lista:
if not elemento in nueva:
... |
58d5e9a9b60b2d6df8364a05a1c804ba932fc062 | anasmorahhib/Master-Data-Science-FSSM | /02.Data mining/ex2-Euclidean-distance-between-two-images/euclidean-distance-between-two-images.py | 1,258 | 3.75 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[14]:
# importing libraries
import numpy as np
import math
import matplotlib.image as img
# In[15]:
# two images to calculate the distance between them
# imgread for transform image tu vector
testImage = img.imread("img-1.png")
testImage2 = img.imread("img-2.png")
# In... |
41ad32a17795ce209a9c1499b325b76d514a2bf9 | YeonggilGo/python_practice | /SWEA/D1/2056_calendar.py | 611 | 3.8125 | 4 | thirty_one = [1, 3, 5, 7, 8, 10, 12, [31]]
thirty = [4, 6, 9, 11, [30]]
twenty_eight = [2, [28]]
total_month = [thirty, thirty_one, twenty_eight]
T = int(input())
for tc in range(1, T + 1):
date = input()
year = date[:4]
month = date[4:6]
day = date[6:]
ans = 0
found = False
for each_mon... |
0f7648d450847448cdd1d25a6e3b4f8669fc424e | Yobretaw/AlgorithmProblems | /Py_leetcode/049_anagrams.py | 579 | 3.875 | 4 | import sys
import math
from collections import defaultdict
"""
Given an array of strings, return all groups of strings that are anagrams.
Note: All inputs will be in lower-case.
"""
def anagrams(strs):
n = len(strs)
if n < 2:
return []
strs.sort()
m = defaultdict... |
30cd8f3f83ffaf07e7afec123aab072c553d9067 | Paychokxxx/flask_store_app_with_test | /test.py | 466 | 3.59375 | 4 | import json
# serializing JSON / making data dump / save
# python objs ==> JSON objs
json_string = """
{
"researcher": {
"name": "Ford Prefect",
"species": "Betelgeusian",
"relatives": [
{
"name": "Zaphod Beeblebrox",
"species": null
... |
537c1bdcd7affb468122d794230d32c2d2bdf61a | oplaf/sandbox | /sandbox4.py | 382 | 3.875 | 4 | import random
def main():
file = open("silly.txt", 'r')
read_file = file.readlines()
random_line = random.choice(read_file)
print(random_line)
def reverser():
rev_file = open("reversable.txt", 'r')
read_rev_file = rev_file.readlines()
to_insert = read_rev_file[1]
print(f"welcom... |
41f3e90e0d9c12e9cfecec43da911ac9bc0f6d19 | AlbertoReal/Practicas_python | /pr5/pr5ejer9.py | 612 | 4.0625 | 4 | #Alberto Real Gomez: practica 5 ejer 8: trinagulo ancho
entrada1=int(input("altura del rectangulo"))
entrada2=int(input("lado del rectangulo"))
for i in range (entrada1):
if i==0:
for j in range (entrada2):
print("*",end="")
elif i==entrada1-1:
for j in range (entrada2):... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.