blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
18f59e3b0c82c5793bf4a3da409e5c291b4b2012
johnnzz/foundations_python
/module8/lab8-1.py
241
3.640625
4
class person(): firstname = None lastname = None def to_string(self): return self.firstname + " " + self.lastname myguy = person() myguy.firstname = "fred" myguy.lastname = "jones" print(myguy.to_string())
af769b9f0efdf2748187576df4bf3e0e279b4cb4
pgmz/Coding_Test
/Questions/Stacks_and_Queues/Queue_Via_Stacks_python.py
657
3.828125
4
class MyQueue(): def __init__(self): self.s_order = [] self.s_norder = [] def pushToQueue(self, data): while len(self.s_norder)!=0: self.s_order.append(self.s_norder.pop()) self.s_order.append(data) def popFromQueue(self): while len(self.s_order)!=...
f95eb8b45c4e84c6729f36869ae8fbe1864085e0
gyurel/SoftUni-Basics-and-Fundamentals
/exercise_funktions/odd_and_even_sum.py
318
3.96875
4
def odd_and_even_sum(input_str): odd_sum = [] even_sum = [] even_sum += [int(x) for x in input_str if int(x) % 2 == 0] odd_sum += [int(x) for x in input_str if int(x) % 2 == 1] return f"Odd sum = {sum(odd_sum)}, Even sum = {sum(even_sum)}" input_str = input() print(odd_and_even_sum(input_str))
8372dcd91d1da4ecd5d934b03f86ae23e090a144
andchrlambda/DS-Unit-3-Sprint-2-SQL-and-Databases
/module1-introduction-to-sql/buddymove_holidayiq.py
1,285
3.984375
4
import os import sqlite3 import pandas as pd """Creating an SQLite database with queries.""" df = pd.read_csv('buddymove_holidayiq.csv') print(df.head) """Checking for null values.""" nulls = df.isnull().sum().sum() print("There are", nulls, "null values.") CONN = sqlite3.connect('buddymove_holidayiq....
91629e1a521ef239aed56df2d97c823c7ae6c11d
sunchitsharma/mini_sql_db
/filereader.py
532
4.03125
4
import csv def filereader(name): try: # OPENING THE FILE file_desc = open (name+".csv" ,'r' ) # READING THE CSV FILE csvread = csv.reader(file_desc) answer=[] # TABLE TO BE RETURNED for row_i in csvread: answer.append(row_i) return answer # ANS...
fe743110239b4c71b841b7c87018b301e783cd95
oceanbei333/leetcode
/73.矩阵置零.py
1,794
3.65625
4
# # @lc app=leetcode.cn id=73 lang=python3 # # [73] 矩阵置零 # # @lc code=start from typing import List class Solution: def setZeroes(self, matrix: List[List[int]]) -> None: """ Do not return anything, modify matrix in-place instead. """ if not matrix: return rows ...
aa1efdf80fb2e7fe0c9231a25f599012e13d067f
tobanteAudio/pyDSP
/dsp/parameter.py
1,390
3.640625
4
'''Parameter classes ''' import abc class AudioParameter: '''Base class for all parameter types ''' def __init__(self, identifier: str, name: str): self._identifier = identifier self._name = name @property def identifier(self) -> str: '''Returns the parameter id '...
d495062d9eaec2aa4021df6b66d6c409914bf412
sarastrasner/python-projects
/turtleCrossing/main.py
1,004
3.703125
4
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) screen.title("Turtle Crossing") screen.listen() # TODO 1. Create a turtle player that starts at the bottom of the ...
0b5784d6d1a04bda2235f4537a2afef6341a0f74
sonukrishna/MITx-6.00.1x
/week4/oddtuple.py
167
3.859375
4
def oddTuple(tup): rtup = () for i in range(len(tup)): if i%2 == 0: rtup += (tup[i],) return rtup print oddTuple(('I', 'am', 'a', 'test', 'tuple'))
29c1ca6c3211f21f965b8b4a5914295374bac730
shivamsharma0227/Turtle-Race
/main.py
964
3.53125
4
from trackdown import * from random import randint #first turtle mika = Turtle() mika.color("red") mika.shape("turtle") mika.penup() mika.goto(-175,110) mika.pendown() mika.write("mika(1)") for turn in range(10): mika.right(36) #second turtle bob = Turtle() bob.color("purple") bob.shape("turtle"...
00c56e03aa36d90a6b458c7cef8f856ae1bd5dca
z-aitkourdas/colliding-blocks
/pi.py
3,563
3.796875
4
import pygame import math NUM_OF_DIGITS = int(input("Enter the number of digits you want to compute: ")) # Set the number of digits WIDTH, HEIGHT = 1280, 720 # Setting the windows dimensions WHITE = (255,255,255) # Set the RGB color of WHITE GRAY = (190,190,190) # Set the RGB color of GRAY RED = (200,0,0)...
09f2cbcdcc47e1b3c55bad0aa2f968c2784a3ce8
Supermac30/CTF-Stuff
/Mystery Twister/Autokey_Cipher/Autokey Decode.py
328
4.0625
4
""" This script decodes words with the AutoKey Cipher """ ciphertext = input("input ciphertext ") key = input("input key ") plaintext = "" for i in range(len(ciphertext)): plaintext += chr((ord(ciphertext[i]) - ord(key[i]))%26 + ord("A")) key += plaintext[i] print("Your decoded String is:",plai...
2f6a5cedb77f528aa533b66003ed3c238654f293
shrivastava-himanshu/Python-Programs
/prime_generator.py
494
3.984375
4
# -*- coding: utf-8 -*- """ Created on Thu Dec 6 09:26:59 2018 @author: shrivh1 """ def prime_generator(n): #list primes from 1 to n for i in range(1,n,1): if prime_check(i): print(i) prime_generator(200) def prime_check(n): flag = 0 if n > 2 and n % 2...
c722fba16963f7cd3628e51f432bcf13357c4024
ClementeCortile/Basic_Software_Engineering
/1_Structure_and_Modules/main.py
1,297
3.84375
4
#The program will run from this main file ( C style!) #Read every comment from top to bottom #Try running the file from the terminal with | python3 main.py | command #Python modules are imported from import sys #print(sys.path) #Importing modules import os import numpy as np os.getcwd() #...but we can import our o...
5a801c4a2ce042b2d5bab7a578fc32074bb8d28f
roseperrone/interview-questions
/combinations.py
479
4.03125
4
''' Print all combinatiosn of a string. Input: 'ros' Output: set(['', 'rs', 'ors', 'o', 's', 'r', 'os', 'or']) ''' def combinations(string): if len(string) == 1: return set([string, '']) result = set() for i in range(len(string)): for comb in combinations(string[:i] + string[(i+1...
b5f304542810c64d9a35a076c8cbb0f84ace8e9f
slakkam/problems
/src/HackerRank/JourneyToMoon.py
1,824
3.578125
4
class Vertex: def __init__(self,data): self.data = data self.visited = False self.adjVertices = [] class Tree: def __init__(self): self.vertexDic = {} self.numVertices = 0 def addVertex(self,data): newNode = Vertex(data) self.vertexDic[data] = newNode...
9c8ea510e8c73f2ab6ecc1797b6cc48857875257
siddhant283/Python
/Generators/gen.py
356
3.765625
4
def generator_function(num): for i in range(num): yield i g = generator_function(1000) next(g) next(g) next(g) print(next(g)) # for item in generator_function(1000): # print(item) # def make_list(num): # result=[] # for i in range(num): # result.append(i*2) # return resu...
b4535183618e11f291e607676dbbc21fb7d0cd71
Deepmalya-Sarkar/Programming-With-Python
/argskwargs.py
239
3.953125
4
def printing(*args): print("Printing") for i in args: print(i) def inputing(): li=[] print("enter 5 numbers") for i in range(5): li.append(int(input())) return li myli=inputing() printing(*myli)
8bdc4d1399a7963716e76df7ce499dbd0b188ae0
ywl123ywl/vip10test
/面向对象/初始化属性.py
580
3.828125
4
class washer(): def __init__(self,width,height,brand): self.width = width self.height = height self.brand = brand def wash(self): print(f'haier洗衣机的宽度是{self.width}') print(f'haier洗衣机的高度是{self.height}') print(f'haier洗衣机的品牌度是{self.brand}') def __str__(self): ...
7aeff1eb445ba3f0c9ea930ad602a11154554ea5
oksanabodnar69/Python-Projects
/Convert.py
984
3.703125
4
import json import csv import os.path import argparse def convert_csv_to_json(csvfilepath, jsonfilepath): if os.path.isfile(csvfilepath): with open(csvfilepath,'r') as csvfile: data={} reader = csv.DictReader(csvfile, delimiter=',') for rows in reader: ...
5881c0e644e59b91db3c3854e8bf05fc364e05f8
zplante/University-Assignments
/CS143/asg2/asg2_prt1.py
5,182
4
4
import argparse, re, nltk # https://docs.python.org/3/howto/regex.html # https://docs.python.org/3/library/re.html # https://www.debuggex.com/ def get_words(pos_sent): """ Given a part-of-speech tagged sentence, return a sentence including each token separated by whitespace. As an interim step you n...
cdd8c8bd7cba0071a6e90c172806eff671e2f0c7
FlorianMerchieG1/PySoli
/Game/column.py
2,281
3.921875
4
from Game.card import * class Column: def __init__(self, number): # Number of remaining cards to draw self.nb_todraw = number+1 # List of cards of the column self.cards = [] def need_reveal(self): """ Checks if a new card needs to be revealed """ ...
1b7a53d710aa01239f86eef1982d2ce700534e70
ccomings/hft-coding-challenges
/2018-11-07/gregori-combinations.py
311
3.671875
4
#!/usr/bin/env python import itertools def myfunc(lst): ret = [] arr = list(itertools.combinations(lst, 3)) for (x,y,z) in arr: if x+y+z == 0: ret.append((x,y,z)) return ret def main(): print myfunc([-1, 0, 1, 2, -1, -4]) if __name__ == '__main__': main()
c535cd2400a2b9518b2ee3238c3e2c802ef1d743
sixcy/python-belote
/cards.py
1,574
3.65625
4
from enum import Enum, unique from typing import List, Optional from utils import * from collections import namedtuple import random @unique class Color(Enum): CLUBS, DIAMONDS, HEARTS, SPADES = range(4) @unique class Rank(Enum): ACE, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING = range(8) class Card: def __ini...
05704bbf852031873f9a266f5f353c1fdbe7835d
JT4life/PythonRevisePractice
/armstrongNum.py
743
4.09375
4
#number of n digits which are equal to sum of nth power of digits #E.G 22 so 2^2 = 4 2^2 =4, 4+4=8 8 does not equal 22 thus not armstrong userEnter = input("Enter digits separated by commas to check if armstrong number") #123 def arm(userEnter): split = userEnter.split(',') print(split) size = len(split) ...
074d56ab90f4b359944fcb5f5d173109b50ec4a8
charles-debug/learning_record
/94-函数的返回值.py
239
3.578125
4
# 用户付钱,返回烟 def buy(): return '烟' goods = buy() print(goods) """ return作用: 1.返回函数返回值 2.return会退出当前函数,导致return 后面的代码(函数体内部)不执行 """
e1d14dcc0eb855e5747fac99cce257925a31c726
GondorFu/Lintcode
/626.矩阵重叠/Solution.py
641
3.9375
4
# Definition for a point. # class Point: # def __init__(self, a=0, b=0): # self.x = a # self.y = b class Solution: # @param {Point} l1 top-left coordinate of first rectangle # @param {Point} r1 bottom-right coordinate of first rectangle # @param {Point} l2 top-left coordinate of second ...
b512a08ed2b0d775965d18eb33200106aa862df9
yugandharachavan272/PythonExercise
/Day1/Exe3.py
981
4.25
4
# Print as it is print "I will now count my chickens:" # print string with numerical operations result, in numerical operation first 30/6 then addition i.e. 25+5 print "Hens", 25+30/6 # string with numerical operations 100 - 75%4 => 100 - 3 = 97 print "Roosters", 100 - 25 * 3 % 4 # print as it is it print "Now I wil...
4cd49ab4d1482795096f65d5768fe221f35dcdea
jpignata/adventofcode
/2015/02/solve.py
682
3.59375
4
import sys import operator from collections import namedtuple from functools import reduce Box = namedtuple("Box", ["l", "w", "h"]) def sides(box): return [box.l * box.w, box.w * box.h, box.h * box.l] def area(box): return reduce(lambda x, y: (2 * y) + x, sides(box), 0) def volume(box): return reduce...
6303e684e3fa6f87d3102dcbe5415b36bfb6f118
pzar97/Design-2
/QueueusingStacks.py
2,444
4.3125
4
""" Queue using Stacks """ """ Time Complexity: Push: O(1) Pop: Amortized O(1) Top: Amortized O(1) Empty: O(1) """ class MyQueue: def __init__(self): """ Initialize your data structure here. """ # 2 stacks:s1 and s2 self.s1 = [] self.s2 = [] def push(self, x: i...
5b5cb24c19407b0d5282575f57276e748b971c07
XuTan/PAT
/Advanced/1046.Shortest Distance.py
2,004
4
4
""" 1046. Shortest Distance (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits. Input Specification: Each input file contains one test case. Fo...
fec820da55e0e79da647992007f67746013aab65
rh01/py-leetcode
/042-TrappingRainWater.py
1,171
3.859375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : ShenHengheng # @File : 042-TrappingRainWater.py # @Desc : # @Site: : https://leetcode.com/problems/trapping-rain-water/ """ Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it ...
22a734f6039120982db28286f905b0ade38dabc8
Scott-S-Lin/Python_Programming_ChineseBook
/ch2/func_multi_ret.py
802
3.984375
4
#filename: func_multi_ret.py #funcion: declare functions, receiving a variable number of arguments, using the * #function: return multi result from the function def multi_variable(var1, var2, *others): print ("var1: %s" % var1) print ("var2: %s" % var2) print ("others: %s" % list(others)) multi_variab...
0d8f63291de52d70d1d0961d8abc2c2984ec7307
aureliewouy/AirBnB_clone
/tests/test_models/test_amenity.py
1,523
3.5625
4
#!/usr/bin/python3 """ Unittest for the Amenity class that inherit from BaseModel """ import unittest from models.amenity import Amenity from models.base_model import BaseModel class TestAmenity(unittest.TestCase): """ Tests for the Amenity class """ def setUp(self): """ To define inst...
3e90e1d87ea1df03eecd2d8139a962d0e8bb238c
sairampandiri/python
/perfect_square.py
253
3.765625
4
#Given two numbers N,M.Find their product and check whether it is a perfect square a,b=map(int,input().split()) n=a*b if(n==0): print("yes") else: for i in range(0,n): if i*i==n: print("yes") break else: print("no")
f88112a63199bf1a25dce10bf426119c0a79b717
CrappyAlgorithm/Airgonomic_Backend
/control/led_handler.py
492
3.515625
4
## @package control.led_handler # @author Sebastian Steinmeyer # Handles the functionallity to turn a led on and off. import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) ## Turn on a led. # @param gpio the gpoi pin which should turn on. def open_window(gpio): GPIO.setup(gpio, GPIO.OUT) ...
4e8315a1740f2ac825666fd2d0810bdba46ccc78
sidv/Assignments
/Rajaprasad/Day12-assignments/addition_of_all_num.py
427
4.15625
4
num = "1,2,3,4,5,6,7,8,9" print("______________Addition of all numbers __________________") sum = 0 numbers = num[0::2] print("numbers are " ,numbers) for i in numbers: x = int(i) sum = sum+x print("The sum is " ,sum) print("_____________Addition of all even numbers______________") even = num[2::4] print("the ...
b64c689b772489d7e2891f7e1427858af57df1d4
ochaib/decision-tree-learning
/tree.py
1,164
3.765625
4
class TreeNode: treeNode = {} def __init__(self, value, attr=None, left=None, right=None): self.value = value self.attr = attr self.left = left self.right = right self.count = 0 def TreeNode(self): return {self.attr, self.value, self.left, self.right} d...
c740799f39f186ec0c03cb86bee4d3dde00c45b1
JerryHu1994/LeetCode-Practice
/Solutions/436-Find-Right-Interval/python.py
1,096
3.640625
4
# Definition for an interval. # class Interval(object): # def __init__(self, s=0, e=0): # self.start = s # self.end = e class Solution(object): def findRightInterval(self, intervals): """ :type intervals: List[Interval] :rtype: List[int] """ index = {} ...
a5620b62a3d865e10a0580dfac2c268c6675a952
skgitbrain/python
/lesson_6/Task_4_L6.py
1,510
4.0625
4
class Car: def __init__(self, name, color, speed, is_police=False): self.name = name self.color = color self.speed = speed self.is_police = is_police def go(self): print(f"Машина марки {self.name} поехала") def stop(self): print(f"Машина марки {self.name} о...
ec6d81715d5dfefbe64189a56720c7265dc05d18
manojnaidu15498/mnset4
/p1.py
97
3.671875
4
s=input() char=0 word=1 for i in s: if(i==' '): continue char=char+1 print(char)
c6e17e3dcc83712b5f4773526d8f765c34f7dc7e
KeleiAzz/LeetCode
/Facebook/onsite/AddOperator.py
449
3.609375
4
# cache = {} def addOperator(nums, target): ''' Seems work, how to optimize? :param nums: :param target: :return: ''' if int(nums) == target or int(nums) == -target: return True for i in range(1, len(nums)): subnum = int(nums[:i]) if addOperator(nums[i:], target -...
ffd82004930ce855863fb34fc777360d98c12e61
bimri/learning-python
/chapter_7/slicing.py
474
3.9375
4
S = 'hello' print(S[::-1]) # Reversing items ''' With a negative stride, the meanings of the first two bounds are essentially reversed. ''' s = 'abcedfg' print(s[5:1:-1]) # Bounds roles differ '''slicing is equivalent to indexing with a slice object''' print('spam'[1:3]) ...
2b01ae394ad42fbcd55168d20f1e7936bcb031f6
snowcity1231/python_learning
/variable/variable.py
579
3.703125
4
# -*- coding:utf8 -*- # Python变量类型 counter = 100 # 一个整型数 miles = 999.99 # 一个浮点数 name = "Maxsu" # 一个字符串 site_url = "http://www.google.com" # 一个字符串 print(counter) print(miles) print(name) print(site_url) # 多重赋值 print("---------多重赋值-------------") a = b = c = 1 aa = bb = cc = "Tom" print(a) print(b) print(c) print...
a908c84a6522088980403e222d03b8399431ef91
IshanDindorkar/machine_learning
/taming_big_data_apache_spark/src/most-popular-superhero.py
1,350
3.703125
4
# Summary of codebase # max() - find out row with maximum key value, lookup() - search for a specific key in RDD from pyspark import SparkConf, SparkContext def count_occurences(line): fields = line.split() return (fields[0], len(fields) - 1) def get_superhero_details(line): fields = line.split("\"") ...
57f6f3c3d9b3f5636b9d55486ee9beb3f3674716
joselynzhao/Python-data-structure-and-algorithm
/leecode/20060401.py
1,485
3.703125
4
#!/usr/bin/python # -*- coding: utf-8 -*- ''' @AUTHOR:Joselyn Zhao @CONTACT:zhaojing17@foxmail.com @HOME_PAGE:joselynzhao.top @SOFTWERE:PyCharm @FILE:20060401.py @TIME:2020/6/4 20:48 @DES: 回文数 : 已解除,但时间超出限制,需要动态规划 ''' def longestPalindrome( s: str) -> str: # 先考虑极端情况 lens = len(s) if lens == 1: re...
56b763228051633b678ef7b8d7049c5bcd60a05a
itsolutionscorp/AutoStyle-Clustering
/intervention/results/control_120722_1449534232_525_11.08.py
232
3.84375
4
def num_common_letters(goal_word, guess): count = 0 used = list() for letter in goal_word: if letter in guess and letter not in used: count += 1 used += letter return count
ece8a6ae9affacb618703981a4fb364642ef0fcc
chasezimmy/fun
/python/sum_of_left_leaves.py
735
4.15625
4
""" Find the sum of all left leaves in a given binary tree. Example: 5 / \ 3 7 / \ / .2 4 .6 sum: 8 (2+6) """ class Node: def __init__(self, val): self.val = val self.left = None self.right = None def sum_of_leaves(root): sum_of_leaves.sum = 0 d...
bb1bf54096d780204fe882811d5ea2f54a6de3fe
Ankur-v-2004/Class-12-ch-1-python-basics
/prog_list_opertn.py
411
4.125
4
#Program to show the outputs based on entered list. my_list = ['p','r','o','b','e'] # Output: p print(my_list[0]) # Output: o print(my_list[2]) # Output: e print(my_list[4]) # Error! Only integer can be used for indexing # my_list[4.0] # Nested List n_list = ["Happy", [2,0,1,5]] # Nested indexing # Outpu...
f1d6eca058cea46fde250faa411a3369a7e072e5
NiCrook/Edabit_Exercises
/60-69/61.py
700
3.828125
4
# https://edabit.com/challenge/baBNZFCozmjNhbp9Q # Create a function that takes a number (step) as an argument # and returns the amount of boxes in that step of the sequence. # Step 0: Start with 0 # Step 1: Add 3 # Step 2: Subtract 1 # Repeat Step 1 & 2 ... def box_seq(steps: int) -> int: steps_tak...
83069810a496224e7e546e6388b3e78fbfa4316f
pratik-1999/Solved-Problems
/has_pair.py
833
3.859375
4
def has_pair(array, req_sum): array.sort() low, high = 0, len(array)-1 while low<high: ar_high = array[high] ar_low = array[low] cur_sum = ar_high+ar_low if cur_sum == req_sum: return (ar_low, ar_high) elif cur_sum>req_sum: high -= 1 ...
4110b8629b2c7b32dd8fcc51510dee5b8852fa6f
antongoy/DL
/Assignment1/src/layers.py
9,070
3.609375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Implementation of layers used within neural networks from __future__ import print_function from __future__ import division import numpy as np class BaseLayer(object): def get_params_number(self): """ :return num_params: number of paramet...
6b0959289acfc6646e08d175f185d3c138a284ef
anurao5/Python-coding-practice
/Class_AgeComparison.py
707
3.828125
4
class Person: def __init__(self,initialAge): #Initialize the age if initialAge < 0: self.initialAge = 0 print("Age is not valid, setting age to 0") else: self.initialAge = initialAge def amIOld(self): #Check the person's age ...
70a0c31ed587a831ab31b7e554cca516b45283dd
MrSyee/algorithm_practice
/dp/pelindrome_partioning_4.py
1,701
3.828125
4
""" 1745. Palindrome Partitioning IV (Hard) https://leetcode.com/problems/palindrome-partitioning-iv/ Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.​​​​​ A string is said to be palindrome if it the same string when reversed. ...
64f6c99cfd8b73e42ec700fb6d5edec6baa4a38f
jnizama/practicePython
/DecimalToBinary.py
528
3.9375
4
binaryNumber = [] def convertToBinary(iNumber:int): resto = round(iNumber%2); binaryNumber.append(resto) iNumber = int(iNumber/2) if(iNumber > 1): convertToBinary(iNumber) else: binaryNumber.append(iNumber) #for x in range(iNumber, 0,-1): # print(x) binary...
068fe21cac258d1c697fd5cb508a2cc7ecbefa95
samadabbagh/sama-mft
/mft-first-section/five-section.py
207
4.1875
4
number = int(input("enter your number number")) i = 0 number_final = 0 while i < number : i = i+1 number_final = number_final +(1 /i**2) print(number_final) pi =( 6 * number_final)**0.5 print(pi)
3d125a3db25023a22e37dd3b833e19ad1cad43af
caynan/ProgrammingContests
/checkio/count_inversions.py
1,050
4.125
4
def sort_count(arr): l = len(arr) if l > 1: mid = l // 2 l_half, l_count = sort_count(arr[:mid]) r_half, r_count = sort_count(arr[mid:]) sorted_arr, m_count = merge_count(l_half, r_half) return sorted_arr, (l_count + r_count + m_count) else: return arr, 0 de...
64518f20dd75f350441e8f8fb488a20e6041aad9
recyan19/num_to_words
/nums_to_words_v1.py
2,020
3.609375
4
#!/usr/bin/python3 import re import inflect def solve(s): p = inflect.engine() nums = '01234567890' signs = '+-*/= ' allowed_chars = nums + signs verbose_signs = {'+': 'plus', '-': 'minus', '*': 'multiple by', '/': 'divide by', '=': 'equals'} if any(i not in allowed_chars for i in s): ...
0553c03a0e68efcff2f06503a63343558e67f07e
na-liu/pythonExercise
/demo/demoTuple.py
919
4.0625
4
# tuple 表示 tup = () # 空元组 tup1 = (1, 2, 3, 4) tup2 = (1) # 括号中是单个元素时,括号会被认为是运算符号,表示整型 print('type(tup1):', type(tup1)) # type(tup1): <class 'tuple'> print('type(tup2):', type(tup2)) # type(tup1): <class 'int'> # 访问元组 print('tup1[0]:', tup1[0]) # tup1[0]: 1 print('tup1[-1]:', tup1[-1]) # tup1[-1]: 4 print('tup1[1...
88f8fc6e5c3014142e5fa2bad468a779cb26bc88
wangxiao2663/learning
/my_learning_python/yield/yield.py
242
3.609375
4
def f(): print "Before first yield" yield 1 print "Before second yield" yield 2 print "After third yield" g = f() print "Before first next" g.next() print "Before second next" g.next() print "Before third yield" g.next()
898d0cd6746fadcca9e603bc8806449d7c2ffb80
ericchen12377/Leetcode-Algorithm-Python
/1stRound/Medium/286-Walls and Gates/DFS.py
953
3.59375
4
class Solution(object): def wallsAndGates(self, matrix): """ :type rooms: List[List[int]] :rtype: None Do not return anything, modify rooms in-place instead. """ wall = -1 gate = 0 empty = 2147483647 directions = [[-1,0], [0,1], ...
91d278a8b16c3f22c70ebe829b8662088cb79f95
Maryville-SWDV-630/ip-1-kylekanderson
/Assignment.py
1,068
4.09375
4
# SWDV-630: Object-Oriented Coding # Kyle Anderson # Week 1 Assignment # Using Thonny, Visual Studio or command line interface expand on the Teams class defined as: class Teams: def __init__(self, members): self.__myTeam = members def __len__(self): return len(self.__myTeam) #...
f3d9ee7eb3d99299457dc11aef9ec09c6435dce0
kathferreira/python-programming-data-science-numPy
/excercises/11_excercise_arange.py
321
4.0625
4
# -*- coding: utf-8 -*- """ Created on Fri Jul 2 11:30:29 2021 @author: kferreip Excercise 11 Using numpy create a one dimensional array of all two-digit numbers and print this array to the console. Tip: Use the np.arange() function """ import numpy as np two_digit_arr = np.arange(10,100,1) print(two_digit_arr...
5c189c84739502959f1fb7a896ce4361364d4543
gosyang/leetcode
/Algorithms/tree/563.Binary_Tree_Tilt/binary_tree_tilt.py
1,815
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ######################################################################## # # Copyright (c) 2017 gosyang. All Rights Reserved # ######################################################################## """ File: binary_tree_tilt.py Author: gosyang Date: 2017/05/25 10:24:3...
459112c5ea9ceca9483053e0a25afd035705e923
vutran1412/CapstoneLab1
/camelCase.py
1,400
4.5
4
# Camel Casing Program # Author: Vu Tran # Function to turn a sentence user entered into a camel cased sentence def camel_case(user_string): # Initialize a new list new_list = [] # Initialize a new string new_sentence = "" # Splits the user sentence and saves the individual words into a list st...
f7c83f90e6999d1a2a08029f4a0ce07495ca0662
GitZW/LeetCode
/leetcode/editor/cn/day_024.py
1,800
4.25
4
""" Implement a function to check if a binary tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that the heights of the two subtrees of any node never differ by more than one. Example 1: Given tree [3,9,20,null,null,15,7] 3 / \ 9 20 / \ 15 7 return ...
b1a55f3689c10dce0ecac0c82d6a1e7472bfc31b
mikhalevv/Poisk_glasnykh
/Poisk_glasnykh final.py
247
3.5625
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 6 17:52:27 2018 @author: mihalev """ s = str(input()) y = list(s) z = s.count('a') + s.count('e') + s.count('i') + s.count('o') + s.count('u') + s.count('y') print('Number of vowels: ' + str(z))
10f2cc80d44941a24f64b4ad63e7cebe3bea7d99
fuburning/lstm_intent
/tensorgou/utils/txtutils.py
1,291
3.53125
4
""" """ import re, string import unicodedata def cleanline(txt): return txt.strip('\n') def to_lowercase(text): return text.lower().strip() def remove_all_punctuations(text): regex = re.compile('[%s]' % re.escape(string.punctuation)) text = regex.sub(' ', text).strip() return " ".join(text.sp...
4ea09a3b33528049580f83ac570841779fd1ca52
athiyamaanb/py_challenge
/scripts/play_tictactoe.py
1,528
3.9375
4
def check_complete(matrix): #complete_flag = False for row in matrix: first_element = row[0] if first_element != ' ': row_check = True for column in row: if first_element != column: row_check = False break ...
11a67512fe2a34841fda57173b6ca56d1f7e1112
WashHolanda/Curso-Python
/exercicios_Prof/Semana 4/lista4-01.py
864
4.09375
4
''' 1) Faça um programa que leia o nome e nota da P1 de vários alunos guardando tudo em uma lista e no final mostre: a. Quantas alunos foram cadastradas b. O nome do aluno com maior nota c. O nome da pessoa menor nota d. O nota média da sala. ''' from operator import itemgetter op = ' ' p1 = [] aluno = {} média = 0 w...
13d44aa24b87dfc3abac3b05b92e2e7457e098e5
agomez0/python-challenge
/PyBank/main.py
2,027
3.953125
4
import os import csv csvpath = ('budget_data.csv') f = open("data.txt", "w") #Prints out to console and text file def outputPrint(text): f.write(text + "\n") print(text) with open(csvpath, newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=',') #Skip the header row first csv_hea...
4351c4da1ec4238f16b5699fe766094d97909784
Misael1998/generador-numeros-aleatorios
/main.py
1,548
3.71875
4
from cuadrado_medio import AleatorioMedio from congruencial import AleatorioCongruencial def main(): print('Numeros aleatorios\n') print('Seleccione el metodo de generacion de numeros alearorios') print('1.Cuadrado medio') print('2.Congruencial') metodo = int(input()) if metodo == 1: pr...
5a97ae18e7319001e3eb66d4a7e55bc0f642fc48
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/想研究的/python-further/metaclass1.py
2,426
4.96875
5
#http://blog.jobbole.com/21351/ #http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python """ Secondly, metaclasses are complicated. You may not want to use them for very simple class alterations. You can change classes by using two different techniques: ·monkey patching ·class decorators 99% of the ti...
b4794dd4ad3a0f2a418f001033b175972deae939
shenyubo1982/gittesting01
/PythonDemo08.py
6,412
3.734375
4
##07-05 学习笔记 ##装饰器 ##—————————————————————————————————— ## 2.1 无参数装饰器的实现 ##如果想为下述函数添加统计其执行时间的功能 import time def index(): time.sleep(3) print('1.Welcome to the index page') return 200 index() #函数原本的执行方式 ##遵循不修改被装饰器对象源代码的原则,我们想到的解决方案可能是这样↓ start_time = time.time() index() stop_time = time.time() print('1...
c0ac397b9d7ec7b7eba8cad4c99e789adad4a1d8
Touchfl0w/python_practices
/basic_grammer/functional_programming/f2.py
451
4.0625
4
#闭包 = 函数 + 环境变量 a = 3 def func_pre(): #环境变量 a = 1 #函数 def func1(x): y = a + x print(y) #最后一定要返回这个闭包后的函数 return func1 f = func_pre() f(2) #发散一下,环境变量初始值可变的闭包 def func_pre1(a): #环境变量实际上为参数中的a #函数 def func2(x): y = a + x print(y) #最后一定要返回这个闭包后的函数 return func2 f = func_pre1(10) f(2)
5b6e9d55beb5fd5f8e1fdc490fe0429d914a1871
itcsoft/itcpython
/python/day14/dict_1.py
1,522
3.953125
4
# Наши Аккаунты в банках accounts = [ { "name": 'Demir Bank', "balance": 500000.00, "valuta": "KGS", "password": 1994 }, { "name": 'Optima Bank', "balance": 9654321, "valuta": "RUS", "password": 1995 }, { "nam...
ffa006e0ef696614131d098e19c2542efa9474fa
alanaalfeche/python-sandbox
/leetcode/blind_75/problem21.py
1,660
3.90625
4
'''Problem 76: Minimum Window Substring https://leetcode.com/problems/minimum-window-substring/ Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). ''' from collections import Counter def min_windows(s, t): '''This algorithm uses sliding w...
bd35fb19ad0effaa6d11cb61abd24504d7e7753f
himanshuJ01/python-course
/Python course/loops.py
107
3.6875
4
numbers = [1,2,3,4,5,6,44,55,88,123] for a in numbers: print(a) i=1 while i<6: print(i) i +=1
3ab28f777a5c4c3799d9451ca7cfd971337b0c76
cwang0129/algos
/ctci/chapter_03/minStack.py
573
3.96875
4
class minStack: def __init__(self): self.stack = [] self.min = [] def push(self, value): self.stack.append(value) if len(self.min) == 0 or value < self.min[-1]: self.min.append(value) def pop(self): val = self.stack.pop() if val == self.min[-1]: self.min.pop() def get_min(self): if len(self.m...
72ccf773210cc9a979ab3f33269ac2fdc5042f8b
erocconi/AoC2020
/d2-bfpv.py
1,310
3.65625
4
#!/usr/bin/env python3 import sys class Password(object): def __init__(self, s): policy, self.password = s.strip().split(': ') policy_range, self.policy_char = policy.split(' ') self.policy_range = [int(x) for x in policy_range.split('-')] def evaluate(self): matches = self.password.count(self.po...
8cbcab7daf01a2f4b7305a521726b3a2d3a148fc
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4472/codes/1764_674.py
604
3.890625
4
# Nome: Nathaly Barbosa Leite # Curso: Estatística # Matrícula: 21954721 from numpy import * vetor = array(eval(input("Informe o conjunto de numeros: "))) #vetor = (vetor) # Quantidade de elementos do vetor print(size(vetor)) # Primeiro elemento do vetor print(vetor[0]) # Ultimo elemento do vetor print(vetor[-1])...
4ad8e6c83c09be43dd274473cdba24041f29b6c4
lingkaching/Data-Structure
/mygraph.py
4,198
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Dec 20 15:33:27 2017 @author: KACHING """ from myqueue import Queue from mypriorityqueue1 import PriorityQueue import numpy as np import pdb class Vertex: def __init__(self,key): self.id=key self.connectedTo={} def add...
40118e0cab40b0812258360ba8d89e1a6a5c2d35
SevenFive/AutomatePython
/AutoPY3while.py
382
4
4
#while loop + break (to prevent inf loop) password = '' while True: print('Please enter password: ') password = input() if password == 'swordfish': break print('Access granted') # while + continue (to skip once) i = 0 while i <= 10: i = i + 1 print('i = ' + str(i)) if i == 3: ...
9d40da52a6432472b10f05ffc700b08d47c718ba
Desperado1/mini-projects
/practice problems(Data Structures)/InsertionSort.py
227
4.09375
4
def insertionSort(array): # Write your code here. n = len(array) for i in range(1, n): j = i - 1 key = array[i] while j >= 0 and key < array[j]: array[j+1] = array[j] j -= 1 array[j + 1] = key return array
b587e629d211aa9754c1a789ee8bd1221f94ad50
CBS-UNHCR-Collaboration/Text-classifiers-project-git
/data-cleaning/non_utf_char_remover.py
2,107
3.875
4
import os """ 2017-06-02: Raghava This code will find all non-utf8 encoding characters. It will read each line and character by character to see if the char is and prints the char position """ source_filepath = '/Users/raghava/data-analytics Dropbox/Raghava Rao Mukkamala/cbs-research/student-supervision/Master-studen...
09e9862b1a184e7faffde27fda51721c2491f9e9
sqlalchemy/sqlalchemy
/examples/vertical/__init__.py
1,045
3.59375
4
""" Illustrates "vertical table" mappings. A "vertical table" refers to a technique where individual attributes of an object are stored as distinct rows in a table. The "vertical table" technique is used to persist objects which can have a varied set of attributes, at the expense of simple query control and brevity. I...
54160af36a62680ccb9efd612315594e3891399d
OmitNomis/BitAdder
/binaryConverter.py
426
4.0625
4
def decimalToBinary(decimalNo): bit = [] #list to store the converted decimal into binary for i in range (8): #running loop 8 times in order to convert the number into 8 bits remainder = decimalNo%2 #finding remainder bit.append(remainder) #adding remainder to list decimalNo = de...
4d977a76ae0a3235694ca1777bf8e5491a416352
AndrewwCD/homework_2
/homework_2.py
861
4.0625
4
#Use decorator to estimate pi to n number of decimal places import math def get_pi_n(func): def inner(n): print("Pi estimated to n number of decimal places: ") return func(n) return inner @get_pi_n def get_pi(n): pi = round(math.pi,n) return pi print(get_pi(3)) #Use lambda ...
833131f89a19612946284285bb91a845b438b793
anhuafeng123/python
/吃鸡鸡.py
367
3.515625
4
def panduan(accont,passwd): if len(account) <= 8 and len(passwd) <= 6: print("登录成功") else: print("登录失败") biaoti = "不会吃鸡" print(biaoti.center(60,"*")) def denglujiemian(): account = input("请输入账号:") passwd = input("请输入密码:") panduan(account,passwd) denglijiemian(...
7ad43c9cce9cef67e994baaae4bb0d65ec8090f4
faportillo/SatelliteSim
/geometry.py
14,251
3.9375
4
import math import numpy as np ''' Space mission geometry. Angles computed in radians ''' def spherical_to_cart(r, theta, phi): """ Convert spherical, or polar, coordinates to cartesian :param r: Magnitude of vector :param theta: Inclination Angle :param phi: Azimuth Angle...
7a1cfe7884bdcc0711750c217ddbcec0ea7fee3d
gridl/Python-Procedures
/maxfunction.py
702
4.40625
4
#file: use max() to recursively find the largest element in a list #procedure # maxoflist #parameters # lst, a list #produces # maximum, a number #purpose # to use basic recursion to find the largest item in a list #preconditions # lst must be entirely numbers that are valid in the max() operator # lst mus...
1fd98ee0243d3a61fef92ab759509ddb2e5c7b17
HaoMoney/leetcode
/lc_jz22.py
485
3.671875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def getKthFromEnd(self, head: ListNode, k: int) -> ListNode: cur = ListNode(0) cur = head length = 0 if not head: return ...
c77e69af4d82e88b08d43e8e9f22bd1da16b2261
thirtyaughtsix/solidity-math-utils
/project/emulation/FixedPoint/IntegralMath.py
3,728
3.671875
4
from .common.BuiltIn import * from .common.Uint import * ''' @dev Compute the largest integer smaller than or equal to the binary logarithm of `n` ''' def floorLog2(n): res = 0; if (n < 256): # at most 8 iterations while (n > 1): n >>= 1; res += 1; else: ...
903f764f8a01935ec4e92767df22484698821a67
Vibhurathore09/python-
/no_of_days_in_month.py
550
4.28125
4
# Number of DAYS IN A MONTH print('Program will print number of days in a given month') flag = 1 month_days = int(input(("enter month (1-12)"))) if month_days == 2: year = int(input("enter year")) if year%4==0 and year%100!=0 or year%400==0: num_days = 29 else: num_days = 28 elif m...
70305aa1024e444ecfa0d8de385e95b3074d890d
JakubKazimierski/PythonPortfolio
/Coderbyte_algorithms/Medium/LongestMatrixPath/LongestMatrixPath.py
2,460
4.40625
4
''' Longest Matrix Path from Coderbyte December 2020 Jakub Kazimierski ''' def LongestMatrixPath(strArr): ''' Have the function LongestMatrixPath(strArr) take the array of strings stored in strArr, which will be an NxM matrix of positive single-digit integers, and find the longest incr...
e465386f01b4b28887ebdb8f7d03af638b5b6765
ezhk/algo_and_structures_python
/Lesson_8/2.py
1,944
3.96875
4
""" 2*. Определение количества различных подстрок с использованием хэш-функции. Пусть дана строка S длиной N, состоящая только из маленьких латинских букв. Требуется найти количество различных подстрок в этой строке. """ import hashlib def get_substrings(input_string): uniq_substrings = {} len_str = len(inp...
dcdf12a35c673a41498fe588350911ec5642e726
GokulAB17/Decision-Trees
/DecisionTree/Company_Data.py
2,096
3.9375
4
#A cloth manufacturing company is interested to know about the segment or #attributes causes high sale. #Approach - A decision tree can be built with target variable Sale # (we will first convert it in categorical variable) & #all other variable will be independent in the analysis. import pandas as pd im...
274c9fb219473adcf49406386743d30f948b8b72
CrisExpo/Python
/Yatzy/yatzy.py
3,145
3.71875
4
class Yatzy(): @staticmethod def chance(*dice): # *argv keeps a random number of arguments, you can run 3 or 5 arguments without changing de code score = 0 for num_dice in dice: score += num_dice return score @staticmethod def yatzy(dice): if dice.co...
90b54a77f8d95c9ed18f6f117cddd37db7ea8c74
PiscesDante/Python_Crash_Course
/chapter_08/print_models.py
301
3.8125
4
def make_great(magicians_list) : new_list = [] for name in magicians_list : name += " the Great" new_list.append(name) return new_list def show_magicians(magicians_list) : magicians_list = make_great(magicians_list) for name in magicians_list : print(name)
64206e421f6ae3f4f6502b76841bcf9df7de0f89
AhmedEltaba5/Numeric-Optimization
/practical 4/Practical Session 4 Adagrad-RMSProp-Adam.py
11,611
4.59375
5
#!/usr/bin/env python # coding: utf-8 # ## Practical Work 4 # For this practical work, the student will have to develop a Python program that is able to implement the accelerated gradient descent methods with adaptive learning rate <b>(Adagrad, RMSProp, and Adam)</b> in order to achieve the linear regression of a set...