blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
7b6238aa8e07d2567cbb78705b4306336f8c459e
RishabhGoswami/Algo.py
/inorder iterative.py
621
3.71875
4
class Node: def __init__(self,data): self.data=data self.left=None self.right=None def inorder(root): s=[] curr=root while(True): if(curr): s.append(curr) curr=curr.left elif(s): curr=s.pop() print(curr.data...
e059c4d57a131c2ad52e217ea634cac16a91560d
rafaelperazzo/programacao-web
/moodledata/vpl_data/405/usersdata/297/78258/submittedfiles/exe11.py
676
3.609375
4
# -*- coding: utf-8 -*- numero= int(input('digite um número inteiro que possua 8 algarismos: ')) a1=int(input('digite o número da dezena de milhão aqui: ')) a2=int(input('digite o número da unidade de milhão aqui: ')) a3=int(input('digite o número da centena de milhar aqui: ')) a4=int(input('digite o número da dezena d...
cf2a9662cd969d234866194f40eb70dcd298c78f
zmbslyr/holbertonschool-higher_level_programming
/0x0B-python-input_output/8-load_from_json_file.py
382
4.09375
4
#!/usr/bin/python3 """Module to load objects from JSON files""" import json def load_from_json_file(filename): """Function to return object from JSON file Args: filename: Path to the file to create object from Returns: Python object from JSON file """ with open(filename, "rt", ...
de9edc4f28330524a0a80b965149905354e4f26b
Nutpapat/Python_Lab
/psit/PSIT/Refrigerator/refi.py
966
3.75
4
"""Refrigerator""" def check_day(data_num, num): """print day of stock food longest""" day = 0 if len(data_num) != num: print("0") else: while 1 == 1: if min(data_num) == 0: print(day) break else: stock = min(data_nu...
dfa08d7023312afbc1c8c4d64e09f3e2b13dca27
lieuzhenghong/programming-practice
/ogp_interview/ogp_interview_q2.py
6,002
3.546875
4
from collections import Counter import random ''' 1713 started 1730 solved part 1 1750 solved part 2, concluded because of lack of time. ''' # [“orange”, “apple”], [1, 1] ''' { 0: 'orange', 1: 'apple' . . n } [orange, apple] [1,3] { 0: 'orange' 1: apple 2: apple 3: apple } { ...
2e5d82401d54853944d91230b0bea129e71f1813
simeon49/python-practices
/base/11_类/09_高级使用__getitem__.py
1,306
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ################################################### # __getitem__: 使得对象可以向列表一样访问 arr[1]=200 or arr[:] ################################################### class MyArray(object): def __init__(self): super(MyArray, self).__init__() self._arry = [] ...
c5cc51646f28b642f59aeb0dedd4392e6b6597a0
Morgan-Cofrin/FizzBuzz
/FizzBuzz.py
376
4.125
4
def print_range(lower_bound = 1, upper_bound = 101): numbers = range(lower_bound, upper_bound) for number in numbers: if ((number % 3) == 0) and ((number % 5) == 0): print("FizzBuzz") elif (number % 5) == 0: print("Buzz") elif (number % 3) == 0: print("Fizz") ...
e57eab07d546d4077812ea054731c14de9b2a123
miller9/another_python_exercises
/4Operadores_y_expresiones/23_c_exercise.py
884
4.375
4
""" 3) Realiza un programa que cumpla el siguiente algoritmo utilizando siempre que sea posible operadores en asignación: Guarda en una variable numero_magico el valor 12345679 (sin el 8) Lee por pantalla otro numero_usuario, especifica que sea entre 1 y 9 (asegúrate que es un número) Multiplica el numero_...
93eb8f56ac31ad55a8081fe674b894d8c976639d
landryb02/CSC446
/Challenge1/Final/Challenge 1/crack4(3).py
1,913
3.546875
4
import hashlib from binascii import hexlify import sqlite3 pepper = hashlib.sha256() pepper.update("I really love this stuff!".encode()) pepper = pepper.digest() def importdb(db): conn = sqlite3.connect(db) c = conn.cursor() return c.execute("SELECT * FROM users") def hexToBytes(hexdata): '''Conv...
72cf6b46586a46bf25bc630265a8d6854e29e556
ItamarRocha/DailyByte
/week_005/day32_sortedarraytobst.py
1,232
4.15625
4
""" Given an array of numbers sorted in ascending order, return a height-balanced binary search tree using every number from the array. Note: height-balanced meaning that the level of any node’s two subtrees should not differ by more than one. Ex: Given the following nums... nums = [1, 2, 3] return a reference to the...
83fdc2096cfd8c4ed1d49e5e91e0fa1da9951f99
llcawthorne/old-python-learning-play
/ProjectEuler/Problem020.py
246
3.828125
4
#!/usr/bin/env python3 """Project Euler Problem 020 n! means n × (n − 1) × ... × 3 × 2 × 1 Find the sum of the digits in the number 100! """ import math n=0 x = math.factorial(100) for digit in str(x): n+=int(digit) print("Sum",n)
b31e0e1746f9ca95805e391925d1fe7862c9e0cc
LachlanStevens/P2PU-ProgrammingTheory2
/Module_1/1.6_Abstraction/Example_Resources/animals.py
372
3.671875
4
from abc import ABCMeta, abstractmethod class Animal: __metaclass__ = ABCMeta name = "" location = "" def __init__(self, name, location): self.name = name self.location = location @abstractmethod def talk(): pass @abstractmethod def move(): pass ...
9dd0a53d93fad498789d4596fd97a6d7ca015f48
Vector22/projet_7
/app/localizze.py
2,531
3.515625
4
import json import requests from random import randrange class Geolocalize(): def __init__(self, address): self.address = address self.geoApiKey = "AIzaSyCObG729BmFhcBjVOiVlWW-Ea_DAfe1NSs" self.urlBase = "https://maps.googleapis.com/maps/api/geocode/json?" def geolocalize(self): ...
97761705bcfa9422204f49dec39f0f87288822e8
napo-lazo/pythonMilestoneProject1
/tictactoe.py
3,421
4.15625
4
import random #Prints the board with its current values def drawBoard(): patterns = {1: " | | ", 2: f" {cellValues[6]} | {cellValues[7]} | {cellValues[8]} ", 3: "-----------", 4: f" {cellValues[3]} | {cellValues[4]} | {cellValues[5]} ", 5: f" {cellValues[0]} | {cellValues[1]} | {cellValues[2]} "} b...
421154e0a913fe4b1906cfd12c4b242330f1a504
YasinEhsan/developer-drills
/fastSlowPointers/linkedListCycle.py
1,061
3.859375
4
# 9.23 def has_cycle(head): # TODO: Write your code here # has to be diff fast, slow = head, head while fast is not None and fast.next is not None: slow = slow.next fast = fast.next.next if slow == fast: return True # this wont work since fast is always 2 ahead of slow, fast should cath ...
ca10ddedcf09155189b93c2d317396c8d3852122
HarrisonConeboy/Python-Puzzle-Solver
/shape.py
3,063
3.859375
4
class Shape(): def __init__(self, mat): self.mat = mat self.volume = self.calc_vol() self.symmetry = self.calc_symmetry() self.perimeter = self.calc_perimeter() self.yLength = len(mat) self.xLength = len(mat[0]) # ROTATIONS and SYMMETRY of the shape ...
cd66a9be877b7ca8c98c63480783f659bef95e41
VitaliiStorozh/Python_marathon_git
/7_sprint/Tasks/s7.6.py
3,061
3.59375
4
class HackerLanguage: def __init__(self): self.message = "" def write(self, text): self.message += text def delete(self, N): self.message = self.message[:-N] def send(self): self.encrypted_text = '' for char in self.message: if char.isalpha(): ...
3ef77922f620dd4baec844ab1b9f918a01da985d
Nikhil-Dingane/Automate-The-Boring-Stuff-With-Python-Assignments
/CommaCode.py
291
3.84375
4
def listToString(tempList): ret='' for r in tempList: ret=ret+' '+r return ret userList=[] while True: print('Enter the list item(or enter nothing to exit)') item=input() if item=='': break userList.append(item) print(listToString(userList))
bf1264039f90b4d7efb092b047f531139cb47920
jlmoldan/pythonclass
/HW7/table.py
412
3.796875
4
print ("| * | 00 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 |") print ("--------------------------------------------------------") # # for row in range(10): # print("| ", "0".rstrip(),(row), " ", end="") for row in range(10): print ("| %02d"%(row),"",end="") for col in range(10): print ("| %02d...
a0f792aff4cec5582439e27ddad5ee7439db48e5
KayMutale/pythoncourse
/workspace/py3cours/getnumbers.py
451
3.8125
4
''' Created on 17 Aug 2017 @author: mark ''' def get_num(message, numtype=int): while(True): try: new_num = numtype(input(message)) except ValueError: print('Not an {}'.format(numtype)) else: return new_num def get_int(message): return get_num(messag...
1128a81213d75b0abb7d5b8b5a9add7722fbd5e2
Ferocius-Gosling/renjuu
/renjuu/game/vector.py
728
3.53125
4
class Vector(tuple): @property def x(self): return super().__getitem__(0) @property def y(self): return super().__getitem__(1) def __hash__(self): return super().__hash__() def __add__(self, other): return Vector([self.x + other.x, self.y + other.y]) def _...
9e8f375706372ad26d883f5b4f8cb7ae79499067
nkotelevskii/mcts_project
/mcts/mcts_algorithm/state.py
1,692
3.734375
4
class State: """ Class, which represents the state. State is the combination of pursuer and evader positions. """ def __init__(self, my_id, parent_id, e_state, p_state, action_applied_e=None, action_applied_p=None): """ my_id -- id of the node parent_id -- id of its parent ...
6971e42f967820baa4a4f9de03aad69981538418
jnheo1216/my_Python_BASIC_ex01
/16.py
737
3.78125
4
## 문제 16. ## n! 이라는 표기법은 n × (n − 1) × ... × 3 × 2 × 1을 뜻합니다. ## 예를 들자면 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800 이 되는데, ## 여기서 10!의 각 자리수를 더해 보면 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27 입니다. ## 100! 의 자리수를 모두 더하면 얼마입니까? def get_factorial(x): tmp = 1 for i in range(x, 1, -1): tmp = tmp * i return tmp def...
fff91b6d607a384c2f6be569250d70f2177dfb13
dan-mcm/python-practicals
/P16/p16p2.py
1,229
4.15625
4
# Psuedocode # #def findDivisors(num1,num2): //define function that takes 2 argumets # divisors = () //define divisors # for i in range (1, min(num1,num2)+1): # if num1 % i == 0 and num2 % i == 0: //for loop will check divisors of both numbers and add them to divisors. # divisors += (i,)...
b4e879d12c1855c3b121795109693dc2ecd96820
joescottengineering/Euler-Problems
/Euler probs - 47 Distinct prime factors B.py
1,643
3.578125
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 15 21:27:54 2015 @author: JKandFletch """ import math from collections import Counter import time start = time.time() def memoize(f): cache = {} def decorated_function(*args): if args in cache: return cache[args] ...
b43e749a7ce31852b69e485dad045ead915e9b8d
nightowl97/goodle
/GoodleStaircases.py
1,121
3.78125
4
import time def answer(n): """ Commander XXXXXX may not be made of money, but we still don't want to solve this in exponential time. So, after a few DP lectures, we'll be using recursion + memorization. Once a recursive function call is made, any identical subsequent calls would n...
7ca2759b4264f1383e42b877ca7c82ab9e1886ec
parkhojeong/pythonBook
/Ch4/proj4_2.py
581
4.09375
4
def main(): N = getInput() max,min = getPrime(N) print("Largest prime factor:",max) print("Smallest prime factor:",min) def getPrime(N): F = 2 pSet = set() while N >1: if N % F == 0 : pSet.add(F) N = N/F else: F +=1 return max(pSet),mi...
21410a8d9bacbdb7debfefb0442c9c89f50a96ba
techisantosh3000/pythonconcepts
/list.py
547
3.828125
4
""" This file contains list data structure assignements. 14/01/2021 """ # global variables. myUniqueList = [] myLeftovers = [] # add things to that list. def addThingsToList(input) : if input in myUniqueList : myLeftovers.append(input) return False else : myUniqueList.append(input) ...
d2992c9e259a87a6f53db7edabfc5e8338fba48f
priyanka1815/euler_project
/Q10optimised.py
692
3.6875
4
#Find the sum of all the primes below two million. # using SIEVE ALGORITHM import math sieve_prime_array = [1] * 2000000 # creating an array initialized with 1 of range 2 million def mark_composite(sieve_prime_array,num): #marking the composite no in array as 0 start = num*2 end = len(sieve_prime_array) ...
6d7b4897fa66079558e72eb08eab42a2ceced073
benczech212/Py_Bingo
/src/old/py_bingo.py
2,427
3.53125
4
import pygame as pg import math import random col_num_min = 1 col_num_max = 15 col_num_range = col_num_max - col_num_min + 1 row_count = 5 col_count = 5 #daubing = class Ball: letters = ["B","I","N","G","O"] def __init__(self): min_val = col_num_min max_val = col_num_range * row_coun...
73b581f8292e2c60b80c981f25f068fa69e00689
clovery410/mycode
/algorithm_exercise/serialization_BT.py
3,925
3.84375
4
class TreeNode(object): def __init__(self, val): self.val = val self.left = None self.right = None #solution1, use pre-order traversal pattern to serialize the binary tree class Serialization(object): # use pre-order traversal to serialize binary tree, need to append '#' to each leaf no...
8ae0cd8a1a1982a389fda2bbc2e8f35e3833c235
rghv16/learnpython
/python_competitive_program/HE_basic_stack_balanced_brackets.py
915
4.0625
4
class Stack: ''' https://www.hackerearth.com/practice/data-structures/stacks/basics-of-stacks/practice-problems/algorithm/balanced-brackets-3-4fc590c6/ ''' def __init__(self): ''' ''' self.l = [] def top(self): ''' ''' return self.l[-1] ...
dba524cade4f83c0a4d33c477f2d6f28c20a9178
datAnir/GeekForGeeks-Problems
/Array/count_distinct_pairs_with_diff_k.py
982
3.984375
4
''' https://practice.geeksforgeeks.org/problems/count-distinct-pairs-with-difference-k/0 Given an integer array and a non-negative integer k, count all distinct pairs with difference equal to k, i.e., A[ i ] - A[ j ] = k. Input: 3 5 1 5 4 1 2 0 3 1 1 1 0 3 1 5 3 2 Output: 1 1 2 ''' # save array in freq map # traver...
1a8ed6ef437e7536714ce639554d9bebc13b8373
HarveyLowndesQA/Unsorted-Python-Stuff
/q.py
372
3.65625
4
class Class1(Exception): pass class Class2(Class1): pass class Class3(Class1): pass y = 2 for x in (Class3, Class2, Class1): try: x = 1/y y = y - 1 raise x except(ZeroDivisionError): print("Massive") break except(Exception): p...
ff398951a695e08046a3080b55d6758da81a3f7a
tatparya/HackerRank
/Algorithms - Strings/Anagrams/solution.py
881
3.8125
4
import os import sys import string def getResult(): string = input() # check if str len is odd length = len( string ) if length % 2 != 0: print( "-1" ) return # Get number of replacements str1 = string[:int( length / 2)] str2 = string[int(length / 2):] characters =...
065583d1f1ac261301faf4cf00c6d6aeb707aca2
Ivaylo-Atanasov93/The-Learning-Process
/Python Advanced/Tuples_and_Sets-LAB/Average Student Grades.py
739
3.875
4
from collections import defaultdict num_of_students = int(input()) students = defaultdict(list) for _ in range(num_of_students): student = input().split() students[student[0]].append(float(student[1])) for (key, value) in students.items(): avg_grades = sum(value) / len(value) grade_string = ' '.join(...
5c66bb6b90e5bbc08c04390d7017f941b5322f95
GeorgeTheTypist/LearnPythonPR
/Strings.py
2,797
4.34375
4
__author__ = 'Pneumatic' paragraph = """This is a long string made up of several lines the triple quotes allow for things like newlines to be printed without the need for the escape character and tabs as well""" var1 = 'Hello Python World!' var2 = "Python Programming" string1 = "hi" sub = "i" intab = "abcde" # create ...
be794033a20fee8cf1c42d8bb2555958ccd61699
KETULPADARIYA/Computing-in-Python
/5.1 Fundamentals and Procedural Programming/Chapeter 1/3 ConvertingToStrings.py
913
3.796875
4
#In the code below, four variables are created: #an integer, a float, a date, and a boolean. # #Create four new variables: integer_as_string, #float_as_string, date_as_string, and #boolean_as_string. # #Convert the corresponding variables to strings. #So, boolean_as_string should have the string #version of the current...
dad02800e2723cc1ef2ffdcef944ac63361c0514
nicolas-git-hub/python-sololearn
/6_Functional_Programming/recursion.py
1,782
4.5625
5
# Recursion is a very important concept in functional programming. # The funcdamental part of recursion is self-reference - function calling themselves. # It is used to solve problems that can be broken up into easier sub-problems of the same type. # # A classic example of a function that is implemented recursively is ...
fa5cc57fdbf244ca7c9b949db9fdadcc51b0808f
dblprog/frequency-analysis
/vigenerefreqgen.py
1,040
3.796875
4
#!/usr/bin/env python3.3 # vigenerefreq2 -- compute word frequencies from standard input and KEYWORD LENGTH import sys import re import operator from string import ascii_lowercase keylength = 7 # CHANGE FOR OTHER KEYLENGTHS BASED ON GCD WITHIN REPETITIONS c = [] # process input for line in sys.stdin: line = line....
3d776bc9bc0259448dbc46fef69b3cae43aef4e8
suyundukov/LIFAP1
/TP/TP1/Code/Python/5J-1.py
259
3.75
4
#!/usr/bin/python # Afficher un motif donné for i in range(9): if i < 5: for j in range(i + 1): print('*', end='') else: for j in range(9 - i): print('*', end='') print() # Ici on affiche un saut de ligne
acd8859364638288d41161cfbf75bf472954cc0a
huotong1212/mylearnpy
/code/day08/描述符的应用/函数与数据描述符的优先级测试.py
1,312
4.15625
4
#描述符Str class Str: def __get__(self, instance, owner): print('Str调用') def __set__(self, instance, value): print('Str设置...') def __delete__(self, instance): print('Str删除...') class People(object): name=Str() def __init__(self,name,age): #name被Str类代理,age被Int类代理, ...
f9dcd85dd47ce5b5210e8237238bf8c0c952303b
hamidmujtaba/py2store
/py2store/util.py
6,682
3.921875
4
import os import shutil def fill_with_dflts(d, dflt_dict=None): """ Fed up with multiline handling of dict arguments? Fed up of repeating the if d is None: d = {} lines ad nauseam (because defaults can't be dicts as a default because dicts are mutable blah blah, and the python kings don't seem to thin...
7674c629c50887bfb5968ed315938f6eac09623b
Ken0706/Crash_Course_Book_Python
/5.11_Ordinal_Numbers.py
263
3.78125
4
def number_list(): numbers = list(range(1,10)) for i in numbers: if i == 1: print("1st") continue elif i == 2: print("2nd") elif i == 3: print("3rd") else: print(f"{i}th") def main(): number_list() if __name__ == '__main__': main()
9ccd16ebdf71cb450fe476ef6ff520dbb223be72
shoxtrem/Web-1-Final-Project-Part-2-Python-Server
/cgi-bin/input_db.py
1,331
3.703125
4
#!/usr/bin/python3 # This script creates a database if one doesn't exist yet # uses user input to populate said database # importing the module import cgi import sqlite3 # Connect or create the database connection = sqlite3.connect("directoryDatabase.db") # cursor crsr = connection.cursor() # SQL command to create ...
3af7bdcc7030ef740f4c52d981674fbaa8b79e54
23b00t/lotto-game
/lotto.py
1,080
3.765625
4
import random def lotto(): print('6 aus 49') tip = [] i = 0 while i < 6: usrin = input('Zahl zwischen 1 und 49 eingeben: ') try: usrin = int(usrin) except ValueError: print("Ungültige Eingabe") while (usrin not in range(1, 50)) or (usrin in tip): print('Zahl nicht im gültigen Bereich oder doppelte ...
44edb880754618426d017a8c0314bb8dcfa6d7ef
jnwanya/python-basic-lesson
/class_object.py
891
3.578125
4
class LotteryPlayer: def __init__(self, name): self.name = name self.number = (1, 34, 56, 90) def __str__(self): return f"Person {self.name} year old" def __repr__(self): return f"<LotteryPlayer({self.name})>" def total(self): return sum(self.number) player...
b2b4df3141415d2466a62ab91d49078e2bafcaa8
dougfunny1983/Hello_Word_Python3
/ex012.py
272
3.921875
4
print('''######################## ##Calculando Descontos## ########################''') print('☻♥☺'*15) valor = int(input('Digite o valor do produto: R$')) desconto = valor-valor*5/100 print(f'O valor do produto com desconto é R${desconto:.2f}') print('→←'*30)
ca52882a17bd0c9c5d96f8cef01bb267af012f1f
Xiaoyu861971996/scb16
/lesson2.py
7,797
4.3125
4
# 增加单个元素 # list1=[1,2,3] # list1.append(4) # print(list1) # 指定位置添加 # list1=[1,2,3] # list1.insert(3,4) # print(list1) # 列表一次性添加多个元素 # list1 = [1,2,3,4] # list1.extend([5,6,7,8,9,10]) # print(list1) #取值 # list1 = [1,2,3,4,5,6,7,8,9,10] # print(list1[0:4]) # 修改 # list1 = [1,2,3,4,5,6,7,8,9,10] # list1[-1]=11 # print(...
62a94176f1fee5662828053becbb4e086723e7ea
icedevil2001/taxadb
/taxadb/util.py
843
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import hashlib import sys def md5_check(file, block_size=256*128): """Check the md5 of large files Args: file (:obj:`str`): input file block_size (:obj:`int`): block_size for the file chunks. Default = 256*128 """ print('Check...
4f2502923f95636c3a8f69b5b67e47a6e3d132f0
mateusascacibas/Repeticao-Python
/Exe23.py
149
4.15625
4
num = int(input("Digite um numero: ")) x = 1; while(x < num): if(num % x == 0): print(x) x += x else: x += x
a7af77403909c973c0dd8f813f864dad08882595
sagarkamthane/selenium-python
/seleniumproject/practice/oop.py
2,160
4.0625
4
class emp: company = 'google' def __init__(self, name, profile, salary, increment, address = "NA"): self.name = name self.profile = profile self.salary = salary self.increment = increment self.address = address def details(self): return f'{self.name} is {se...
8a78b5b8daf3ea8248d5254cc04d12dbce792487
Hououin47/intro_python
/week_6/calutils.py
3,557
4.34375
4
''' Global variables to get array index of day and length ot month ''' days = { 1:'Monday', 2:'Tuesday', 3:'Wednesday', 4:'Thursday', 5:'Friday', 6:'Saturday', 0:'Sunday' } months = { 1:['January',31], 2:['February',28, 29], 3:['March',31], 4:['April',30], 5:['May',31], 6:['June',30], 7:['July',31], 8:...
102ebc9b8ab3c1d6ea6aea717bb5293019f345f5
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4175/codes/1807_2573.py
555
3.53125
4
from numpy import * x = array(eval(input())) y = array(eval(input())) a = zeros(size(x)) for i in range(size(x)): a[i] = round(x[i]/(y[i]*y[i]),2) c = "" n = max(a) for i in range(size(a)): if n < 17: c = "muito abaixo do peso" if 17 <= n <= 18.49: c = "abaixo do peso" if 18.5 <= n <= 24.99: c= "peso n...
9f4b28af767832ebd9198d3f8a861ecb2c0e3406
pyaephyokyaw15/PythonFreeCourse
/chapter10/abstract.py
377
3.765625
4
from abc import * class Human(ABC): @abstractmethod def __init__(self): pass @abstractmethod def work(self): pass class Doctor(Human): def __init__(self): print("Doctor constructor") def work(self): print("Doctor work") class Teacher(Human): def __init__(...
b3ea964c8fd938408cb048c601779dce21f18b7b
UweZiegenhagen/Skriptsprachen_WS1920
/VL_06/Blatt_Wdhl_5VL_Aufgabe1.py
313
3.6875
4
# -*- coding: utf-8 -*- """ Wenn man die Aufgabe 1 so interpretiert, dass die Frage lautet "Wie oft ist der Buchstabe 'z' in einem String s enthalten?" da könnte die Lösung so aussehen: """ def anzahl_der_zs(s): return len(s) - len(s.replace('z','')) print(anzahl_der_zs('Szdf zegfzdf'))
3a999cdee32207cd81cc0ff894f1d164aaf83d60
BjoernWewer/raspi
/buttons.py
382
3.5625
4
from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) button1=37 button2=38 GPIO.setup(button1,GPIO.IN,pull_up_down=GPIO.PUD_UP) GPIO.setup(button2,GPIO.IN,pull_up_down=GPIO.PUD_UP) for q in range(0,5): if GPIO.input(button1)==0: print("button 1 was pressed") sleep(.5) if GPIO.input(button2)==0...
bd7061f386d04bd46bd9fd3380d1906b32ad00ce
Jas-Gripen/Dans_Banking_System
/Withdraw_window.py
3,425
3.796875
4
# Class: Withdraw_window # Description: Pop-up window for withdrawing assets # Author: Daniel Gripenstedt from tkinter import Toplevel, StringVar, Label, Button, Entry from bank_system import Bank_system from Assets_window import Assets_window class Withdraw_window: # Build the withdra window with all of the l...
53aa59cf9043c432e6c36976b1de5b671b444166
hotate29/kyopro_lib
/python/lib/prime_factorize.py
599
3.703125
4
# 素因数分解 # pf from typing import List, Tuple def prime_factorize(n: int) -> List[Tuple[int, int]]: r = [] for p in range(2, n): if p * p > n: break e = 0 if n % p == 0: while(n % p == 0): n //= p e += 1 r.append((p, e))...
1aa7047bec35535315671153347300e7cbf18b1c
AllenCellModeling/napari
/examples/add_vectors_image.py
1,144
3.609375
4
""" This example generates an image of vectors Vector data is an array of shape (N, M, 2) Each vector position is defined by an (x-proj, y-proj) element where x-proj and y-proj are the vector projections at each center where each vector is centered on a pixel of the NxM grid """ from napari import ViewerApp fr...
a4a90a39210ceb025b117b8260e30dcba603e5c4
HOWISYUNI/LECTURE_asPython
/my solution/BinarySearch.py
2,379
3.734375
4
# binary search는 항상 정렬돼있음을 가정한다. my_list = [1, 2, 3, 7, 9, 11, 33] lookfor = 34 """ 일반적인 binary search 1. 값을 찾았다 -> 찾은 위치 리턴 1.1 [중간]에 찾았다 1.2 [first와 last가 1칸 차이]에서 찾았다. 2. 찾지 못했다 -> -1을 리턴 """ def bi_search_usual(mylist, target, lo=0, hi=None): # init if hi is None: ...
e5005760465d954f7df030af14d3f40dc4d46125
DawnEve/learngit
/Python3/pythonCodeGit/day4-Fn-adv/generator2.py
835
4.28125
4
print('生成器generator2'); def fib(max): n, a, b = 0, 0, 1 while n < max: print(b) a, b = b, a + b n = n + 1 return 'done' fib(6) #上面的函数和generator仅一步之遥。要把fib函数变成generator,只需要把print(b)改为yield b就可以了 print("\n",'yield b:'); def fib(max): n, a, b = 0, 0, 1 while n < max: ...
9294e3d52f0fca3255a835b749941165ea9ef99f
1rv1nn/Python
/src/TablaDeMultiplicar.py
449
4.0625
4
print("Vamos haremos una tabla de multiplicar con números positivos(-1 para salir)") número=int(input("Dame un número positivo: ")) while número!=-1: #Evalua la condición,sí es verdadera se sigue ejecutando hasta que deje de cumplirse for i in range(1,11): resultado=i*número print(("%s x %s =%s...
0c8946ca0ab2b3c82a76d39f774985fad70fc692
Wellsjian/20180826
/xiaojian/xiaojian/first_phase/teacher/day05/exercise05.py
208
3.71875
4
# 练习:将list01中所有元素的个位存入list02中. list01 = [56, 36, 68, 44, 868] list02 = [] for item in list01: list02.append(item % 10) list02 = [item % 10 for item in list01] print(list02)
d97ddc544fc56f37fc0b9ce88cbc9db517b7a257
justinm-nyc/stream_parse_json
/stream_parse_json.py
4,600
3.921875
4
import ijson def initialize_parser(file): ''' Given a file object, this returns an ijson parser (which is a python iterator) ''' file.seek(0) return ijson.basic_parse(f) def print_all_events(parser): ''' An example of how to iterate through events using the parser. The events consist of...
0e9a6b57c9e39431d43d8bb3e14ff761ec7ce958
tomas0011/proyecto_lucapricho
/ventana.py
2,361
3.765625
4
def calculadora(): import tkinter as tk #------------declarar funciones------------ #suma def suma(): suma=int(entrada1.get())+int(entrada2.get()) return var.set(suma) #resta def resta(): resta=int(entrada1.get())-int(entrada2.get()) return var.set(resta) ...
99901e7df424d3a322a1253bbcf1b429851b4641
andreeafarago/plptest
/ex5.py
918
3.78125
4
import sys #from string import digits words_list = [] word_dictionary = {} def get_dictionary(word_list): for word in word_list: if word in word_dictionary: word_dictionary[word]=word_dictionary[word]+1 else: word_dictionary[word] = 1 return word_dictionary def get_max(pairs): (max_key, ma...
4565036a9003c76882a73fdff05fe22d53759261
ajtrebe/projects
/main.py
1,437
3.953125
4
while True: print("Type the first value you wish to add") while True: try: number1 = int(input("First: ")) break except ValueError: print("\nThis is not a number. Try again...") print() while True: try: number...
e964310e3d2612bbf63d63a60b616117b41c7b55
chaitanyaubijawe/python
/batch_4/session_1/1_data_types.py
2,814
4.40625
4
# print("Hello !") # Dynamically datatyped language... # Datatype.... print("Hello") # Number # 1- int. # 2- float. var_1 = 1 print(var_1) print(type(var_1)) var_1 = 1.1 print(var_1) print(type(var_1)) var_2 = 1 var_3 = 2 # arithmatic operations... add = var_2 + var_3 add = var_2 + var_3 add ...
3efc935031555f1931e5a691e640191f634bd5c0
fishleongxhh/LeetCode
/Heap/MinHeap.py
2,902
3.984375
4
# -*- coding: utf-8 -*- # Author: Xu Hanhui # 此程序主要实现最小堆的数据结构和基本操作 class MinHeap: def __init__(self): self.size = 0 self.data = [float('-inf')] #最小堆数组的第一个位置一般放一个标志元素,这个元素比所有可能的元素都要小 def isEmpty(self): return self.size == 0 def findMin(self): if self.size == 0: ...
f55dfaf58d24c5bef9741123ff2f9f4b8b6e8c29
joeygaitan/cs-markov-chain-algorithm
/dictogram.py
1,763
3.796875
4
import random class Dictogram(dict): def __init__(self, word_list=None): self.types = 0 # Count of distinct word types in this histogram self.tokens = 0 # Total count of all word tokens in this histogram # Count words in given list, if any super().__init__() if ...
6392fbfb3918b3d9852c0030f317460d98715bc2
profpetersburg/python-crash-course
/python_work/ch5_exercises.py
1,142
4.28125
4
## 5.1 Conditional Tests car = 'ford' print("Is car == 'ford'. I predict True.") print(car == 'ford') print("\nIs car == 'audi'. I predict False") print(car == 'audi') ## 5.2 More Conditional Tests my_car = 'dodge' fav_car = input(print("What's your favorite car brand?")) if fav_car.lower() == my_car: pr...
1864e238dec8139d1007db91d133db6a07d19d11
kejriwalrahul/Regex-generator
/DFA/DFA.py
10,121
3.890625
4
from graph import graph from random import shuffle """ Basic DFA implementation: 1. Can build a basic DFA from strings 2. Allows building DFA manually 3. Allows OR & AND using subset construction 4. Can plot current DFA 5. Can do state optimization 6. Can generate regex from DFA 7. Allows toString of DFA for human ...
22fbb45ecb4c7685812dc5091a075e3daef21cca
MrColour/LeetCode
/leets/leetcode/1669.py3
611
3.921875
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode: la = list1 for i in range(a - 1): ...
5381dd032507347db64bb2b9f754d30587b48ead
digitalix-ai/CustomRange
/CustomRange.py
425
3.6875
4
class MyGen: current = 0 def __init__(self, first, last): self.first = first self.last = last MyGen.current = self.first - 1 def __iter__(self): while True: if MyGen.current < self.last - 1: MyGen.current += 1 yield MyGen.current ...
94b4dc4def11b0c9043d3de02cdea6c941849497
MohaimenH/python3-tutorial
/Problem Solving Practice/maxOfArray.py
171
3.5625
4
numbers = input() numbers = numbers.split() for x in range(len(numbers)): numbers[x] = int(numbers[x]) numbers.sort() print(str(numbers[299]) + " " + str(numbers[0]))
f315ceaf67b73fb67301bf0aa9d17d614d1c61d0
RussellSnelgrove/SENG_265-UVIC-Fall-2016
/assign3/other.py
3,107
3.53125
4
import re import inputfile class Formatter: "A class for formatting input strings" def __init__(self, inputlines,none): self.coms = {'LW' = 0,'LM' = 0, 'FT' = False} self.LS self.newcheck = {'lineone' = False,'needsecond' = False} self.display = [] self.temp = "" self.input = inputfile.input() s...
60646cabfe2ed7313530e15d02645921ba8fd935
sAnjali12/More_exercises
/more_exercises11.py
431
3.578125
4
sentence = "NavGurukul is an alternative to higher education reducing the barriers of current formal education system" count = 0 new_list = [] while count<len(sentence): new_index = count str_count = " " while new_index<len(sentence): if sentence[new_index] == " ": break else: str_count = str_count...
f08ae36060662ab1c332d701b537ee2d5f941483
DonXanderForDZ/Lesson1DZ
/venv/dztask5.py
509
3.9375
4
a = int(input("Введите сумму выручки ")) b = int(input("Введите сумму издержек ")) if a < b: print("У вас убытки") else: print("У вас прибыль") c = (a - b) / a print(f"Рентабельность выручки {c}") d = int(input("Введите численность сотрудников фирмы ")) e = (a - b) / d print(f"Прибыль фирмы ...
05a4638d18d0da05c4a885de768ad81586922474
imtiyaazthompson/Source-Code-Tutorials
/Python-Crash-Course/5lb2kg.py
133
3.9375
4
weight_lbs = float(input("What is your weight in pounds: ")) weight_kgs = weight_lbs/2.205 print("Weight in kgs: ") print(weight_kgs)
0ac68e7965703ccff2a4fbbecdfb1efe65bbffd1
pmaslankowski/rushing-turtles-backend
/rushing_turtles/model/player.py
844
3.65625
4
from typing import List from rushing_turtles.model.person import Person from rushing_turtles.model.turtle import Turtle from rushing_turtles.model.card import Card class Player(object): person: Person turtle: Turtle cards: List[Card] def __init__(self, person: Person, turtle: Turtle, cards: List[Car...
7dd3d4dd7624112bbf8239df25cbc11614203637
pradeesi/IoT_Framework
/database_setup.py
385
3.53125
4
userInput = raw_input('WARNING: This script will re-initialize the Sqlite Database and DELETE all the Data. Do you want to continuw? [Y/n]') if len(userInput) == 1 and userInput == 'Y': print 'Script will now delete all the Data and re-initialize Database' import db.initialize_DB_Tables else: print 'Script ...
c2fdb96a2ff8ef015a8a65fcd7b0e33e85e7758c
zjuzpz/Algorithms
/PaintHouseII.py
1,544
3.84375
4
""" 265. Paint House II There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. The cost of painting each house with a certain color is repr...
2d874fea2084fab0a0d3c38c0999c6797195bbd1
vatsaashwin/Binary-Search-1
/search_arr_unknownSize.py
933
3.84375
4
# // Time Complexity : O(log(n)) # // Space Complexity : O(1) # // Did this code successfully run on Leetcode : Yes # // Any problem you faced while coding this : No class Solution: def search(self, reader, target): """ :type reader: ArrayReader :type target: int :rtype: int ...
ddd6cf5908a00e1b36093cc3251be46345db8b5c
AshishBhoj/Palindromify_list
/Palindromify_list.py
817
3.8125
4
def function(n): if n < 10: return n while True: if str(n) == str(n)[::-1]: return n break else: n += 1 if __name__ == '__main__': restart = ('y') while restart == 'y': print("Palindromifiaction Method") n = int(i...
e65b52f1e25b31e2dba270f8fe067816cc0e10c0
deepak261/python-exe
/hello_world_with_fun.py
712
4.28125
4
''' S01AQ01 Re-write the earlier question of S01Q01 using functions as mentioned below : You can use following code template to create your solution : https://git.io/vgrjP [ Click on "RAW" button if you find it difficult to download the code ] - Modify the first “Hello World” program to promp...
ec0e2ccafc24e6e533017d3dc95490ef56923325
kunalsonawane3/bluepineapple_training
/Algorithms_Practice/recursive_algorithms/recursive_powers.py
388
4.0625
4
def is_even(n): return n % 2 == 0 def is_odd(n): return n % 2 == 1 def power(x, n): if n == 0: return 1 # if n is positve if n == 1: return x elif n > 1: return x*power(x,n-1) # if n is negative if n == -1: return 1/x elif n < -1: return power(x,n+1)/x print(power(3,0)) print...
4c12c841320d4c1b9e9f537420e5d3564b625569
AntonioCenteno/Miscelanea_002_Python
/Ejercicios progra.usm.cl/Parte 1/2- Estructuras condicionales/set-de-tennis.py
651
3.75
4
#Primero, debemos pedir los datos juegos_a = int(raw_input("Juegos ganados por A: ")) juegos_b = int(raw_input("Juegos ganados por B: ")) #Luego, evaluamos el estado del juego if (juegos_a >= 0 or juegos_b >= 0) and (juegos_a <= 7 and juegos_b <= 7): if juegos_a == 7 or juegos_b == 7: if abs(juegos_a - juegos_b) <=...
ec71e4cb6ace723238ed23c15362388d98337fff
vvij2016/gcpchallenge
/highest-profit/highest-profit.py
832
3.859375
4
# coding: utf-8 # In[2]: import pandas as pd import numpy as np # In[8]: # Load data from csv file into a pandas data frame df = pd.read_csv("data.csv") df.columns = ["year", "rank", "company", "revenue", "profit"] print("Total number of records: {}".format(df.shape[0])) # In[9]: # convert profit columns to...
42e1f4d5921a813e9b082bc4f2765e8be30c223b
nayunhwan/ACM-ICPC-training
/2742.py
71
3.8125
4
#coding:utf-8 num = int(input()) while(num > 0): print(num) num -= 1
ca0a2cc4b4f89574046b60cff3cdcf4fc72e463a
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/pstcla002/question2.py
511
4.09375
4
"""Program to count pairs Claudia Pastellides 8 May 2014""" def pairfinder(string, tracker): length = len(string) if length > 1: if string[0] == string[1]: tracker += 1 #adds to current pair count pairfinder(string[2:],tracker) else: pairfinder(st...
abc234e6e58580450b671bf092704f32c0bd3077
manu-s-s/Challenges
/non_co_prime.py
418
3.59375
4
import itertools from functools import reduce from math import gcd def non_coprime_subarrays (a, n): # Your Code Goes Here count=0 for L in range(1,n+1): for subset in itertools.combinations(a,L): if reduce(gcd,subset)>1: count+=1 return count n = ...
f4b6e8d15be0b82bca88fbe58334293b6fdd1e91
TheKingOfTheDragon/builder_of_rectangular_shapes
/builder_of_rectangular_shapes_v1.0.py
6,087
3.703125
4
from tkinter import * import os os.system("mode con cols=105 lines=30") """ ФУНКЦИЯ РЕАЛИЗУЮЩАЯ АЛГОРИТМ ЕВКЛИДА ДЛЯ НАХОЖДЕНИЯ ОБЩЕГО КРАТНОГО """ def NOK(a,b): m = a*b while (a != 0) and (b != 0): if (a > b): a = a % b else: b = b % a return m // (a+...
2bff8667db8341a0fdcaff58de019fb0837ff46b
zhaoace/leetcode_solutions
/p5-longest-palindromic-substring.2.py
1,784
3.6875
4
# https://leetcode.com/zhaoace/ # https://leetcode.com/problems/longest-palindromic-substring/ #encoding = 'utf-8' class Solution(object): def longestPalindrome(self, s): """ :type s: str :rtype: str """ print "s == ", s if s=="": return "" lo...
26cdf91007dfbc915517f2bf36bc8f4e62c8d477
barbararaquelperez/Python
/Ej 1.py
866
4.125
4
#en este programa multiplicaremos los numeros que el usuario introduzca def multiplicacion(): a=input ("Introduzca un numero: ") b=input ("Intoduzca otro numero: ") c=input ("Introduzca otro numero: ") d=input ("Introduzca otro numero: ") i=a*b*c*d if(a==0): ...
5bc692185f5fbf39e76d3e6ee150a7a85c506b60
simonaculda/LeetCode
/Array_and_Strings/longestPrefix.py
640
4
4
""" Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". """ def longestCommonPrefix( strs): """ :param strs: List[str] :return: str """ if len(strs) == 0: return "" else: it = 0 for ...
dd6b4ccab13ddc16d53d30f8560c2d41c6b22d4d
VadimSechin/Python
/14-09/4.py
145
3.5625
4
import turtle import time turtle.shape('turtle') turtle.speed(10) for i in range(36): turtle.forward(10) turtle.left(10) time.sleep(1)
a40f2c5774f6a127f4063be88076327f73407e39
mameen-omar/EAI320_Practical-4
/SOFTWARE/Game.py
13,597
3.59375
4
import numpy as np import copy import queue import sys class game: #initializer def __init__(self, game = None, board = None): if(game == None): self.board = np.array([["#","#","#"], ["#","#","#"], ["#","#","#"]]) ...
84d5413932754c2c84ee6a8ce2842d65596b56de
MisterJackpot/decrypt_vigenere
/index.py
3,513
3.53125
4
#!/usr/bin/python import sys from collections import Counter INDEX_OF_COINCIDENCE = 0.072723 ALPHABET = "abcdefghijklmnopqrstuvwxyz" NUMBER_OF_LETTERS_PORTUGUESE = 26 PORTUGUESE_LETTER_FREQUENCIES = [14.634,1.043,3.882,4.992,12.570,1.023,1.303,0.781,6.186,0.397,0.015,2.779,4.738,4.446,9.735,2.523,1.204,6.530,6.805,4....
4f6054cd2ab80b4cbc6d79dc9c9250cc8318e1f2
xinshuaiqi/My_Scripts
/python 学习/objectives/class.py
3,528
3.96875
4
# liao xue feng example # https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001431864715651c99511036d884cf1b399e65ae0d27f7e000 class Student(object): pass qxs = Student() qxs # 后面的0x10a67a590是内存地址 Student class Student(object): def __init__(self, name, score): self....