blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
18a0ea2427fe9e371589c77dba270fb477610d33 | alisonmcginley/tree-practice | /binary_search_tree/tree.py | 3,595 | 3.921875 | 4 | class TreeNode:
def __init__(self, key, val = None):
if val == None:
val = key
self.key = key
self.value = val
self.left = None
self.right = None
class Tree:
def __init__(self):
self.root = None
def add_helper(self, current_node, key, va... |
785b07a649be87381a414f0f2f29d8b55894d815 | Isshik/leetcode_python | /27. Remove Element.py | 407 | 3.703125 | 4 | # -*- encoding: utf-8 -*-
class Solution:
def removeElement(self, nums, val):
i = 0
while len(nums) != i:
if nums[i] == val:
nums.remove(nums[i])
else:
i += 1
return len(nums)
if __name__ == '__main__':
S = Solution()
num_li... |
2286e60f3da4d184847ffe0e46b332313bd3ff5b | BinXiaoEr/Target_to-Offer | /52.两个链表的第一个公共节点.py | 943 | 3.5625 | 4 | # -*- coding:utf-8 -*-
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def FindFirstCommonNode(self, pHead1, pHead2):
# write code here
lengtha=0
lengthb=0
if pHead1 is None or pHead2 is None:
ret... |
43c04ea50c40b5b74f09a27cc1d2b30457c0421d | yurinmk/python | /Faculdade/Aula 3 - Exercício G.py | 289 | 3.8125 | 4 | def main():
cores = ["azul","amarelo","vermelho","laranja","verde"]
print(cores)
#Verificar se existe a cor vermelho no vetor
if cores.__contains__("vermelho"):
cores.remove("vermelho")
else:
print("Não existe a cor vermelha!")
print(cores)
main() |
5a697840581d90f9dd4a99f171f39bf90e1c3b39 | sathyamahavishnu/sathya | /power.py | 162 | 4.3125 | 4 | import math
number = int(input(""))
exponent = int(input(""))
power = math.pow(number , exponent)
print("{0}Power{1}:{2}".format(number, exponent, power))
|
56ef3916a49bc0693ffe0bc30d65e1db29bd8f54 | ShirinNajdi/WP-tree | /Wavelet_Packet_Frequency_Band_Calculator.py | 2,623 | 3.75 | 4 | """
This repo will help researchers to explore sub-bands of wavelet packet decomposition and visualize them.
This will lead to choose correct sub-bands for feature extraction.
"""
import itertools as it
import numpy as np
import matplotlib.pyplot as plt
def freq_band_name(level):
"""
This function generates ... |
d2b7eabf39c5b6e75ab8ddf34703de2926fcdcc6 | UrviSoni/competitive-programming | /Other/04_10_20_remove_covered_intervals.py | 1,371 | 3.734375 | 4 | # Given a list of intervals, remove all intervals that are covered by another interval in the list.
# Interval [a,b) is covered by interval [c,d) if and only if c <= a and b <= d.
# After doing so, return the number of remaining intervals.
# Example 1:
# Input: intervals = [[1,4],[3,6],[2,8]]
# Output: 2
# Explanatio... |
275dfad0245a6cf31e7682c29b36531cbb2ed2de | andwilley/sched-ga | /app/models/event_gene.py | 1,331 | 3.671875 | 4 | """
EventGene class definition.
"""
import uuid
class EventGene():
"""
Map an event ID to a pilot ID.
"""
def __init__(self, event_id: uuid.UUID) -> None:
"""
Create the EventGene
Args:
event_id: the ID of the event associated with this gene.
Returns:
... |
ec19ba079152c451338b642b693805a0ddf5ef50 | Hansyaung/Coding-Interviews-Questions-And-Solutions-python- | /二维数组中的查找.py | 797 | 3.875 | 4 | '''
题目描述
在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。
请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
'''
# -*- coding:utf-8 -*-
class Solution:
# array 二维列表
def Find(self, target, array):
# write code here
if len(array) ==0:
return False
row = 0
column = len(array[0... |
fd39e64fc4195533d84ccc0414a22f20ebc01d51 | buptwxd2/data_structure | /24_binary_search_tree/binary_search_tree.py | 4,112 | 4.1875 | 4 | class Node:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def set_left(self, node):
self.left = node
def set_right(self, node):
self.right = node
# assume this binary search tree has been built already
clas... |
caa827ea497287fa80fb3a21d7de1b343b6dcc27 | AishwaryalakshmiSureshKumar/DS-Algo | /linkedlist_sort_0_1_2.py | 1,120 | 3.84375 | 4 | def printList(n):
while n is not None:
print(n.data, end=' ')
n=n.next
print()
def sortedList(head):
ptr = head
count= [0, 0, 0]
while ptr!=None:
count[ptr.data]+=1
ptr = ptr.next
ptr = head
i=0
while ptr!=None:
if count... |
eff5703eb2bc32d8824fb31ec72611f212eba0e9 | denshap/task3 | /loop.py | 147 | 3.6875 | 4 | List = [-8, 8, 6.0, 5, 'строка', -3.1]
sum=0
for i in List:
if type(i)==float or type(i)==int:
sum+=float(i)
print("%.1f" %(sum)) |
0c22f30f4c7b881c4cdcaedcc0386ac6ed32afc1 | yeung66/codesAboutCCF | /201409/stringmatch.py | 252 | 3.734375 | 4 | match = input()
flag = False
if input()=='0':
flag=True
if flag:match=match.lower()
n = int(input())
for _ in range(n):
test = input()
if flag and match in test.lower():
print(test)
elif match in test:
print(test)
|
133b75b97330a4653427ecb8e68da8bce6a40870 | Alasdair-Macindoe/TicTacToeNN | /game.py | 7,816 | 3.65625 | 4 | """
File to hold the tic tac toe game
"""
from neuralnetwork import NeuralNetwork
import random
class Game():
""" Represents a specific game of Tic Tac Toe """
NAUGHT = 'O'
CROSS = 'X'
EMPTY = '-'
_NAUGHT_TURN = True
_won = False
_nn1 = None
def __init__(self, NW = 1, CW = -1, EW = 0)... |
9d9d772fa7bb1e97552bf0ff6a94210b80fe3258 | makolyte/57exercises-python | /lesson32-guessinggame.py | 1,243 | 3.75 | 4 | import random
import math
class GuessGame():
CORRECT = 0
HIGHER = 1
LOWER = -1
def __init__(self, difficulty):
self.difficulty = difficulty
self.max = int(math.pow(10, difficulty))
self.number = random.randint(1, self.max)
self.guesses = 0
def guess(self, guess):
... |
9bf129dbbb663cbc694849d7e4716f2bdb4ce665 | carriegardner428/kaggle | /stumble/python/timer.py | 314 | 3.578125 | 4 | import time
import datetime
class Timer(object):
def __init__(self, name):
self.name = name
def __enter__(self):
self.t0 = time.time()
def __exit__(self, *args):
print "\nRan " + self.name + " in " + str(datetime.timedelta(seconds=time.time()-self.t0)) + "\n" |
012eabf45e09c98be5c6bb8bb6e89e9a31d968df | vera-a/exercism | /acronym/acronym.py | 124 | 3.75 | 4 | import re
def abbreviate(words):
acronym = re.findall(r"(\w)(?:\w*\'?s?)", words)
return ''.join(acronym).upper()
|
95782705387a4a33d4ca794b305d8c316564b26b | richien/trivia_api | /backend/flaskr/questions/helpers.py | 721 | 3.65625 | 4 | def isValidQuestion(data):
''' checks whether the proper body was sent in
the add question request
'''
# these are required fields
expected = [
'question',
'answer',
'category',
'difficulty'
]
isValid = True
for item in expected:
if item not i... |
504b687fddc9c3091e5337bda0e04e858a893eb7 | denyadenya77/beetroot_lessons | /lesson_1/a_perfect_day.py | 217 | 3.515625 | 4 | from datetime import date
import calendar
my_date = date.today()
today = calendar.day_name[my_date.weekday()]
my_name = "Denys"
print('Good day ' + my_name + '! ' + today + ' is a perfect day to learn some python.') |
8015e20952d70a98ec157fbb2ca0f57a337000ac | bobbobbio/monopy | /player.py | 8,848 | 3.921875 | 4 | import board
import game
class MonopolyPlayer(object):
def __init__(self, name, _game):
self.name = name
self.money = 1500
self.num = 0
self.current_tile = None
self.last_roll = None
self.jail_cards = 0
self.holdings = []
self.game = _game
s... |
3c8e8ad650368c286b4e2568b582e72e2fa5edca | radrajith/Artificial_Intelligence | /Search Algorithms - Proj 1/SearchAlgorithms/Stack.py | 582 | 3.921875 | 4 | #Implementation of the Stack Datastructure using the lists
class Stack:
def __init__(self):
self.stack = []
def push(self, node):
#insert the node at the start of the list
self.stack.insert(0,node)
def pop(self):
#remove the first item from the list
return self.stack... |
9ab7f4a82d6d443dcf8e1262e25dd8c917d6bd51 | hwebz/python-crash-course | /classes/survey.py | 1,219 | 4.09375 | 4 | class AnonymousSurvey:
"""Collect anonymous answer to a survey question."""
def __init__(self, question):
"""Store a question, and prepare to store responses."""
self.question = question
self.responses = []
def show_question(self):
"""Show the survey question."""
pr... |
29884a28d3f2fefaa74683fdae0302d8ce8232de | Aasthaengg/IBMdataset | /Python_codes/p03477/s516560814.py | 151 | 3.59375 | 4 | a,b,c,d = map(int,input().split())
ab = a + b
cd = c + d
if(ab > cd):
print('Left')
elif(ab < cd):
print('Right')
else:
print('Balanced') |
0cd8f0b795c9ed150be91093b18af1285b693a69 | vandensp/01-IntroductionToPython | /src/m6_your_turtles.py | 1,567 | 3.703125 | 4 | """
Your chance to explore Loops and Turtles!
Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher,
Aaron Wilkin, their colleagues, and Samuel VanDenburgh.
"""
########################################################################
# DONE: 1.
# On Line 5 above, replace PUT_YOUR_NAME_HERE wit... |
65e2962959b544ee5cfe9682314949e7cbb93206 | KorryKo/PythonPractice | /python-check/«Факториал» _Factorial_.py | 73 | 3.625 | 4 | n = int(input())
f = 1
for i in range(1, n + 1):
f = f * i
print (f)
|
765427259325bf8e772c7c408e5df09726387374 | andrewjuarez/wallbreakers-hw | /week1/self_dividing_numbers.py | 664 | 3.6875 | 4 | # https://leetcode.com/problems/self-dividing-numbers/
class Solution:
def selfDividingNumbers(self, left: int, right: int) -> List[int]:
result = []
for num in range(left, right + 1):
#print("iterating", num)
possible = num
while num > 1:
#print(... |
17c794861a01e8fb45db8f1598446fbf10434a06 | raunakchowdhury/stuy-ai | /assignments/day12/tictactoe.py | 8,523 | 3.609375 | 4 | #! /usr/bin/python3
import random
import sys
''' Layout positions:
0 1 2
3 4 5
6 7 8
'''
# layouts look like "_x_ox__o_"
Wins = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
AllBoards = {} # this is a dictionary with key = a layout, and value = its corresponding BoardNode
class BoardNode:
... |
d31cdd74dabee0c0f9508c7b9c15b7d6a113bc08 | glenjantz/DojoAssignments | /Python/pythonoop/test/test.py | 292 | 3.546875 | 4 | class Test(object):
def __init__(self, phrase='Nothing was passed'): # set the default value for 'phrase' parameter
self.phrase = phrase
test1 = Test('Hello, World!')
test2 = Test()
print "Test 1 has phrase: '" + test1.phrase + "'"
print "Test 2 has phrase, '" + test2.phrase + "'"
|
b34b6aceed5065f04a4f7c019205d3394bd1a1dc | yoshiiinuma/sync-ad-to-everbridge | /api/contact_validator.py | 8,946 | 3.5 | 4 | """
Contact Validation Functions
"""
import re
import logging
class ContactValidationResult:
"""
Keeps track of Azure contact validation results
"""
def __init__(self):
self.errors = []
self.warnings = []
self.first = None
self.last = None
self.email = None
... |
514a7a1731a3d8fe668c5edc73c879ab67db0a3c | DiegoMacana/Calculadora-de-matrices-y-vectores | /Calculadora_de_Complejos.py | 1,917 | 3.90625 | 4 | #Calculadora de Numeros complejos
#Estudiante: Diego Fernando Macana Naranjo
import math
def suma(A,B):
#print ("(",A[0],"+",A[1],"i) + (",B[0],"+",B[1],"i) = ","(",A[0],"+",B[0],") + (",A[1],"+",B[1],")i")
r=A[0]+B[0]
c=A[1]+B[1]
#if r==0:
# print("=",c,"i")
#else:
... |
6a689d20b9c6724ae2637f9122ca440969bd1c8b | ElektraInitiative/libelektra | /src/tools/pythongen/support/kdb.py | 1,935 | 3.828125 | 4 | def below(key, check):
"""Check if key check is below key"""
if key == '/':
return True # everything is below /
if len(key) > len(check)+1:
return False # key longer
if not check.startswith(key):
return False # not same prefix
if len(check) == len(key):
return False # same key
if check[len(key)] != '/':
... |
6d059c96692d075367cec1ef8e620cec05efedef | ravireddy07/LPU-Material | /src/Python Programing/Practiced Files/Binary-Decimal Conversion.py | 231 | 3.71875 | 4 | def main():
print(dbinary(7))
def dbinary(num):
b=1
rem=0
bin=0
while(num>0):
rem=num%2
bin+=rem*b
b*=10
num//=2 ''' Binary,Octal,Hexa,Decimal Conversion'''
return bin
main()
|
ede23f8b5aa2c69d3427a0e63c6c49f1f40e0482 | abderrahmanesaad/python-climb-learning-tutorial | /codewars/codewars 2/main7.py | 110 | 3.546875 | 4 | # Where my anagrams at?
def anagrams(word, words):
return [w for w in words if sorted(w) == sorted(word)] |
fd7d690f5c63337e58622e5e3786c8c29d9b848b | alercunha/adventofcode | /2017/day03.py | 2,439 | 3.90625 | 4 | import math
def part1(data):
# the depth of the spiral for a given n is the square root of n /2
# the bottom right diagonal is (depth * 2 + 1) ^ 2
# 37 36 35 34 33 32 31
# 38 17 16 15 14 13 30
# 39 18 5 4 3 12 29
# 40 19 6 1 2 11 28
# 41 20 7 8 9 10 2... |
5b26224958bc02965a502862c5e08d16ff0479a5 | CaioAvelino/Python_Fundamentos | /Cap03/Lab02/calculadora_v1.py | 1,164 | 4.1875 | 4 | # Calculadora em Python
# Desenvolva uma calculadora em Python com tudo que você aprendeu nos capítulos 2 e 3.
# A solução será apresentada no próximo capítulo!
# Assista o vídeo com a execução do programa!
print("\n******************* Python Calculator *******************")
option = int(input("\n\nSelecione o núme... |
40b43fdd7bd27856ea40e953fe378660231f6d5d | Szoul/Automate-The-Boring-Stuff | /Chapter 5/Testing_Finding_Variable_in_list_of_lists.py | 3,958 | 3.921875 | 4 | height = 5
listwithinlists = [[] for i in range (height)]
for i in range (height):
for letter in "abcd":
listwithinlists[i].append(str(i)+str(letter))
for y in range (height):
for x in range (4):
print (listwithinlists[y][x] + " ", end ="")
print ("")
variable_True = "1b"
variable_False =... |
501d1bb0cbe297cbb7a0a3fb64b530da89c1a7e0 | Mavus/project-euler | /Python/009_euler.py | 239 | 3.578125 | 4 | #!/usr/bin/python
for a in range (1,333):
for b in range(a+1,1000-a):
c = 1000 - a - b
if a*a + b*b == c*c:
print (a,b,c)
print 'abc = ', a*b*c
exit(0)
print "nothing found"
exit(1) |
32208d1d92eb1e1a8eaf2e986eee3905550e2037 | AnoopMasterCoder/python-course-docs | /12. Chapter 12/08_pr02.py | 162 | 4 | 4 | list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for index, item in enumerate(list1):
if(index+1 == 3 or index+1 == 5 or index+1 == 7):
print(item)
|
501eeb19a7b129323f21b750208616f7f4d4e552 | llx-answer/Data-Structure | /linklist.py | 1,507 | 4 | 4 |
class Node(object):
def __init__(self, value, point=0):
self.value = value
self.next = point
class Linklist(object):
def __init__(self):
self.head = 0
def initlist(self, value):
self.head = Node(value[0])
point = self.head
for i in value[1:]:
no... |
4b4db986c7d2d5d7e6fcdf53a7f0f1f47838669b | gautamkumar94/Introduction_to_Computer_Science_and_Programming-Using_Python | /oddTuples | 809 | 4.4375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 8 23:13:25 2018
@author: gautam
"""
"""
Write a procedure called oddTuples, which takes a tuple as input, and returns a new tuple as
output, where every other element of the input tuple is copied, starting with the first one.
So if test is the ... |
7ef3a7624fc933189f22c69a74942d037691dc9e | lanej/workflow | /rootfs/scheduler/utils.py | 1,814 | 3.515625 | 4 | from __future__ import unicode_literals
from copy import deepcopy
def dict_merge(origin, merge):
"""
Recursively merges dict's. not just simple a["key"] = b["key"], if
both a and b have a key who's value is a dict then dict_merge is called
on both values and the result stored in the returned dictionar... |
17cf2e6af22788ac2c545b8554b991c009cc0d9e | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_118/2094.py | 859 | 3.6875 | 4 | import math
file = 'C-small-attempt0'
def is_palindrome(number):
n = str(number)
first = int(math.floor(len(n) / 2))
second = int(math.ceil(len(n) / 2)) + (0 if len(n) % 2 == 0 else 1)
return n[0:first] == n[second:][::-1]
with open(file + '.in', 'r') as input:
with open(file + '.out... |
7dc6f81ec89e49657b820a9f7bc7863f9cde2022 | JennieOhyoung/Letter-counting | /lettercount.py | 642 | 4.03125 | 4 | # Open file --done
# Read file (optional: close file) - done
# Loop through text using char - done (essentially telling the computer to read each character on the "list")
# Convert each char in lowercase - done
# Find ordinal value to each char -done
# Create list - done
# Add counter - done
# For every repeated char,... |
12164496ff877ff748406b7258ccaaabccd51b55 | FlorinCiocirlan/Dojos | /asdasd.py | 91 | 3.90625 | 4 | letters = ["a", "b", "c", "d", "e", "f", "g", "h"]
for i in letters:
print(i.upper())
|
d44d3a36dbe79c1e5e3b972fb71911e623e2204b | zkutasi/adventofcode-2018 | /day05/1.py | 1,697 | 3.71875 | 4 | #!/usr/bin/env python
import sys
def progress(s):
sys.stdout.write("%s\r" % s)
sys.stdout.flush()
def reacts(u1, u2):
if u1 != u2 and u1.lower() == u2.lower():
return True
return False
first = None
size = 0
class Elem(object):
def __init__(self, unit, prev, next):
self.unit = unit
self.prev = ... |
c8e437ef8cb5b8f583a31c37e8d982d7fc611295 | Matheuspaixaocrisostenes/Python | /ex048.py | 193 | 3.546875 | 4 | soma = 0
cont = 0
for c in range(1 ,501 ,2):
if c % 3 ==0:
cont = cont + 1
soma = soma + c
print('a soma de todos {} valores solicitados é de \033[32m{}'.format(cont,soma)) |
e4254cf15084688bde8293097654ba2802c6d02f | danielfsousa/algorithms-solutions | /leetcode/Arrays, Strings and Hashing/217. Contains Duplicate.py | 1,000 | 3.78125 | 4 | # https://leetcode.com/problems/contains-duplicate/
from typing import List
class Solution:
def containsDuplicateSet(self, nums: List[int]) -> bool:
"""
Set approach
Time complexity: O(n)
Space complexity: O(n)
"""
seen = set()
for n in nums:
... |
f742f19bf0490a7c52f2b35fcda43f3d17c8c8fa | sarfrazahmadmca/python_practice_codes | /stacks/stack_array.py | 997 | 4.09375 | 4 | class Stack(object):
def __init__(self):
self.data = []
def push(self, value):
self.data.append(value)
def pop(self):
if self.is_empty():
raise IndexError("Index out range")
return self.data.pop()
def peek(self):
if self.is_empty():
raise IndexError("Stack is empty")
return self.data[-1]
def... |
d92e83424192281785201f01a1f1ff18dff29be2 | wysockey/pypractice | /flow.py | 358 | 3.65625 | 4 | print ("Anime is cool")
response = raw_input("How are you?")
if( response.lower() == "good"):
print ("Anime is really cool")
print ("Radical")
elif(response.lower() == "ok"):
print("Okay, I understand")
elif(response.lower() == "bad"):
print("... I dont talk to non weeb like people!")
else:
print("What was that yo... |
cf5c0f51c353d4ecfd3d70fcb877c198dd073e41 | agzuniverse/CompetitiveCoding | /DP and Recursion/longest_palindromic_subsequence.py | 790 | 3.921875 | 4 | '''
Given an input string, find the length of the longest palindromic subsequence
'''
def longestPalindromicSubstring(inp, n):
memo = [[0]*n for _ in range(n)]
for i in range(n):
memo[i][i] = 1
# The traversal is done diagonally, filling in the upper diagonal elements
# l is length of substr... |
919e9029bc9d6223806cefaf5f1128cade3cb713 | mohanakamanooru/Python | /6 Files and Data Processing/DataProcessing/RandomScattePlot.py | 590 | 4.15625 | 4 | ''''
Python Programming : Data Processing and Visualisation
Week 6 - Tutorial : To show a random scatter plot
@author : Mohana Kamanooru
email : A0223038@tees.ac.uk
Date : 02/11/2020
'''
from random import randint
import matplotlib.pyplot as plt
if(__name__ =="__main__"):
'''
... |
77d864a9aee31e766b04390a34c166bbc2828301 | trcooke/57-exercises-python | /src/exercises/Ex03_printing_quotes/test_quotes.py | 589 | 3.625 | 4 | import unittest
from exercises.Ex03_printing_quotes import quotes
class TestQuotes(unittest.TestCase):
def test_givenPlainQuote_returnQuotationOutput(self):
self.assertEqual(quotes.quotation('Michael Barry', 'If in doubt, git checkout'),
"Michael Barry says, \"If in doubt, git ch... |
285093ce46d046eb3597379c76622a0ba5261350 | zh805/PythonCookbook_Codes | /Chapter_3_数字,日期与时间/3.1数字的四舍五入.py | 1,090 | 3.78125 | 4 | '''
@Time : 2020/04/23 12:39:11
@Author : Zhang Hui
'''
# 问题:对浮点数作指定精度的四舍五入
if __name__ == '__main__':
# 使用内置的round(value, ndigits)函数即可
print(round(1.23, 1))
print(round(1.27, 1))
print(round(-1.27, 1))
print(round(1.25361, 3))
# 当一个值刚好在两个边界的中间时,round返回离它近的偶数
print(round(1.5))
... |
cba1c8a3b7843d1ed5398d08ac2ca36d8aed4976 | twolfe13/text-analysis | /chatbot_input-response.py | 501 | 3.5 | 4 | # Import Counter
import re
from nltk import word_tokenize
from collections import Counter
with open('design-portfolio.txt', 'r') as myfile:
data=myfile.read().replace('\n', '')
# Tokenize the article: tokens
tokens = word_tokenize(data)
# Convert the tokens into lowercase: lower_tokens
lower_tokens = [t.lower() ... |
c135fdbde11c76957711dd1fde0d319a55eb5d0e | MStevenTowns/Python-1 | /TurtleTrees.py | 2,802 | 4.0625 | 4 |
"""
M. Steven Towns
Assignment 20
Recursive Trees
"""
def drawTree(t,depth,length,rightAngle,leftAngle,dropL,dropR):
if depth==0:
t.color("dark green")
return
t.width(depth+1)
t.forward(length)
t2=t.clone()
t.left(leftAngle)
t2.right(rightAngle)
drawTree(t, ... |
d7c0f8600e513a20a7b80d5502fb3e1a056470d1 | gill104/NQueensPython | /parentClass.py | 2,830 | 3.625 | 4 | import random
import genotypeClass
class Parent:#---------------------------------------------------------------this class is to [MAKE THE CHILDREN] simple
def __init__(self,genoA,genoB):#----------------------------constructor that takes in two [GENOTYPES/PARENTS]
self.parent1 = genoA
self.parent2... |
54ab6fd0447c6e3ea6076057ebc2b985e45c9656 | jaeyson/py-scripts | /remove_dup_csv.py | 524 | 3.671875 | 4 | #####################################################
# remove duplicate rows of a csv file
#
# how to use (make sure file is in the current dir):
# python3 remove_dup_csv.py input.csv output.csv
#####################################################
import os
import sys
with open(sys.argv[1],'r') as input_file, open(s... |
f6c26e140ea21c42eb30e0a466dc8d6972d8d1d4 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_116/245.py | 966 | 3.578125 | 4 | #!/usr/bin/python
import sys
def check(board, player):
winchar = 'T'+player
def check_line(line):
return all((ch in winchar) for ch in line)
for row in board:
if check_line(row):
return True
for col in zip(*board):
if check_line(col):
return True
if c... |
961b1a6865b3fb603235eb85c6d0c26c8b0030c1 | deadpooltanishq78/tani | /game.py | 967 | 4 | 4 | #!/usr/bin/python3
#snake and ladder program
import random #import random libraries
count=0
r=0
while count<=100:#creates a while loop
roll=input("press r to roll")
if roll =="r":
r=random.randint(1,6)
print("u got ",r)
print("your current location is ",count)#current location
if count==8:
count=37
prin... |
7e4b89b0a7dfe6c314db544038424f09d1ecfb64 | rawhi123/Python-Project | /bikeshare.py | 8,829 | 4.34375 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) city - name o... |
78e354648105e8b09bb2644069366bf98d3b4b15 | snndmr/Image-Processing | /python/3 - Drawing Functions/episode 1.py | 944 | 3.765625 | 4 | import numpy as np
import cv2
# Create a black image
img = np.zeros((512, 512, 3), np.uint8) # 512 Array, W : 3 | H : 512
# Draw a diagonal blue line with thickness of 5 px
line = cv2.line(img, (0, 0), (511, 511), (255, 0, 0), 5)
# To draw a rectangle
rect = cv2.rectangle(img, (128, 128), (384, 384), (0, 255, 0), 5... |
3ce8e9da4cdc9781bb975137cf393a817d571d68 | kuchunbk/PythonBasic | /9_date_time/Sample/date-time_ex41.py | 451 | 3.84375 | 4 | '''Question:
Write a python program to generate a date and time as a string.
'''
# Python code:
import datetime
# Current time
now = datetime.datetime.now()
# Make a note of the date and time in a string
# Date and time in string : 2016-11-05 11:24:24 PM
datestr = "# In string: " + now.strftime("%Y-... |
e66a09d2d14a25cc888de0b03780c53be1d6f587 | RobRussmann/adventure-bit | /games/sequence/src/sequence.py | 1,130 | 3.515625 | 4 | from microbit import *
import random
import radio
points = 0
for i in range(0, 5):
letter = random.randint(0, 1)
if letter == 0:
letter = "A"
else:
letter = "B"
display.show(letter)
cond = False
while (cond is False):
if button_a.is_pressed():
cond = True
... |
962f23fc866cad704f56518dc534ae9142383201 | v4s1levzy/practicum_1 | /29.py | 321 | 3.71875 | 4 | X = int(input("Введите год:"))
if (X % 4 == 0 and X % 100 != 0) or (X % 400 == 0):
print("Год невисокосный:")
else:
print("Год високосный")
if X % 100 == 0:
X = X // 100
print(X," век")
elif X % 100 != 0:
X = (X // 100) + 1
print(X," век")
|
22c73011465d3d59fc89504d31db019c368d6209 | ArthurTriis1/puzzle8-resolver-flask | /Puzzle8.py | 3,239 | 3.578125 | 4 | class Puzzle8(object):
def __init__(self, lista, **kwargs):
pai = kwargs.get('pai')
self.lista = lista
if pai:
self.pai = pai
def getLista(self):
return self.lista
def inOrder(self):
anterior = -1
for x in self.lista:
if(x <= anter... |
9e542189ebd25c5aab955042fc85773bc558147e | gerardoojeda/Python | /CLASS4_TUPLES_EDXCOURSE.py | 1,385 | 4.28125 | 4 | import sys
# Create your first tuple
tuple1 = ("disco",10,1.2 )
print(tuple1)
print(type(tuple1))
# Print the variable on each index
print(tuple1[0])
print(tuple1[1])
print(tuple1[2])
# Print the type of value on each index
print(type(tuple1[0]))
print(type(tuple1[1]))
print(type(tuple1[2]))
# Use negative index to ... |
349dd40a599f8c7ca114fa0a3494d352f23eb639 | unixonboard/Python_Scripts | /untitled/new.py | 641 | 3.6875 | 4 | # # print("hello")
#
# def sample():
# print("i'll print this no matter")
# return
# sample()
#
# def calculator(a,b):
# # var=a+b
# return a+b
# sum=calculator(10,5)
# print(sum)
# employee={'thakur':1,'priya':2}
# def test(emp):
# new={'nandu':3}
# print("value",new)
# return new
# funcva... |
9c8279db04d4b5c89b40e100e5a7ccc9fe783673 | Connor-Mooney/Clifford-T-Synthesis-Project | /jacob_code/finding_operator_residues.py | 2,356 | 3.703125 | 4 | """
This program defines a method for determining the number of unique residues
contained in a given array of operators.
"""
import numpy as np
from numpy import sqrt
from time import time
from copy import deepcopy
import operator_module as opm
import residue_module as rem
# The sum_sort() function is an attempt at s... |
f48f0fad8c60027b7e89dd9dfcc666feb2f5322b | otega99/anime_downloader | /main.py | 2,086 | 3.546875 | 4 | #!/usr/bin/env python
import web
main_url="https://www1.gogoanime.ai"
anime=input("Please enter the anime you want to download: ").replace(" ","%20")
search_url=main_url+"//search.html?keyword="+anime
results_webpage=web.get_webpage(search_url)
results_dict={}
results=results_webpage.findAll("p",{"class":"name"})
cou... |
a23e2d60efc8a1e72b53278ced791867787ca8d5 | jiangjinshi/1807 | /07day/2-作业.py | 190 | 3.578125 | 4 | python_score = int(input("请输入成绩"))
c_score = int(input("请输入成绩"))
if (python_score > 60):
print("及格")
elif (c_score > 60):
print("及格")
else:
print("不及格")
|
195261cd438d3a8558b1e8537e16bfd01cb6d1ac | zolxl/helloword | /python/a2.8Draw.py | 77 | 3.59375 | 4 | import turtle
for i in range(100):
turtle.seth(i*90)
turtle.forward(3*i+5)
|
de4f3184f6b854ab2ab772abbf21ffb55de8b5ad | greatitman/pythonstub | /statestub.py | 1,480 | 3.734375 | 4 | import copy
import random
from math import *
"""
"""
class StateTest(object):
def __init__(self):
print "init"
def test(self):
a = 2
b = 2
print a==b
print a is b
print b is a
c = copy.deepcopy(a)
print c==a
print c is a
print a... |
3b3ec913a52dced622366fa4d2237993d6dc4c4d | Zhenye-Na/leetcode | /python/10.regular-expression-matching.py | 2,814 | 4.03125 | 4 | #
# @lc app=leetcode id=10 lang=python3
#
# [10] Regular Expression Matching
#
# https://leetcode.com/problems/regular-expression-matching/description/
#
# algorithms
# Hard (27.26%)
# Likes: 5443
# Dislikes: 831
# Total Accepted: 516.4K
# Total Submissions: 1.9M
# Testcase Example: '"aa"\n"a"'
#
# Given an inpu... |
59f389e49f7c90942ea7c9f9f2c0a0288d65dcc5 | frontendcafe/py-study-group | /ejercicios/CodeWars/Javier-Rodriguez/to_binary.py | 134 | 3.609375 | 4 | def to_binary(n):
resu = ''
while n >= 1:
resu = str(n % 2) + resu
n //= 2
return int(resu)
to_binary(10) |
691863f09c4d4bd0a40d16fc8e9882705ec42d58 | madokast/cctpy | /final_code/demos/CCT结构讲解绘图/B06四极CCT核相位.py | 4,466 | 3.671875 | 4 | """
2020年11月25日 FIXED 禁止修改
用于 books\cct\CCT几何分析并解决rib宽度问题.md
增加坐标 x y z
gif 压缩:https://gifcompressor.com/zh/
"""
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
import matplotlib.animation as animation
fig = plt.figure(figsize=(11, 4.8))
# 绝对坐标系,确定绘图板位置
ax = plt.axes([0.15, 0.10, 0.35, ... |
a991c117a2226dcded47e735422e272018677e65 | coco-team/log2model | /tools/animator_multi.py | 1,550 | 3.765625 | 4 | import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
import sys
array = []
totalargs = len(sys.argv)
for i in xrange(1,totalargs):
print sys.argv[i]
array.append(np.genfromtxt(sys.argv[i], delimiter=','))
plotlays, plotcols = [2,5], ["black","red"]
# First set up the figu... |
88fb45b6edcee190e70cbace972df03c5f0f763b | clattems/pythonlearning | /loopcontrol.py | 397 | 3.6875 | 4 | #!/usr/local/bin/python3
counter = 0
while counter < 100:
if counter == 4:
break
print(counter)
counter = counter + 1
while counter < 100:
if counter == 4:
break
else:
pass
print(counter)
counter = counter + 1
for i in "Python":
if i == "h":
continue
... |
bc991a1265d0df8ad04c3d777ee1af5712c0c880 | hemal507/CS-Algorithms | /piecesOfDistinctLengths.py | 207 | 3.671875 | 4 | def piecesOfDistinctLengths(s):
r = 0
i = 1
while r < s :
i+=1
r+=i
return i - 1
'''
print(piecesOfDistinctLengths(14))
print(piecesOfDistinctLengths(3))
print(piecesOfDistinctLengths(4))
'''
|
f00ce0a130172a8e94fc65a7419b1725f9282bf7 | jorlugaqui/drawingToolPractice | /models/illustrator.py | 10,330 | 3.671875 | 4 | #! -*- coding: utf-8 -*-
""" Module for managing models."""
class Canvas():
"""Canvas Model."""
def __init__(self, w, h):
"""
:param w: The width
:param h: The height
"""
self.w = w
self.h = h
self.canvas = []
self.create_canvas()
def crea... |
31888f62d570b101e1afcd41deacde1990ca7278 | isepulvedamunoz/cursos_platzi | /Datascience school/Python/diccionarios.py | 248 | 3.953125 | 4 | my_dict = {
'David':35,
'Erika':32,
'Jaime':25,
}
print(my_dict['David'])
print(my_dict.get('Ignacio', 30))
my_dict['Ignacio'] = 31
print(my_dict)
def llaves(dict):
for valor in dict.values():
print(valor)
llaves(my_dict) |
d47d2e55d6e290a2f2df8d6c67855fd70da4f15a | huhudaya/leetcode- | /LeetCode/912. 排序数组(复习基础排序算法).py | 5,249 | 4.0625 | 4 | '''
给你一个整数数组 nums,请你将该数组升序排列。
示例 1:
输入:nums = [5,2,3,1]
输出:[1,2,3,5]
示例 2:
输入:nums = [5,1,1,2,0,0]
输出:[0,0,1,1,2,5]
'''
# 快排
from typing import List
import random
class Solution:
def randomized_partition(self, nums, l, r):
# 找一个随机数
pivot = random.randint(l, r)
# 和最后一个元素进行交换
... |
76579c2cf5dc3ba3813b4409caebd4f2aa67bf18 | AkshayPradeep6152/letshack | /Sum.py | 109 | 3.921875 | 4 | n = 10
sum = 0
for num in range(0, n+1, 1):
sum = sum+num
print("SUM of first ", n, "numbers is: ", sum)
|
fccc19d6495f7a9c125f6988e17b9a020248f3ad | doitfor10/my_algorithm | /algorithm/test_61_dfs_bfs.py | 1,130 | 3.53125 | 4 | # 백준 1260번 https://www.acmicpc.net/problem/1260
# DFS & BFS 그래프 탐색하기
#vertax,edge,start
N,M,V = map(int,input().split())
coordnate = [[0]*(N+1) for _ in range(N+1)]
#간선만큼 돌며..
for _ in range(M):
f_vertax,s_vertax = map(int,input().split())
coordnate[f_vertax][s_vertax] = 1
coordnate[s_vertax][f_vertax] = 1
... |
e661fb49090940bcc238cc3ed94e60afb46610ca | nebula-28/Python-Applications | /News Application.py | 1,150 | 3.796875 | 4 | #This application uses News API and Tkinter
import requests
import tkinter as tk
def getNews():
api_key = "69098ca7575f42069325e5168a565e07"
url = "https://newsapi.org/v2/top-headlines?country=in&apiKey="+api_key
news = requests.get(url).json()
headings=news['articles'] #this has a list of dictioa... |
34d37d54bfe05fc0302dcd053bdac6445a7af167 | Nelcyberth86/IntroProgramacion | /funciones/ejercicio6.py | 574 | 3.96875 | 4 | # Definir una función es_palindromo() que reconoce palíndromos (es decir, palabras que
#tienen el mismo aspecto escritas invertidas), ejemplo: es_palindromo ("radar") tendría que devolver True.
def palindromo(palabra):
tam = len(palabra)
aux= tam -1
contador = 0
for i in range(0,tam):
if (palab... |
cee4f314ae95fcc525f0ef9fe8a53f235fb05a68 | alexovidiupopa/Fundamentals-of-Programming- | /A05-09/model/iterablestructure.py | 3,624 | 4.03125 | 4 | import unittest
class IterableStructure:
'''
Class for the iterable structure required for A9
'''
def __init__(self):
self.__index = 0
self.__list = []
def __iter__(self):
'''
structure iterator
'''
return iter(self.__list)
... |
93da46a75d0c1d4cec42044afe602755a2c15122 | 369geofreeman/MITx_6.00.1x | /codewars/Removing-Elements.py | 442 | 4.09375 | 4 | # Removing Elements
# Take an array and remove every second element out of that array. Always keep the first element and start removing with the next element.
#
# Example:
#
# my_list = ['Keep', 'Remove', 'Keep', 'Remove', 'Keep', ...]
def remove_every_other(my_list):
# Your code here!
return [v for i,v... |
8030cd585494704a9b73e73e5cafea1c5b3cf21a | dxy/dxy-bin | /p2n.py | 1,370 | 3.96875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2012 Daisuke Yabuki. All Rights Reserved.
"""Convert an IP address from printable string to an integer.
Convert an IP address from its address family specific string format
(i.e. dotted decimal notation for IPv4) to an integer, e.g. 127.0.0.1
to 2130706433.
Sampl... |
8d0fb4cfd1c26a1295aeaabddc4de4055ebf97ff | maharshmellow/pyropes | /test/test_ropes.py | 5,217 | 3.546875 | 4 | import unittest
from pyropes import Rope
class Test(unittest.TestCase):
def setUp(self):
# TODO: targets
pass
def test_empty(self):
rope = Rope()
self.assertEqual(None, rope.root)
self.assertEqual(0, rope.size)
self.assertEqual(0, len(rope))
self.asser... |
00c5edbfb0eda891f5e01d44407ad6fcbf20abf1 | MaesterPycoder/Python_Programming_Language | /codelist1/operatoroverriding.py | 288 | 3.59375 | 4 | class bookx:
def __init__(self,pages):
self.pages=pages
def __add__(self,other):
return self.pages+other.pages
class booky:
def __init__(self,pages):
self.pages=pages
b1=bookx(100)
b2=booky(200)
print("Total pages in the book=",b1+b2)
|
d88d34f868ae34a2279b31e55c6fdae4c6486d85 | sanchez-17/ejercicios-python-UNSAM | /Clase09/canguros_buenos.py | 1,828 | 3.8125 | 4 | # -*- coding: utf-8 -*-
class Canguro:
def __init__(self, contenido_marsupio):
self.contenido_marsupio = contenido_marsupio
def meter_en_marsupio(self, item):
self.contenido_marsupio.append(item)
def __str__(self):
"""devuelve una representación como cadena de este Canguro.
"""
... |
ab1f8b17c24e90f7c60d835ab803aa3894f9beda | RealMikeyM/PUBG_Sqlite_database | /Mauricio_Test_functions/Mauricio_Test_functions/players.py | 2,774 | 3.90625 | 4 | import sqlite3 as sq
import csv
PLAYERCSV = "players.csv"
PLAYERSQL = "Players.sqlite"
class Players:
def __init__(self):
self.__conn = sq.connect(PLAYERSQL)
self.__cur = self.__conn.cursor()
self.__fieldNames = ["id", "username", "first_name", "last_name", "phone", "address", "gender",... |
e52cd0ef60eb1a40055668ab46efa4268debf8bf | etsvetanov/Algorithms | /misc/test.py | 785 | 3.8125 | 4 | # def test(a, b, c):
# print(a, b, c)
#
# test('a', 'b', 'c')
# 2 args, vending machine, cost of item, money supplied, return [] with possible coins [1, 2, 5, 10, 20, 50, 100, 200]
COIN_VALUES = [200, 100, 50, 20, 10, 5, 2, 1]
def vendingMachine(payment, cost_of_item):
change_value = payment - cost_of_item
... |
144884c7c0a2899c89b5da05416b4f2fac0a0021 | bg4erem/geek-python-aic | /lesson01/example05.py | 284 | 3.671875 | 4 | max_count = int(input("Max number >>> "))
delimeter = int(input("Delimiter >>> "))
current_count = 0
while True:
if current_count == max_count:
break
current_count = current_count + 1
if current_count % delimeter == 0:
continue
print(current_count) |
49ce93ae9de4b1140179aecdb19d7b545300114a | shubhamx939/Python_Codes | /Pentagon_Practice.py | 826 | 4.0625 | 4 | #Taking two Strings:
print("Enter 1st String S1")
s1=input()
print("Enter 2nd String S2")
s2=input()
#Reversing the Second String so that we can traverse straight through it:
s2=s2[::-1]
#Calculating the length of the Strings:
len1=len(s1)
len2=len(s2)
#Initial values for i and maxLen:
i=0
maxLen=... |
85a28d263c5767973f23f59772d3bc96a1f93b87 | wusanpi825117918/study | /Day03/p_10九九乘法表.py | 240 | 3.53125 | 4 | '''
打印99乘法表
'''
def nine_nine_table():
i = 1
while i <= 9:
j = 1
while j <= i:
print('%d*%d=%-3d' % (j, i, j*i), end=' ')
j += 1
print()
i += 1
nine_nine_table() |
638855c45654a4d9dec8900cf96d7bdcfa110c33 | mathis-girault/Mastermind | /play.py | 4,049 | 3.890625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Import des librairies utilisées :
import os
# Imports des fichiers utilisés :
import common
def play(codemaker, codebreaker):
"""
Fonction principale de ce programme :
Fait jouer ensemble le codebreaker et le codemaker donnés en arguments
"""
n_trie... |
3396c24815d6366c8306c9c4d63772db880f964b | WenyuChang/python-learning | /src/Learning_DataStructure/Queue/BuildinQueue.py | 2,232 | 3.828125 | 4 | __author__ = 'wenychan'
def producer_consumer_usage(produce_count=5, consumer_count=10):
"""Using build-in queue module as a blocking queue to demo producer and consumer problem"""
import threading
import time
from Queue import Queue
lock = threading.Lock()
max_queue_size = 10
product... |
0105b7bc1402645b720c211a5058cd41795907bc | gkl1107/Python-algorithm | /alarm.py | 552 | 3.90625 | 4 | #!/usr/bin/python
import sys
current_time_str = raw_input("What is the current time (in hours 0-23)? ")
wait_time_str = input("How many hours do you want to wait? ")
print(type(current_time_str))
try:
current_time_int = int(current_time_str)
print(current_time_int)
wait_time_int = int(wait_time_str)
final_tim... |
8cc52a68907420640b4a9ba464343a26f8a9e332 | pranaymate/Python_3_Deep_Dive_Part_1 | /Section 5 Function Parameters/63. Positional and Keyword Arguments - Coding.py | 1,175 | 3.875 | 4 | def my_func(a, b, c):
print("a={0}, b={1}, c={2}".format(a, b, c))
my_func(1, 2, 3)
def my_func(a, b=2, c=3):
print("a={0}, b={1}, c={2}".format(a, b, c))
# def fn(a, b=2, c):
# print(a, b, c)
# File "<ipython-input-4-2180ec769037>", line 1
# def fn(a, b=2, c):
# ^
# SyntaxError: non-def... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.