blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
de03ef703174213c6b78cb401a6093683deaa159 | wwwwodddd/Zukunft | /leetcode/maximum-difference-between-node-and-ancestor.py | 601 | 3.59375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def maxAncestorDiff(self, root: Optional[TreeNode]) -> int:
z = 0
def dfs(x, mn, mx):
... |
48be00a7d6d4b934b236d49951d4651e4eaf99f1 | wwwwodddd/Zukunft | /leetcode/map-sum-pairs.py | 375 | 3.53125 | 4 | class MapSum:
def __init__(self):
self.d = {}
def insert(self, key: str, val: int) -> None:
self.d[key] = val
def sum(self, prefix: str) -> int:
return sum(self.d[k]for k in self.d if k.startswith(prefix))
# Your MapSum object will be instantiated and called as such:
# obj = Map... |
e7e8174a4b18a4cb172055335218c35e46dfe23b | wwwwodddd/Zukunft | /codechef/BIRDFARM.py | 206 | 3.609375 | 4 | for t in range(int(input())):
x, y, z = map(int, input().split())
if z % x == 0 and z % y == 0:
print('ANY')
elif z % x == 0:
print('CHICKEN')
elif z % y == 0:
print('DUCK')
else:
print('NONE') |
a98c88cfab12493ed9a1603c575b5e4eb36550ea | wwwwodddd/Zukunft | /leetcode/longest-univalue-path.py | 756 | 3.71875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def longestUnivaluePath(self, root: Optional[TreeNode]) -> int:
z = 0
def dfs(x):
... |
25c1b4a4ecbda8bb77a93c7fecb5268585b4d84f | wwwwodddd/Zukunft | /leetcode/balance-a-binary-search-tree.py | 656 | 3.640625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def balanceBST(self, root: TreeNode) -> TreeNode:
def dfs(x):
if x == None:
... |
5d41068d3970b1819aac531f06e2f62078b2baa0 | wwwwodddd/Zukunft | /CF/870A.py | 144 | 3.703125 | 4 | raw_input()
a = set(raw_input().split())
b = set(raw_input().split())
if a & b:
print min(a & b)
else:
print ''.join(sorted((min(a), min(b)))) |
9c85d8e6fb1440d8409bc3cbc296776cb83a0a37 | wwwwodddd/Zukunft | /leetcode/odd-even-linked-list.py | 556 | 3.71875 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def oddEvenList(self, head: Optional[ListNode]) -> Optional[ListNode]:
o = p = ListNode()
e = q = ListNode()
c = 0
wh... |
62ff406f01dae42b1b6fcf9279f3445def379d60 | wwwwodddd/Zukunft | /leetcode/moving-average-from-data-stream.py | 431 | 3.625 | 4 | class MovingAverage:
def __init__(self, n: int):
self.n = n
self.q = deque()
self.s = 0
def next(self, v: int) -> float:
self.q.append(v)
self.s += v
if len(self.q) > self.n:
self.s -= self.q.popleft()
return self.s / len(self.q)
# Your Movi... |
14fba096e73044dd8d6b036f956876e6495a6804 | wwwwodddd/Zukunft | /leetcode/remove-duplicates-from-sorted-list.py | 412 | 3.640625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def deleteDuplicates(self, h: Optional[ListNode]) -> Optional[ListNode]:
i = h
while i and i.next:
while i.next and i.val... |
c39643a26f3e76fdf1bb8b76ae809b8554e6e8d2 | wwwwodddd/Zukunft | /leetcode/symmetric-tree.py | 571 | 3.890625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
def shi(x, y):
if x==None and y... |
4a7af2e619ca112e0f65ca033e60cc7183d78968 | wwwwodddd/Zukunft | /atcoder/abc132_a.py | 73 | 3.546875 | 4 | s=sorted(input())
print('YNeos'[s[0]!=s[1]or s[1]==s[2]or s[2]!=s[3]::2]) |
2b57f12d248158579c6b4e93d8107e61376775e6 | wwwwodddd/Zukunft | /leetcode/design-compressed-string-iterator.py | 739 | 3.5 | 4 | class StringIterator:
def __init__(self, s: str):
self.s = s
self.p = 0
self.c = 0
self.d = 0
def next(self) -> str:
if not self.hasNext():
return ' '
if self.d == 0:
self.c = self.s[self.p]
self.p += 1
while self... |
770d21cd4f6c21159bce54f4f695d00a7fd963aa | wwwwodddd/Zukunft | /leetcode/random-pick-index.py | 508 | 3.5625 | 4 | class Solution:
g = {}
def __init__(self, a: List[int]):
self.g = {}
for i in range(len(a)):
if a[i] not in self.g:
self.g[a[i]] = []
self.g[a[i]].append(i)
def pick(self, target: int) -> int:
if target not in self.g:
return None
... |
2036a0047b17c76ea7c988367bf8eae9cd0e80b0 | wwwwodddd/Zukunft | /PE/454.py | 107 | 3.578125 | 4 | for i in range(25):
for j in range(25):
x = 2 ** i * 5 ** j
y = 10 ** 24 / x
if x < y:
print x |
0a5f55c3a04670b1a37cffd63dbd0a29f54cf83c | wwwwodddd/Zukunft | /PE/162.py | 313 | 3.625 | 4 | def F(x, y):
re = 0
for i in range(1, 17):
re += x * y ** (i - 1)
return re
ans = 0
ans += F(15, 16) # +A01
#print F(15, 16)
ans -= F(14, 15) # -01
ans -= F(15, 15) # -A1
ans -= F(14, 15) # -A0
ans += F(14, 14) # +A
ans += F(14, 14) # +1
ans += F(13, 14) # +0
ans -= F(13, 13) # -
print ans
print '%X' % ans |
42b4110a95d4e1c0e25e5df1382301c9362c6e9c | wwwwodddd/Zukunft | /CF/1684A.py | 97 | 3.640625 | 4 | for tt in range(int(input())):
s = input()
if len(s) == 2:
print(s[1])
else:
print(min(s)) |
dda7bb671363021e5c01693d3c2677ed0a2dab02 | edharcourt/CS140 | /python/factorial.py | 147 | 3.84375 | 4 |
prod = 1
for i in range(26,0,-1):
prod = prod * i
print(prod)
prod = 1
for i in range(1,27):
prod = prod * i
print(prod) |
dc898953a425e4f2ca257f7ef34de186e2d6c714 | edharcourt/CS140 | /python/compareTheTriplets.py | 828 | 3.8125 | 4 | def compareTheTriplets(a, b):
pass # student fill in function here
a_score = 0
b_score = 0
for i in range(3):
if a[i] > b[i]:
a_score += 1
elif a[i] < b[i]:
b_score += 1
return (a_score, b_score)
# M a i n P r o g r a m
# Test Sample Input 0
if compreTh... |
1b9bb4cbe3063743b521b49dd75d3c1bc3951801 | edharcourt/CS140 | /python/loop_exercises/fib.py | 176 | 3.703125 | 4 |
# Compute the 100th Fibonacci number
prev = 0
curr = 1
n = 2
while n < 100:
n += 1
tmp = curr
curr = curr + prev
prev = tmp
print(n,curr)
|
0094eb3ebca0eb6e5756203c7c728b509b05f146 | LuisAlbertoOliveira/Python-CursoemVideo | /aula07a.py | 278 | 4.09375 | 4 | a=int(input('Digite um numero: '))
b=int(input('Digite outro numero:'))
s=a+b
m=a*b
d=a/b
di=a//b
p=a**b
print('A soma entre {} e {} é {}'.format(a,b,s), end=' ')
print('A multiplicação é {}, a divisão é {:.2f}, a divInteira é {}, a potencia é {}'.format(m, d, di, p))
|
deebfaddc0940c0948c1c76b4e5ebfbb24e39eaf | xiongdong57/design_of_computer_program | /lesson3/matchset.py | 3,727 | 4.125 | 4 | #----------------
# User Instructions
#
# The function, matchset, takes a pattern and a text as input
# and returns a set of remainders. For example, if matchset
# were called with the pattern star(lit(a)) and the text
# 'aaab', matchset would return a set with elements
# {'aaab', 'aab', 'ab', 'b'}, since a* can consum... |
0d01539466932f9f009105e09aa0ef6284cafa5c | DenilsonGomes/Socket-de-Redes | /Servidor.py | 1,336 | 3.640625 | 4 | # -*- coding: cp1252 -*-
print 'Autores: Denilson Gomes Vaz da Silva e Julio Cesar Rodrigues'
print 'Trabalho de Redes'
print 'Implementao de Sockets\n'
#importao de modulos
import socket
import thread
host = '' # Endereco para o Servidor ouvir
porta = 5000 # Porta que o Servidor esta ouvindo
print 'Servidor esperand... |
0e4d622bff0a1a1903c310fc7e9a0c668afb5e04 | xlmriosx/Pomodoro | /pomodoro.py | 1,231 | 3.609375 | 4 | import time
from plyer import notification
poms = 0
print("Bienvenido a Pomodoro")
if __name__ == "__main__":
while True:
option = input(f'1. Para 25 minutos de trabajo y 5 de descanso'
f'\n2. Para 50 minutos de trabajo y 10 de descanso'
f'\nOpcion: ')
... |
746db7a7abfb75aa5f47f224ba74751c979f3fce | JLew15/Python | /Cards/gameFunctions.py | 1,589 | 3.515625 | 4 | import time
import sys
def slowText(text, amtime):
"""MAKES TYPING EFFECT TEXT"""
for char in text:
time.sleep(amtime)
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(0.5)
print()
def getNumber(question, high, low):
response = None
while response not in range(l... |
3981067a47735afe28eb0854066f9352816896c2 | JLew15/Python | /chapter2.1examples.py | 246 | 3.5 | 4 | x = 3
print(type(x))
x = x + .8
print(type(x))
name = "Jay"
print(type(name))
awake = True
print(type(awake))
#Key words
#True
#False
#and
#as
#assert
#break
#class
#continue
#def
#del
#elif
#else
#except
#finally
#for
#from
#global
#if
#import
|
1da903be540d9cd3d432c3b4d42f2ed1cdcb0b4e | JLew15/Python | /chapter2and3.py | 433 | 3.5625 | 4 | number = 10
print(type(number))
score = 10000
number2 = 7.0
answer = number + number2
print(type(answer))
print(answer)
print(2+5*7/8+3/(8+7*4))
tableline="----------------------------------"
strScore = "Score:-------------------- " + str( score + 100) + "\n" + tableline
print(strScore)
print(strScore)
print(strScore)... |
dddfd2527e7e09db2f936c8708bd5ad5e7045953 | zacharytq/advent-of-code-2020 | /day_1.py | 483 | 3.59375 | 4 | target_number = 2020
with open('input_day_1.txt') as input:
nums = []
while (line := input.readline().rstrip()):
nums.append(int(line))
nums.sort()
for i, number in enumerate(nums):
complementary_number = target_number - number
if complementary_number in nums[i+1:]:
... |
60a78615f015d60e9086528d02fae1f80d58f12b | NIMIII/Softuni | /SoftUni/Activation Keys.py | 1,204 | 3.703125 | 4 | string = input()
data = input()
while data != "Generate":
token = data.split(">>>")
command = token[0]
if command == "Contains":
substring = token[1]
if substring in string:
print(f"{string} contains {substring}")
else:
print("Substring not found... |
8fd926f8cb17433c8b3c31bf7111affbda53179d | nexus-lab/secure_scripting_python | /20.SeSPython_AssessmentAnswerFiles/For Windows/new2.py | 330 | 3.6875 | 4 | import sys
if len(sys.argv)-1 != 3:
print("Usage: "+sys.argv[0]+" num1 num2 [ -m | -d ]")
sys.exit(1)
if sys.argv[3] == "-m":
print(int(sys.argv[1]) * int(sys.argv[2]))
elif sys.argv[3] == "-d":
print(int(sys.argv[1]) / int(sys.argv[2]))
else:
print(sys.argv[0]+": third argument must be -m or -d")
sys.exit(1)
sy... |
b11e8603aa6e7579594a6243f873ea6233ed35d8 | nexus-lab/secure_scripting_python | /04.SeSPython_Unit1_TheBasics_DataFiles/Part I/nameQuestionCheck.py | 124 | 4.09375 | 4 | name = input("what is your name: ")
if len(name) > 1:
print("please to meet you ",name)
else:
print("Please enter a name") |
a87ce59e405c86c4827d91c104713f97e929aedd | nexus-lab/secure_scripting_python | /04.SeSPython_Unit1_TheBasics_DataFiles/Part I/stringSearchMessage.py | 278 | 4 | 4 | import sys
myString = "this is a text with several words"
if len(sys.argv) != 2:
print("Usage: give exactly 1 argument, the string to be looked for")
else:
target = sys.argv[1]
if(target in myString):
print(target," was found!")
else:
print(target," was NOT found!")
|
7197edc132812121c3b9a7aa3541162b0b05b9dc | MarcT89/sidewalkify | /sidewalkify/graph/find_paths.py | 851 | 3.765625 | 4 | from typing import List
import networkx as nx
from sidewalkify.graph.find_path import find_path, Path
def find_paths(G: nx.DiGraph) -> List[Path]:
"""Find paths representing a combinatorial map of sidewalks.
:param G: A graph with edges labeled with 'az1' and 'az2' keys,
where 'az1' = azimuth... |
ba841dc0c17e4730dcfb9e432731a53c9cd0a157 | MarcT89/sidewalkify | /sidewalkify/geo/cw_distance.py | 459 | 4.125 | 4 | def cw_distance(az1: float, az2: float) -> float:
"""
Calculates the 'clockwise' distance between two azimuths, where 0 = North
and the direction of increasing angle is clockwise.
:param az1: Azimuth 1.
:type az1: float
:param az2: Azimuth 2.
:type az2: float
:returns: The angular dista... |
9a06a32294de88987fef4f2f2904fa93462ced12 | Omkar-M/Coffee-Machine | /Problems/Lexical reduplication/task.py | 58 | 3.5 | 4 | word = input()
# Change the next line
print(word + word)
|
55c5d53c92592f6fc1ba1e3976d539e0eef1a500 | Omkar-M/Coffee-Machine | /Problems/Game over/task.py | 281 | 3.640625 | 4 | scores = input().split()
correct = 0
incorrect = 0
for x in scores:
if x == 'C':
correct += 1
elif x == 'I':
incorrect += 1
if incorrect == 3:
print('Game over')
print(correct)
break
else:
print('You won')
print(correct)
|
09ea9e70cb52fca8dd8da77ef4dac82dd45b1f30 | sauuyer/python-practice-projects | /day7-word-cleaner-counter.py | 732 | 4.3125 | 4 | def user_input_word_checker():
while True:
try:
entered_word = input("Enter a word to be counted: ")
entered_word = entered_word.strip()
length_of_entered_number = len(entered_word)
print(f"The length of {entered_word} is {length_of_entered_number}.")
... |
a9ce15149454899d559aed6eddb0e1a2b2711646 | sauuyer/python-practice-projects | /day7-splitstackshape.py | 685 | 3.9375 | 4 | name = input("Enter your first and last name in this format -> Lastname, Firstname: ")
name = name.title().strip()
split_name = name.split(",")
print(split_name)
num_list = [1, 2, 3, 4, 5]
str_list = []
for each in num_list:
str_num = str(each)
str_list.append(str_num)
str_list = " | ".join(str_list)
print(s... |
f181daaaf53cc3bf473845412edf82962835a9e6 | mrdbourke/LearnPythonTheHardWay | /ex11.py | 501 | 3.6875 | 4 | """
print "How old are you?",
age = raw_input()
print "How tall are you?",
height = raw_input()
print "How much do you weigh?",
weight = raw_input()
print "So you're %r old, %r tall and %r heavy." % (
age, height, weight)
"""
print "What is your name?",
name = raw_input()
print "What is your favourite food?",
food ... |
ab024c117a9eb726ffa85d8d3dd7167cbcf0527b | mrdbourke/LearnPythonTheHardWay | /ex16.py | 1,268 | 4.8125 | 5 | from sys import argv
#the filename is the argument variable
#enter into terminal, python script filename
script, filename = argv
#Asking the user whether or not they want to erase the file
print "We're going to erase %r." % filename
print "If you don't want that, hit CTRL-C (^C)."
print "If you do want that, hit RETU... |
0d3bcb5a4e1409124d0b8be881e8f318bede31ce | majaszymajda/wstep_do_algorytmow | /Lista_4/drzewo_binarne.py | 5,014 | 3.65625 | 4 | import binarytree
def drzewo_binarne_1():
class Node:
def __init__(self, data=None, left=None, right=None):
self.data = data
self.left = left
self.right = right
def __str__(self):
return str(self.data)
class NodeS:
# wezel binarny do ... |
d6d0fd7acbad62b7714383132436b8c2f4653356 | angian00/soccer-manager | /scripts/extract_nomi.py | 1,040 | 3.9375 | 4 | #!/usr/bin/env python3
namefile = "resources/nomi_italiani.csv"
def main():
#read female names first
female_names = set()
with open(namefile) as f:
first_line = True
for line in f:
if first_line:
#skip header
first_line = False
continue
tokens = line.split(",")
name = tokens[0]
gender ... |
3e90708f1ad22c9ad6e28af703c5c64a29e5bd1b | fabruun/DS800 | /python/exercise_1/untitled0.py | 400 | 3.90625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 9 14:52:02 2020
@author: fred
"""
print("Welcome to the input program!")
keyboard = input(str("Please input your sentence:"))
if(keyboard.find(" ") >):
print("I contain spaces")
else:
if(keyboard.islower()):
print("I am lower-case... |
4a78fa563ca1d61c7b9b3fe201056d457641b289 | Mryangtaofang/pyleetcode | /leetcode/GreaterTree.py | 561 | 3.625 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
class Solution:
"""
https://leetcode.com/problems/convert-bst-to-greater-tree/
"""
sum = 0
def convertBST(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
if root:
self.convertBST(root.right)
... |
69f22325f631f60011f2342303a37a20abda87bb | hayesmit/PDXCodeGuildBootCamp | /lab8-Make_Change.py | 744 | 3.609375 | 4 | #lab8-Make_Change.py
amount = round(float(input("How much much money do you have, lets make some change? example $4.25 >> $"))*100)
print(amount)
amount = int(amount)
print(amount)
quarters = amount//25
amount = amount - quarters*25
print(amount)
dimes = amount//10
print(dimes)
amount = amount - dimes*10
print(amou... |
a849d9d8299971bf5bef27df851c1cbff573e1e8 | hayesmit/PDXCodeGuildBootCamp | /practice_dictionary_problems.py | 284 | 3.734375 | 4 | # practice_dictionary_problems.py
#problem 1
player = ['jordan', 'labrron', 'kobey', 'oden', 'drexler']
their_number = [23, 8, 12, 45, 6]
def make_dictionary(key, value):
return dict(zip(key, value))
my_dictionary = make_dictionary(player, their_number)
print(my_dictionary)
|
6afb61d53a8289ec8079c3e1b4982ad0e2dfe0e8 | hayesmit/PDXCodeGuildBootCamp | /lab11-Simple_Calculator.py | 719 | 4.1875 | 4 | #lab11-Simple_Calculator.py
#import operator
#again = "yes"
#ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv, }
#while again != "done":
# operation = input("which operation would you like to perform? +, -, *, / >> ")
# firstNumber = float(input("What is the first number? ... |
345986fccd0c116f4e3d913bd3a51c545fa78769 | hayesmit/PDXCodeGuildBootCamp | /practie_comprehensions.py | 225 | 4.0625 | 4 | #practice_comprehensions.py
#problem 1
#powers_of_two = [2**x for x in range(10)]
#print(powers_of_two)
#problem 3
dictionary = {'a': 1, 'b': 2, 'c': 3}
dictionary = {v: k for k, v in dictionary.items()}
print(dictionary)
|
b2f71b16b986c4b349d8c549bcf963dbfb19a650 | open-all/edu.gcccd.csis | /primeOrNot.py | 1,576 | 4.15625 | 4 | """
Program to perform simple primality test on integers
Program: primeOrNot.py
Author: Elias McCoy
Last date modified: 2/20/19
Enter a number into the command line and you will be told if it is prime and its smallest divisor that isn't 1
"""
class primeOrNot:
#primality test of any int n
def primeOrNot(n):
... |
9bc0af8efdcdee32c9853fe36fe8bda62ca36e8d | marjan-sz/CodeSignal_Solutions | /removeDuplicateStrings.py | 1,179 | 4.0625 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 28 22:01:27 2020
@author: marjan
Question: Remove all duplicates from an already sorted (in lexicographical order) array of strings.
Redefine the question:
a) an array of strings is given as input/array is sorted
b) remove all duplicates ... |
b50fdb7920d2a76ef7406b853e3dbfc34e948705 | marjan-sz/CodeSignal_Solutions | /anagramsOrNot.py | 3,815 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 3 19:24:07 2020
@author: marjan
A) Redefining the question:
we are having two string as input, check if they are anagrams and if they are return true, otherwise return false
Anagram: two words are anagrams if they both have the exact same set of ... |
a8313489a25deab6d7d579921cda7392b3bdfa02 | dwy927/leetcode | /easy/190.reverse-bits/190.reverse-bits.py | 1,007 | 3.609375 | 4 | #
# [190] Reverse Bits
#
# https://leetcode.com/problems/reverse-bits/description/
#
# algorithms
# Easy (29.26%)
# Total Accepted: 150.8K
# Total Submissions: 515.3K
# Testcase Example: ' 43261596 (00000010100101000001111010011100)'
#
# Reverse bits of a given 32 bits unsigned integer.
#
# Example:
#
#
# Input:... |
0915f3514e0b73d7c2c10aad770b7d9dab46ae02 | dwy927/leetcode | /medium/2.Add-Two-Numbers/2.add-two-numbers.python3.py | 1,782 | 3.90625 | 4 | #
# [2] Add Two Numbers
#
# https://leetcode.com/problems/add-two-numbers/description/
#
# algorithms
# Medium (29.92%)
# Total Accepted: 690.9K
# Total Submissions: 2.3M
# Testcase Example: '[2,4,3]\n[5,6,4]'
#
# You are given two non-empty linked lists representing two non-negative
# integers. The digits are stor... |
d7e3f03a30155b20d3c71d9225710f4cef331378 | yenpinchiu/Eight-Legged-Essay | /Codility_Number_Of_Square.py | 353 | 3.6875 | 4 | # number of whole square number within a range
import math
class Solution(object):
def FindSquareNumNum(self, a, b):
min_squre_num = math.ceil(math.sqrt(a))
max_squre_num = math.floor(math.sqrt(b))
return max_squre_num - min_squre_num + 1
if __name__ == "__main__":
s = Solution()
... |
d8c7fc3ecd0742a8d3824dfcd59a9648a07ab38f | xixi0226/lcd | /line_ros_utility/nodes/tools/histogram_line_lengths.py | 3,537 | 4.1875 | 4 | """ Draws a histogram of the length of all the lines in the dataset.
"""
import matplotlib.pyplot as plt
import numpy as np
class LineLengthHistogram:
""" Creates a histograms of the lengths of all the lines in the dataset and
displays it.
Args:
num_frames (int): Number of frames expected in t... |
abe1fd00c1c2b8477d23877d31d5796844271f94 | kejndan/Battleship2.0 | /PycharmProjects/BattleShip2.0/select_window.py | 2,679 | 3.5 | 4 | from const import *
import pygame
from ship import Ship
class SelectWindow(object):
def __init__(self, screen, vector):
"""
Данный класс создает окно выбора кораблей
:param screen: экран
:param vector: 1 - горизонтальные корабли; -1 - вертикальные корабли;
"""
self.... |
54723e4be5d99e0d2539aeecac98cb773136c0b5 | thuchimney292/thutran-fundamental-lesson4-c4ep35 | /serious34.py | 554 | 3.8125 | 4 | question={
'If x=8, then what is the value of 4(x+3)?':[35,36,40,44,4],
'Jack scored these marks in 5 math tests : 49, 81, 72, 66 and 52. What is the mean?':['about 55','about 65','about 75','about 85',2]
}
correct=0
for key in question:
print(key)
for i in range(4):
print(str(i)+'. ',question[k... |
950a704a71a1fd5f7840b40ff003e36b5325cdb8 | arongsnuna/python_1-1 | /task/MP05/MP05.py | 1,928 | 3.75 | 4 | # 1. import random, turtle
# 2. win, turtle 생성 (거북이 2개 생성)
# 3. 거북이를 배치 (화면에 배치)
# 4. 카드 이미지 등록
# 5. random number 생성
# 6. 거북이로 카드 이미지로 보이도록 함
# 7. 숫자 비교
# 8. 누가 이겼는지 혹은 비겼는지 화면에 출력
# 1
import random
import turtle
# 2
win = turtle.Screen()
tLeft = turtle.Turtle()
tRight = turtle.Turtle()
# 3
tLeft.penup()
tLeft.goto... |
2a9cf10157ab2d54d38301b94a43c247ca1df2df | keithli411/DE4_SIOT | /coursework_1_collection/API/weatherRequest.py | 2,160 | 3.640625 | 4 | ## Script to just request selected datapoints from dark sky
# Powered by Dark Sky; https://darksky.net/dev
# Uses ForecastIO Python 3 Wrapper: https://github.com/bitpixdigital/forecastiopy3
import time
import requests
import json
from forecastiopy import *
from datetime import datetime
import csv
def main():
#for ... |
048b349ee3ca589c9979d7731c6e7f5874004c9a | wileys/wileys.github.io | /Classes/movie_class.py | 2,293 | 3.8125 | 4 | #wiley's fun lil movie geek code
import random
class Movie():
def __init__(self, name, number_of_stars, budget, box_office, famous_actors, length, genre, songs):
self.name = name
self.number_of_stars = number_of_stars
self.budget = budget
self.famous_actors = famous_actors
self.length = length
self.genr... |
3e89f097af853629c16a12a7f4187664a6812719 | lewis-od/Optimatic | /optimatic/utils/generate.py | 1,108 | 4.25 | 4 | """
Methods for generating data to fit using optimisation algorithms
"""
import numpy as np
def random_polynomial(degree, x, scale=5, noisy=True):
"""
Generates a polynomial of the given degree with random coefficients, then
adds some noise.
:param degree: The degree of the polynomial to generate
... |
8ada887ec85d40a9b44a1c82bb0a06e22d9ac3c8 | romaingrebul/TP02 | /TP04.py | 694 | 3.90625 | 4 | #x = 1
#while x <= 50 :
# print ("facile" + str (x))
#x+=1
#x = 1
#while x <=25 :
# print ("*",end="")
#x+=1
#for x in range (21, 146):
# print (x)
#x = 1
#for x in range (1, 41):
# print ("le carré de " + str(x) #+ "vaut" + str(x**2))
#x+1
#x =1
#total = 0
#for x in range (21, 145):
# total = x+(x+1)+... |
38feae48d020a151920a3370d32fc9ca3c7d1bbb | sasca37/PythonPrac | /chapter4/ex3.py | 649 | 3.6875 | 4 | #ord : 아스키코드 숫자변환, 입력값 좌표화
# 나이트 입력위치 받기
input_data = input()
row = int(input_data[1])
column = int(ord(input_data[0])) - int(ord('a')) + 1
print(row,",",column)
#나이트 이동 방향
steps = [(-2, -1), (-1, -2), (1, -2), (2, -1), (2, 1), (1, 2), (-1, 2), (-2,1)]
# 8가지 방향 이동 가능 여부 확인
result = 0
for step in steps:
# 이동 위치 ... |
f765c48e719efa008bc3dafd9d9a38f32e699adf | sasca37/PythonPrac | /dfsbfs/dfs.py | 726 | 3.703125 | 4 | #DFS 메서드 정의 : 스택으로 처리
#Depth First Search
def dfs(graph, v, visited):
# 현재 노드를 방문 처리
visited[v] = True
print(v, end=' ')
# 현재 노드와 연결된 다른 노드를 재귀적으로 방문
for i in graph[v]:
if visited[i] == False:
dfs(graph, i, visited)
# 각 노드가 연결된 정보를 리스트 자료형으로 표현 (2차원 리스트)
graph = [
[], #필요없어보임
[2, 3, 8],
[... |
225ad6a6d3ac05d654fdcf758302b67b0af95efc | sconn823/characterGenerator | /DiceParser.py | 325 | 3.546875 | 4 | import random
def diceRoller(numDice, diceType, modifier):
sum = 0
for i in range(1, numDice):
sum+= random.randrange(diceType)
return sum + modifier
#4d6 + 3
print("4d6 + 3")
print(diceRoller(4,6,3))
#2d8 + 1
print("2d8 + 1")
print(diceRoller(2,8,1))
#3d4 - 2
print("3d4 - 1")
print(diceRoller(3,4... |
2e39f1c70e94a82efe31be46177b126286ac4e6f | JohnAssebe/Python | /The Big Book Of Small Python Project/birthday_paradox.py | 1,772 | 3.734375 | 4 | import datetime
import random
#help(datetime)
def generate_random_birthdates(num):
'''Generate a random birthdays of specified numbers'''
birthday_lst=[]
for i in range(num):
start_date=datetime.date(2020,1,1)
time_delta=datetime.timedelta(random.randint(0,364))
birth_date=start_date... |
df9c19801ac4742d19bc68b65b1accd5590e6572 | JohnAssebe/Python | /SeriesOfMatplotlib/plot/american_womens_bachelor_degree_plot.py | 823 | 3.609375 | 4 | '''
@Author:Yohannes Assebe(John Assebe github)
'''
import pandas as pd
import random as ra
from matplotlib import pyplot as plt
plt.style.use('ggplot')
df=pd.read_csv('../percent_bachelors_degrees_women_usa.csv')
year=df['Year']
fields=[]
cols=df.columns.values
colors=['black','#521222','#155888','yellow','... |
ff6a28d87467b37c1350f26a4afd2571854e691e | JohnAssebe/Python | /SoloLearn_Project/Coursera/elevator.py | 679 | 4.0625 | 4 | class Elevator:
def __init__(self, bottom, top, current):
"""Initializes the Elevator instance."""
self.bottom=bottom
self.top=top
self.current=current
def up(self):
"""Makes the elevator go up one floor."""
if self.current<self.top:
self.current+=1
... |
a99b8d1db9ba22192c24add735bd5ac512d4ec76 | JohnAssebe/Python | /WorkOnDS/find_max.py | 236 | 3.546875 | 4 | def find_max(lst):
try:
max_num=lst[0]
for item in lst:
if item>max_num:
max_num=item
return max_num
except(Exception) as err:
return "Something wrong :",str(err)
print(find_max([i for i in range(10000011)])) |
cb4340ee5cb68a8c328e3aa1d15409fc55a1537a | JohnAssebe/Python | /WorkOnImage/add_logo/add_txt_on_multiple_img.py | 855 | 3.828125 | 4 | from PIL import Image,ImageFont,ImageDraw
import os
text=input("please enter text to write on the image: ")
for file in os.listdir('.'):
if file.lower().endswith('.jpg') or file.lower().endswith('.png'):
file_name=file
last_index=file_name.find('.')
file=Image.open(file)
img_... |
44dc3bd4ef0effd844488a49603a945bc6aebbdf | JohnAssebe/Python | /HackerRank/grading_student.py | 894 | 4.21875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'gradingStudents' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts INTEGER_ARRAY grades as parameter.
#
def generate_five_multiple(num):
while num%5!=0:
num+=1
return... |
93c213c8b91c9d58a084216bce31ebf1f2e0b464 | JohnAssebe/Python | /SoloLearn_Project/fib.py | 192 | 3.984375 | 4 | num = int(input())
def fibonacci(n):
if n<=1:
return n
else:
return fibonacci(n-1)+fibonacci(n-2)
if num<0:
print("Error")
else:
for i in range(num):
print(fibonacci(i))
|
67d9f495d104b10304536ebe2bca8ec248b66943 | JohnAssebe/Python | /WorkOnDS/prefix_average_O(n2).py | 187 | 3.578125 | 4 | def prefix_avg(s):
n=len(s)
A=[0]*n
for i in range(n):
total=0
for k in range(i+1):
total+=s[k]
A[i]=total/(k+1)
yield A
for k in prefix_avg([1,2,3,4,5]):
print(k) |
4b560130d52f28c3805135edcab82e8c7e3fb221 | rvkeerthana/myproject2 | /B4.py | 214 | 4 | 4 | a=int(input("enter the number:"))
b=int(input("enter the number:"))
c=int("input("enter the number:"))
if(a > b):
print("A is bigger",a)
elif(b > c):
print("b is bigger",b)
elif(c > a)
print("c is bigger",c)
|
e44ff08d9dce6ee31d8ee9ee9d92b581a5556a61 | lentomurri/python | /caesar.py | 871 | 3.953125 | 4 | #!/usr/bin/env python3
#Caesar cypher game. It can be upgraded entering a user input for the sentence as well.
user = "The die is cast"
result = []
while True:
try:
num = int(input("Please enter a number between 1 and 25: "))
if num < 1 or num > 25:
print("{Please enter a valid number... |
edb040c384f746e3170d1c5ba41d4b77793f30fb | lentomurri/python | /capitals.py | 1,920 | 4.28125 | 4 | #! python3
# The program will fish from a JSON file the data needed to create a questionnaire
# "Which one is the capital of this State"
import random, json
with open (r"C:\Users\Lento\personalBatches\capitals.json", "r") as capitals:
data = json.load(capitals)
capitals.close()
def createQuiz():
# create a r... |
39ee4342cec7000637145be3a7bb60611004a23a | lentomurri/python | /tic-tac-toe.py | 5,491 | 3.734375 | 4 | # PLAYER SELECTION SECTION
import random
player1 = ""
cpu = ""
startGame = False
while True:
options = ["X", "O"]
result = random.randint(0,1)
player1 = options[result]
if player1 == "X":
print("Welcome, Player 1! You'll be the " + player1)
cpu = "O"
elif player1 == "O":
p... |
92654884157156b838186cf09deb1b6d19710b38 | nitish800/python-practice | /IsPrime.py | 263 | 4.15625 | 4 | # check whether a given number is prime or not
def isprime(n):
i=2
j=0
if n in(0,1,2):
print('Oops! please enter a number greater than 2')
return
while (i*i)<n:
if n%i==0:
print('not prime')
j=1
break
else:
i+=1
if j==0:
print('prime')
|
3935a9710c89431c1c99b1673897c3e1227ab8a8 | dancps/EUII_DetectorDeGas | /tests/testClock/bcd.py | 250 | 3.671875 | 4 | def bcdDigits(chars):
for char in chars:
char = ord(char)
for val in (char >> 4, char & 0xF):
if val == 0xF:
return
yield val
print("Digite o valor inteiro")
while(end):
inputT=input(">>") |
d796a5eb04361d23229d56bb287e6b0ec4889df3 | rcurnow1/python | /TWITTER/AUTOTWEET.py | 824 | 3.546875 | 4 | import twitter, sqlite3, urllib2, time
while True:
pass
#call the history
console = sqlite3.connect("C:\\Users\\rcurnow1\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History")
cursor = console.cursor()
cursor.execute("SELECT urls.title FROM urls")
GrabData = cursor.fetchall()
HistoryList = []
for r... |
a7b941e681aa69ab694e5f45b94a36885aec6858 | mira0993/algorithms_and_linux_overview | /Python/Trees/interval_tree.py | 5,404 | 3.65625 | 4 |
class IntervalNode(object):
def __init__(self, low_value, high_value):
self.low = low_value
self.high = high_value
self.max = high_value
self.left = None
self.right = None
def height(self):
def _height(node):
if not node:
return 0
... |
3f3ce5fdddcd5aec73f28cdd11cb1983769d828a | mira0993/algorithms_and_linux_overview | /Python/InterviewPractice/find_all_palindromes.py | 1,429 | 4.03125 | 4 | '''
Write code to find all Palindromes in a given sample string.
Example: "pop this tacocat seems nice at noon"
"pop", "s tacocat s", " tacocat ", "tacocat", "acoca", "coc", "noon"
'''
def find_palindromes_brute_force(sentence):
pals = []
len_s = len(sentence)
comparisons = 0
for x in range(len_s-1):
... |
7dba1c4bea38b6770d164b854f524c54db8a5f33 | mira0993/algorithms_and_linux_overview | /Python/SortingAlgorithms/selection_sort.py | 853 | 4.40625 | 4 | #!/usr/bin/python
'''
SELECTION SORT
1. Find the smallest element in the array and then swap that element with the
one in the first position.
2. Find the second smallest element and swap it for the one in the second
position.
3. Repeat this for each element of the array.
'''
from array_generator import cre... |
0941d0bfcfbd791f2cf84c29585a7643d6355430 | mira0993/algorithms_and_linux_overview | /Python/Trees/BNode.py | 565 | 3.8125 | 4 |
class BNode():
'''
Basic node to use in a binary tree
'''
def __init__(self, value, parent=None):
self.value = value
self.parent = parent
self.left = None
self.right = None
def is_leaf(self):
if not self.left and not self.right:
return True
... |
a90938ba9e46f14d2cf9d64117e9a6c3ae49b7f9 | mira0993/algorithms_and_linux_overview | /Python/InterviewPractice/bulbs.py | 863 | 4.125 | 4 | '''
N light bulbs are connected by a wire. Each bulb has a switch associated with it,
however due to faulty wiring, a switch also changes the state of all the bulbs
to the right of current bulb. Given an initial state of all bulbs, find the
minimum number of switches you have to press to turn on all the bulbs.
You can ... |
f1ba1b0d69da1c8f20e79acd210ab71d3b8b8f5f | bradwinters/networkx | /p2.py | 580 | 3.65625 | 4 | import networkx as nx
import matplotlib.pyplot as plt
print("hi")
G= nx.Graph()
G.add_edge('A','B', weight=13, relation='freind')
G.add_edge('B','C', weight=9, relation='family')
G.add_edge('B','D', weight=7, relation='freind')
G.add_edge('E','B', weight=10, relation='freind')
G.add_edge('E','A', weight=1, relation='... |
e178815c762587e5a0a55e2f1c5a18d183866f94 | clarali65/Python-practice | /data structure and algorithm_exercise/ex1/ex1_3.py | 618 | 3.546875 | 4 | from pythonds.basic.stack import Stack
def calc(tokens):
s = Stack()
for i in tokens:
if i in "0123456789":
s.push(i)
else:
if i in "+-*/":
t2 = s.pop()
t1 = s.pop()
t3 = operation(t1, t2, i)
s.pus... |
b2db77b56b8796c8a6b4bb3e9b5209c4145bc99f | ArkaprabhaChakraborty/Datastructres-and-Algorithms | /Python/KruskalAlgorithm.py | 1,488 | 3.703125 | 4 | class Graph:
def __init__(self,v):
self.vertices = v
self.graph = [[100000000000 for i in range(v)] for i in range(v)]
self.parent = [i for i in range(v)]
def add_weighted_undirected_edge(self,u,v,w):
self.graph[u][v] = w
self.graph[v][u] = w
def find(self,a):
... |
d60fa0425f5544166077abff5b16140d7aa2200d | ArkaprabhaChakraborty/Datastructres-and-Algorithms | /Python/itertoolsproduct.py | 538 | 4.5 | 4 | '''
itertools.product()
This tool computes the cartesian product of input iterables.
It is equivalent to nested for-loops.
For example, product(A, B) returns the same as ((x,y) for x in A for y in B).
You are given two lists A and B. Your task is to compute their cartesian product X.
A = [1, 2]
B = [3, 4]
AxB = [(1,... |
5208350cebbbf78b2cc0c7e79d2ef39294c9438f | ArkaprabhaChakraborty/Datastructres-and-Algorithms | /Python/itertoolsCombinationWithRepeatations.py | 662 | 4.0625 | 4 | '''
itertools.combinations_with_replacement(iterable, r)
This tool returns r length subsequences of elements from the input iterable
allowing individual elements to be repeated more than once.
Combinations are emitted in lexicographic sorted order.
So, if the input iterable is sorted, the combination tuples will be p... |
92c99fc2f76eb09f131426c7e4f7730af7352875 | ArkaprabhaChakraborty/Datastructres-and-Algorithms | /Python/defectivechessboard.py | 1,202 | 3.90625 | 4 | """
The defective chess board problem.
given a N x N board where N is even, there is one defective square.
The challenge is to find out whether the space can be tiled using L shaped tiles.
The algorithm here substitutes the tile number in the matrix
"""
t = 0
def tile(arr,a,b,x,y,size):
global t
if (size == 1... |
60320b23688f38720e8897f7b31b24469971346d | ArkaprabhaChakraborty/Datastructres-and-Algorithms | /Python/a2.py | 3,041 | 4.21875 | 4 |
def get_length(dna):
''' (str) -> int
Return the length of the DNA sequence dna.
>>> get_length('ATCGAT')
6
>>> get_length('ATCG')
4
'''
return len(dna)
def is_longer(dna1, dna2):
''' (str, str) -> bool
Return True if and only if DNA sequence dna1 is longer than DNA sequenc... |
53943679a2d4368b4b25d4a19bda3592d54e5fd9 | ArkaprabhaChakraborty/Datastructres-and-Algorithms | /Python/multipleofthree.py | 1,477 | 3.921875 | 4 | '''
Consider a very long K-digit number N with digits d0, d1, ..., dK-1 (in decimal notation;
d0 is the most significant and dK-1 the least significant digit).
This number is so large that we can't give it to you on the input explicitly;
instead, you are only given its starting digits and a way to construct the rema... |
381265e4157a997e4f15345bca3ef0a0724d1390 | ZachMarcus/Experiments | /algorithms/wedding-planning/fuzzer.py | 595 | 3.703125 | 4 | #!/bin/python3
from random import randint
def generate_examples(num_cities, num_edges, root_city):
print('{} {} {}'.format(num_cities, num_edges, root_city))
for x in range(0, num_edges):
first_city = randint(1, num_cities)
second_city = randint(1, num_cities)
while second_city == fir... |
ba1c5caa9993ab4a3b1de9bc6f90f025d463d589 | Khaled-Abdelal/coursera-data-structures-and-algorithms | /course1_algorithmic_toolbox/week2_algorithmic_warmup/5_fibonacci_number_again/fibonacci_huge.py | 1,066 | 3.78125 | 4 | # Uses python3
import sys
def get_fibonacci_huge_naive(n, m):
if n <= 1:
return n
previous = 0
current = 1
for _ in range(n - 1):
previous, current = current, previous + current
return current % m
def get_fibonacci_huge_fast(n, m):
sequence = generate_sequence(m)
resul... |
2f09f83c11caa07e1e1643d0cd889054c961fb90 | NDM2021/M9LabAssignment | /CSS225M9P3NumList35.py | 357 | 3.984375 | 4 | num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 33, 34, 35]
counter = 0
while counter < len(num):
print(counter)
counter += 1
num.append(35)
# Norris Mayes
# 3/18/20
# This program uses the while loop to generate ... |
0521e633805ec70a85b004f8612bab6797f298a1 | abhisaxena5694/word-game | /word-game.py | 2,453 | 4.125 | 4 | import random
import string
def score(list_of_words):
count = 0
count = len(list_of_words) * 10
count += (len(list_of_words)//5) * 10
print "Your score is %s " % count
def start(letter):
print "So, your starting letter is '%s'.Let's start with the game." % letter.upper()
print "Enter the ... |
194ec17dc4782d8db8ac1bd6cb988904879d5cd0 | yved/python_lesson2 | /week1/week1-1.py | 707 | 3.828125 | 4 | # #商管程式設計二第一周上課內容 #five littile duck #function
#版本一
def over_mother():
print("Over the hills and far away")
print("Mother duck said quack quack quack")
def n_duck(num):
print("%s litte ducks went out day" % num)
def only_n(num):
print("But only %s little ducks came back" % num)
# n_duck("Five")
# over_mother()
#... |
090f78465826453378211588a7b9be4f86535b6d | ikollipara/BlackJack | /Shoe.py | 3,251 | 3.640625 | 4 | from Card import Card
from RulesError import RulesError
from random import *
class Shoe(list):
def __init__(self, filename, numberOfDecks=6):
super(Shoe, self).__init__()
if type(numberOfDecks) == type(2):
for placeholder in range(numberOfDecks):
with open(filename) as c... |
b658782635ad2df01dcd1effbe02e5f53017652d | Qazaqbala-N/project2 | /snake.py | 3,116 | 3.625 | 4 | import pygame
import random
pygame.init()
#Screen
screen_x,screen_y=800,600
screen = pygame.display.set_mode((screen_x,screen_y))
#Score_Surface
score = 0
Surface_score = pygame.Surface((100,40))
Shrift = pygame.font.Font(None, 38)
class Snake:
def __init__(self):
self.size =1
self.x = 100
se... |
560826b1242c7a3b86428fda9f689ccb12508cbf | Elijah3502/CSE110 | /Programming Building Blocks/Week 2/03Teach.py | 2,199 | 4.46875 | 4 | import math
#Team activity for unit 3
"""
Write a program to compute the areas of three different shapes. Prompt for the necessary information,
then compute and display the area, as follows:
Make sure that your program can appropriately handle decimal values as well as whole numbers.
Square—The area is the length ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.