blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
226388f95456e7a467d86f85a1fb335b5048b40b
dhruvarora93/Algorithm-Questions
/Graphs and Trees/Q8.py
1,415
3.75
4
class Node: def __init__(self,key): self.left=None self.right=None self.parent=None self.value=key def depth(n): height = 0 while(n.parent): n = n.parent height += 1 return height def go_up(n,steps): count = 0 while count != steps: n = ...
f3f523acda56f49487e74a057b04f08ceed9d907
dhruvarora93/Algorithm-Questions
/Array Problems/max_product_subarray.py
314
3.59375
4
def max_product(nums,k): if k <= 1: return 0 prod = 1 ans = left = 0 for right, val in enumerate(nums): prod *= val while prod >= k: prod /= nums[left] left += 1 ans += right - left + 1 return ans ar = [1,2,3,2,10] print(max_product(ar,20))
29c0ce37069a7cad319d219c06602ab27132899c
dhruvarora93/Algorithm-Questions
/Array Problems/longestvalidpalindrome.py
377
3.71875
4
def longest_valid_parantheses(string): stack = [-1] maxlen = 0 for i, c in enumerate(string): if c == '(': stack.append(i) else: stack.pop() if stack: maxlen = max(maxlen, i-stack[-1]) else: stack.append(i) ...
9e6422cf592c3df348a82503a6448739237a51a3
dhruvarora93/Algorithm-Questions
/Array Problems/max_reward_pacman.py
909
3.5
4
def get_max_reward(mat, row, col): if row < 0 or col < 0: return 0 else: return mat[row][col] + max(get_max_reward(mat,row-1,col),get_max_reward(mat,row,col-1)) def get_reward(mat): reward = [[0]*len(mat[0]) for _ in range(len(mat))] visited = [[False]*len(mat[0]) for _ in range(l...
3bdfbc9385681f8612d851e9c04389de4526b46f
dhruvarora93/Algorithm-Questions
/Array Problems/find_duplicate_number.py
356
3.640625
4
def find_duplicate(nums): if len(nums) > 0: slow = nums[0] fast = nums[nums[0]] while slow != fast: slow = nums[slow] fast = nums[nums[fast]] head = 0 while slow != head: slow = nums[slow] head = nums[head] return slow...
1e3c7c09157a75bb4e013a6b09368a47c44cab6d
dhruvarora93/Algorithm-Questions
/Array Problems/intersection of rectangles.py
646
3.953125
4
def find_overlap(point1,length1,point2,length2): highest_point = max(point1,point2) lowest_point = min(point1+length1,point2+length2) if highest_point >= lowest_point: return (None,None) return highest_point, lowest_point - highest_point my_rectangle1 = { # Coordinates of bottom-left...
027b1a1c2f335782c1f33f78bc2f3a0a75c55b27
dhruvarora93/Algorithm-Questions
/Dynamic Programming/cake_thief.py
642
3.515625
4
def max_duffel_bag_value_with_capacity(cake_tuples, capacity, max_at_each_weight): for i in range(1,capacity+1): maximum = 0 for cake_weight, cake_value in cake_tuples: if cake_weight <= i and cake_weight != 0: current = max(cake_value, cake_value + max_at_each_weight[i-c...
d1da3baf9053e7c5139df8322daf31fef54cc37f
dhruvarora93/Algorithm-Questions
/Array Problems/prefix to postfix.py
401
3.84375
4
def prefix_to_postfix(string): stack = [] operators = ['+','-','/','*'] for i in string[::-1]: if i not in operators: stack.append(i) else: operand1 = stack.pop() operand2 = stack.pop() temp = str(operand1) + str(operand2) + i stac...
a46521e696f2ef613067e8f685f9cc889ba6c238
dhruvarora93/Algorithm-Questions
/Graphs and Trees/graph_coloring.py
832
3.796875
4
from collections import defaultdict class GraphNode: def __init__(self, label): self.label = label self.neighbors = set() self.color = None def coloring(graph): distinct_colors = ['r','g','b','y'] for node in graph: colors_used = set() for i in node.neighbors: ...
160113cdf60ab06f9d40b4e20be2b384083dbe71
dhruvarora93/Algorithm-Questions
/Graphs and Trees/Q2.py
2,158
3.984375
4
class Node: def __init__(self,key): self.left=None self.right=None self.value=key def insert(root,node): if root is None: root = node else: if node.value < root.value: if root.left is None: root.left=node else: inse...
eacd8b4ef465350017e0c1f756e63fc92f156ec9
dhruvarora93/Algorithm-Questions
/Array Problems/reverse_Words.py
775
3.640625
4
def reverse_words(ar): ar.reverse() number_of_words = 1 indices = [] for i,j in enumerate(ar): if j == ' ': number_of_words += 1 indices.append(i) indices.append(len(ar)) count = 0 starting_index = 0 while count < number_of_words: last_index = ...
f3df915657bf25a6e871e4a85c11d90acc6ba709
dhruvarora93/Algorithm-Questions
/Linked List/check_cycle.py
630
3.96875
4
class LinkedListNode(object): def __init__(self, value): self.value = value self.next = None def check_cycle(node): if not node.next: return False head1 = node head2 = node.next while head1 != head2: if not head1.next: return False if not head2....
0af76aed2c7ace524be81763c15e1a1c3cfbd87f
ehughson/sudoku_solver
/SudokuPuzzle.py
6,425
4.25
4
from math import sqrt from math import sqrt class SudokuPuzzle: """ A class to represent a single sudoku puzzle. Attributes ---------- board : list[list] contains the sudoku puzzle as a list of rows of characters. Blank is represented as "" size : int size of the puzzle.(for n...
18204e5dad8f08704fafc366de33a7bad7fe5a68
kayartaya-vinod/2017_08_PHILIPS_PYTHON
/Examples/ex21.py
813
3.734375
4
# import userexceptions # have to use the members with 'userexceptions.' prefix from userexceptions import InvalidAgeException, InvalidNameException class Person(object): @property def name(self): return self.__name @name.setter def name(self, name): if type(name) is not str: raise InvalidNameException(...
a31f3b686320226f2a784d25db62b363a55073b1
kayartaya-vinod/2017_08_PHILIPS_PYTHON
/Examples/ex20.py
685
3.765625
4
def test(*args): try: n1 = args[0] n2 = args[1] n1 = int(n1) if type(n1) is str else n1 n2 = int(n2) if type(n2) is str else n2 if n1<5 : return; q = n1//n2 return q except (ValueError, ZeroDivisionError) as x: print(x) except IndexError: print("Two numbers were expected, got {}".format(len(a...
671935685e05969a6459df6349c98ae4516e0b27
kayartaya-vinod/2017_08_PHILIPS_PYTHON
/Examples/ex06.py
578
3.875
4
# loop through the dictionary info = {} info["name"] = "Vinod" info["email"] = "vinod@vinod.co" info["phone_numbers"] = ("9731424784", "9844083934") info["address"] = dict(city="Bangalore", state="Karnataka", country="India") for key in info.keys(): val = info[key] if type(val) in [list, tuple]: print("Total %d ...
11d3fc1846fe4345c37be7333a65140a36931330
Shaletanu/avodha_code_challenge
/coding_challenge_7.py
287
3.890625
4
def add_element(dict, key, value): if key not in dict: dict[key] = value product = {} add_element(product, "Apple", 200) add_element(product, "Orange", 300) add_element(product, "Grapes", 350) add_element(product, "Watermelon", 400) for i in product.values(): print(i)
1c19ae7983cb4c5408d7f6e6864a7da7acf3bc20
Shaletanu/avodha_code_challenge
/coding_challenge_2.py
170
3.65625
4
#Task no 1 str = "I am a programmer" for i in range(0, 5): print(str) #Task no 2 def square_value(n): for i in range(1, n): print(i*i) square_value(10)
bf5d152c238b019fc47ab8b2ad92b1626731fa97
jeremylee87/learnpy
/test.py
147
3.96875
4
# print absolute value of an integer #a = 100 #if a >=0: # print(a) #else: # print(-a) if age >= 18: print('adult') else: print('teenager')
f6f639dedc8fa0dacedce1073e2f3bed100fb3a6
lentiummmx/Design-Patterns-In-Python
/facade/facade.py
760
3.578125
4
""" Facade Design Pattern """ class SubSystemClassA: @staticmethod def method(): return "A" class SubSystemClassB: @staticmethod def method(): return "B" class SubSystemClassC: @staticmethod def method(): return "C" # facade class Facade: def __init__(self): ...
62060e529fb4d55e578338b0a3807039799a7a13
lentiummmx/Design-Patterns-In-Python
/abstract_factory/table_factory.py
2,198
4.4375
4
"""A Factory Pattern Example The Factory Pattern Defines in Interface for creating an object and defers instantation until runtime. Used when you don't know how many or what type of objects will be needed until during runtime """ from abc import ABCMeta, abstractstaticmethod class ITable(metaclass=ABCMeta): # pylin...
5207ee3be30429c742c2e7513434c2ba43d02bb6
xaneon/PythonProgrammingBasics
/python_example_scripts/max_recursion_depth.py
255
3.78125
4
def recursive(i): try: i = i + 1 recursive(i) except RuntimeError as exc: print ('max depth == %d' % i) try: exit(0) except RuntimeError: print ('RuntimeError in exit') recursive(0)
4e79aa108e58d2aa4d5e7c6c70f22c31033e2646
xaneon/PythonProgrammingBasics
/oop/oop_continued.py
306
3.515625
4
class A: def m(self): print("m von A") class B(A): def m(self): print("m von B") A.m(self) class C(A): def m(self): print("m von C") A.m(self) class D(B, C): def m(self): print("m von D") B.m(self) C.m(self) d = D() d.m()
b1061661ad5ea0ab3dd491c7b0adbb737ce75e99
xaneon/PythonProgrammingBasics
/comprehensions/comprehensions.py
675
3.859375
4
""" Normierung einer String-Liste auf Klein- buchstaben. Drei Wege die zum Ziel führen werden demonstriert. """ # Input answers = ['Yes', 'yes', 'No', 'no', 'maYbE'] # Weg 1: Die klassische for-Schleife normalized = [] for x in answers: normalized.append(x.lower()) # Weg 2: Lambda und map() normalized2 = list(map...
6850ca104b180d961b5d69f9e4cb540a17d1b3bf
adamatom/dotfiles
/.bin/i3blocks/clock.py
723
3.71875
4
#!/usr/bin/env python3 """Prints the time given a format. Can also launch something when clicked.""" import os from subprocess import Popen import argparse from time import localtime, strftime def create_argparse(): """Generate the argparse object.""" parser = argparse.ArgumentParser(description='Print the tim...
9ac740359a83ead7e96e4404cfc3e640c49e96a1
AwetKebedom/di-python-2018
/my bootcamp staffs/Home Work 1/Exercise 1.py
148
3.515625
4
mysentence = " have you enjoyed the class?" word = mysentence.split() i= 0 w_count = 0 while i < len(word): w_count+=1 i+=1 print (w_count)
ac58139586144cea210b9fd119b963f01a2fc5ab
AwetKebedom/di-python-2018
/my bootcamp staffs/Home Work_2/second test.py
149
3.875
4
mystring = "hello world" beginning = "hell" i = 0 if mystring[0:len(beginning)]==beginning: print("yes") else: print("no")
68e32b69e9d2e765827f31234a494f2bf3c93056
AwetKebedom/di-python-2018
/my bootcamp staffs/new folder/Steps 1, 2 and 3.py
316
3.90625
4
#step 1 contacts ={"tesfalem": 545770120, "suzi": 532262321, "awet": 543146864 } #step 2 contacts["bereket"] = 54454445 #step 3 # A. for loop method for contact in contacts: print("This is {} and can be reached at {}".format(contact, contacts[contact]))
8f939d12cee36226489f9ce3af63bd789f9851c7
AwetKebedom/di-python-2018
/dictionary/restuarant.py
2,739
3.9375
4
# The restaurant # A class Restaurant with those attributes: # # capacity --> int # nb_of_tables --> int # tables_state --> Dictionary {1:True, 2:False, 3:True... for every table} # opening_hour --> int # closing_hour --> int # methods: # # client_in --> if you can add them, return true and ...
e7aad8d2eed447178e2d4c0d7a7701d6838750eb
Guilherme-Avellar/vetores
/exercicio_10.py
519
3.875
4
# 10.Escrever uma função que substitui por zero todos os números negativos do vetor passado por parâmetro, def subistituir_negativos(vetor, num): for i in range(len(vetor)): if vetor[i] < 0: vetor[i] = num return vetor vetor1 = [] for i in range(5): numero = int(input("Di...
f7b4e1d9be3949270eef989b058bbc3ed3fe2f6e
SCRedstone/plugdj-exporter
/utils/duplicated.py
434
3.8125
4
# Removes duplicates from a list def removeDuplicate(listing): preRemove = len(listing) newList = list(dict.fromkeys(listing)) print("Duplicates found: " + str(preRemove - len(newList))) return newList def removeDuplicates(listing, purpose): preRemove = len(listing) newList = list(dict.fromke...
b7589a0ad9557ddc95217bfda938f8837ce8c56b
joseamador0898/algorithms-and-data-structures-in-python
/lists/add_two_numbers.py
777
3.65625
4
# https://leetcode.com/problems/add-two-numbers/ # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, p: ListNode, q: ListNode) -> ListNode: ans = ListNode(None) ...
1abe4b514214503330fa94af175328d7d62a190f
ericksc/bootstrap
/db_conn.py
627
3.578125
4
from sqlalchemy import create_engine import pandas as pd engine = create_engine('sqlite:///db.sqlite', echo=False) def leer_db(table_name): return pd.read_sql(sql=f'select * from {table_name}', con=engine) def salvar_db(df, table_name): df.to_sql(table_name, engine, index=False, if_exists='replace') if __na...
952cf0df43b66f3cdb1f30b77c6551e6c841844a
IshMSahni/Photo-editor
/filters.py
16,064
3.859375
4
""" SYSC 1005 Fall 2018 Filters for Lab 7. All of these filters were presented during lectures. """ from Cimpl import * from random import randint def grayscale(image): """ (Cimpl.Image) -> Cimpl.Image Return a grayscale copy of image. >>> image = load_image(choose_file()) >>> gray_image = g...
2d39187e3c5547eeedc52a75641c5a053eb3075d
DiWu9/AI_projects
/project-2-cannibals/missionary.py
7,736
4
4
### File: missionary.py ### Implements the missionaries and cannibals problem for state ### space search from improvedSearch import * import gym from gym.envs.classic_control import rendering LEFT = 0 DOWN = 1 RIGHT = 2 UP = 3 class MissionaryState(ProblemState): """ Missionaries and Cannibals puzzle: Three...
befba2f6cf24c2d0c8e926893a821364a1cdaa8c
DiWu9/AI_projects
/project-1-eliza/wups1.py
9,294
3.734375
4
import chenps1 as cc import time import random class ChatAgent: #replace this with your last name, like RieffelChatAgent """ChatAgent - This is a very simple ELIZA-like computer program in python. Your assignent in Programming Assignment 1 is to improve upon it. I've created this as a python object so...
fc61f7adaa89950041b44a200611fb21730b5860
StigernMTF/git-training
/cesar.py
897
3.578125
4
# Кодирование с помощью "шифра Цезаря" (на РУССКОМ алфавите). alph = 'абвгдеёжзиклмнопрстуфхцчшщъыьэюя1234567890абвгдеёжзиклмнопрстуфхцчшщъыьэюя1234567890' # Копирования алфавита для шифрования последних букв алфавита vvod = str(input('Какое слово хочешь закодировать?:')) sdvig = int(input('На сколько идет сдвиг?(1-3...
be86ec52da3864bca635b571afb67b700b9f9fd8
sajansunny/pythonSelenium_Udemy
/PythonBasics/DataTypes.py
1,147
3.828125
4
# List - Mutable print("----------List----------") values_list = [1, 2, "Sajan", 4, 5] print(values_list[0]) # 1 print(values_list[2]) # Sajan print(values_list[-1]) # 5 print(values_list[1:4]) # [2, 'Sajan', 4] values_list.insert(3, "Sunny") print(values_list) #...
51ac2aa3c8cd9084673cb1a0aaad62db7600f0c4
Skytrave/Python-spider-learning
/2018.1.24-25.py
485
3.609375
4
#!/usr/bin/env python # _* _ coding:utf-8 _*a #for i in range(1,10): #print(i) names=['xiaoming','travel'] ages=['23','24','26','78'] for name,age in zip(names,ages): print(name,age) #for a in range(1,14): # print(a) urls=['https://www.cnblogs.com/waltsmith/p{}-0/'.format(a) for a in range(1,13)] for url...
07db94de6b232aa61ce476d5618d0d0976043704
orlova-lb/PythonIntro06
/lesson_17/test.py
846
3.765625
4
from student import Student from group import Group name = input('Please enter group name: ') gr = Group(name) cnt = int(input('Please enter count of studens: ')) for i in range(cnt): st = Student() st.name = input('Please enter name: ') st.age = int(input('Please enter age: ')) cnt_g = i...
a5cdb13deb697430e0a7f791a19a20d33eef9d02
orlova-lb/PythonIntro06
/lesson_09/ex.py
697
4.03125
4
""" Найти произведение элементов списка, кратных 6 и оканчивающихся на 8. Если таких элементов нет - сообщить об этом. """ from random import randint lst = [randint(1, 100) for _ in range(35)] print(lst) def search(collection): tmp = [] p = 1 for el in collection: if el % 6 == 0 and el % 10...
497c03cfb6da3bcb9d40ed26300d46b6f75d5341
orlova-lb/PythonIntro06
/lesson_03/IF.py
401
4.40625
4
""" if <condition>: operator 1 operator 2 else: operator 4 operator 5 operator 3 """ # x = 3 # if x == 0: # print('x is zero') # else: # print('x is not zero') """ x = 6 """ x = -4 if x > 0: print('x is positive') elif x < 0: print('x is negative') else: print('x is zero') ...
cd1e4a31c6c9fdc4193dcd9ce561a81827245229
orlova-lb/PythonIntro06
/lesson_17/student.py
737
3.6875
4
class Student: def __init__(self, name=None, age=None, grades=None): if not grades: self.__grades = [] self.__name = name self.__age = age @property def name(self): # print('In property NAME') return self.__name @name.setter def ...
4bc6b721924747df8761b0d037f24b314c68ab66
orlova-lb/PythonIntro06
/lesson_07/tuples.py
228
3.625
4
t = () print(t, type(t)) t = tuple('D:/PROJECT/Python/HILLEL/PythonIntro06/lesson_07/tuples.py') print(t, type(t)) t = (2, 4, 6, 7, 8) print(t, type(t)) t = t + (6.6, 7, 2, 2, 9) print(t, type(t)) t = 50, print(t, type(t))
5bda795a9f3b5b7f4c9ceffb971350e5fc6abfd6
orlova-lb/PythonIntro06
/lesson_02/type_of_data.py
1,052
3.953125
4
""" int a = 9; """ count = 5 print(count) count = 'Hello' print(count) d = count print(d) """ f| | | | | char f; | str | count ------------>| ref = 2 |<----- d | 'Hello' | """ """ числовой: int, float, complex строковый: str, ESCA...
d4291c364b880bbf96e517834af83154a71eab0f
FullteaR/naturalLanguageProcessing100Knock
/knock34.py
248
3.53125
4
from knock30 import neko for i in range(1, len(neko) - 1): if neko[i]["surface"] == "の" and neko[i - 1]["pos"] == "名詞" and neko[i + 1]["pos"] == "名詞": print("{0}の{1}".format(neko[i - 1]["surface"], neko[i + 1]["surface"]))
9e9740f8081366f8ddab6d76467dc7c08fd091bc
FullteaR/naturalLanguageProcessing100Knock
/knock03.py
233
3.546875
4
string = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." string = string.replace(",", "") string = string.replace(".", "") result = [len(i) for i in string.split(" ")] print(result)
f8f07f88c6e4441fb10e03eebdc315a2a9fadc92
nihk/Python-Project-Euler
/Problems1-9/Problem7.py
5,559
3.796875
4
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # # What is the 10 001st prime number? # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ...
f8640ed732bbb8afc4517af360b477b1275ce692
nihk/Python-Project-Euler
/Problems20-29/Problem26.py
3,142
3.734375
4
# A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with # denominators 2 to 10 are given: # # 1/2 = 0.5 # 1/3 = 0.(3) # 1/4 = 0.25 # 1/5 = 0.2 # 1/6 = 0.1(6) # 1/7 = 0.(142857) # 1/8 = 0.125 # 1/9 = 0.(1) # 1/10 = 0.1 # Where 0.1(6) means 0.166666..., and has a ...
9b29ead7f8ab70b08f69dff1eaff95806a28bf84
FloraC/Coursera-Cryptography1
/ps1/P1setsol2.py
718
3.5
4
import sys import string ## plain text 1 pt1 = "attack at dawn" ## ascii for text 1 acpt1 = "".join([hex(ord(x)) for x in pt1]) acpt1 = "0x"+"".join([x for x in string.split(acpt1,"0x")]) ## plain text 2 pt2 = "attack at dusk" ## ascii for text 2 acpt2 = "".join([hex(ord(x)) for x in pt2]) acpt2 = "0x"+"".join([x for...
fffd26f74e2663fc2b817e5083c7d7eb01f7fa76
manulg1/DinHedging
/DinInsurance.py
7,890
3.5625
4
# -*- coding: utf-8 -*- """ @author: Manuel Luna """ import numpy as np import math import pandas as pd from scipy import stats import random ''' Production Value Firstly, this package includes a function that allows users to estimate the Expected Net Present Value and Standar Deviation from a set ...
9e3501061cd32cc7084b4bf512bc8683ebce35d3
immortalmin/csk
/day6/dog.py
316
3.578125
4
#Author:immortal luo # -*-coding:utf-8 -*- class Dog: def __init__(self,name): self.name = name def bulk(self): print(self.name+"wang wang wang") d1 = Dog("xiaohuang") d2 = Dog("xiaohei") d1.color = "blue"#增加属性 print(d1.color) del d1.color#删除某个属性 # d1.bulk() # d2.bulk()
4c206099af5f0d95777a4379ef42549b11ef5505
immortalmin/csk
/day1/shopping.py
1,431
3.859375
4
#Author:immortal luo # -*-coding:utf-8 -*- list1 = [["bike",800], ["luomin",100],["chenshengkuan",200],["zeng",300]] minn = list1[0][1] for i in list1: if(i[1]<minn): minn = i[1] list2 =[] salary = int(input("请输入你的工资:")) while(True): # number = int(number) print("商品列表:") for i in list1: ...
6a0d0ac7ae8582639897551c9cbc0a14198e40c0
immortalmin/csk
/day10/草稿.py
323
3.65625
4
#Author:immortal luo # -*-coding:utf-8 -*- import threading,time import queue # def run(): # print("running") # time.sleep(2) # # for i in range(10): # t = threading.Thread(target=run) # t.setDaemon(True)#守护线程 # t.start() # t.join() q = queue.Queue() q.put(1) q.put(2) q.put(3) q.put(4) print(q)...
a39a3a673f3eb6c57f20f8bca2c2b48b733a7be9
immortalmin/csk
/day1/names.py
510
4
4
#Author:immortal luo # -*-coding:utf-8 -*- import copy # names = [] names = ["chenshengkuan", "luominmin", "weijinyan", "zhangjinmu", "liushunli"] # print(names) # names.append("zeng") # names.insert(1,"wugui") # names[1] = "jinyan" # names.remove("weijinyan") # del names[3] # names.pop() # print(names.index("chensheng...
3f2b71801f2724d9519a7aea4c95ebe22e55424f
NathanCollinson/Discovery-of-Aotearoa
/Kupe_v2.py
6,876
4.40625
4
#This is a board game based on the adventure of the great Polynesian Navigator Kupe #When creating 'landmarks', I will need to create each tile a dictionary #But display the "X" #When you have 'discovered' a landmark i will rerandomise, the next landmark #Octopus (%) will have it's own movement and will cause the...
9dff26d10857abb313adc17e24cc362aeb30b2e1
sahasukanta/repo-rosalind.problems
/rosalind_calculating_protein_mass.py
1,182
3.609375
4
# calculating protein mass # mass dictionary amino_acid_mass = {'A' : 71.03711, 'C' : 103.00919, 'D' : 115.02694, 'E' : 129.04259, 'F' : 147.06841, 'G' : 57.02146, 'H' : 137.05891, 'I' : 113.08406, 'K' : 128.09496, 'L' : 113.08406, 'M' : 131.04049, 'N' : 114.04293, 'P' : 97.05276, 'Q' : 128.05858, 'R' : 156.10111,...
9be90863063e2990fe28cd639db65565a79cc74f
cppavel/TelegramItinerary
/dataBase.py
5,000
3.6875
4
import sqlite3 class DataBase: #creates a user database and sets a connection def __init__(self): self.connection = sqlite3.connect("users.db",check_same_thread=False) self.cursor = self.connection.cursor() try: self.cursor.execute("""CREATE TABLE users(userName te...
131a0e9bba9869fc867e880b9dbd0e681d721ffc
unodeej/OneDayRPG
/display.py
2,516
3.5625
4
import numpy as np import os import time windows_compatibility_mode = False # Some windows versions may not support colors? transparentTile = " " # to get a transparent character, type display.transparentTile -- using ASCII alt+255 width = 160 height = 35 __viewports = [] if os.name == "posix": os.system("clear")...
d36b14c1a6c375ba4e7e37043b9a825dea382b81
Blaidej/SPC.Python
/SystemAdministrationAssign/RecursiveLab.py
300
4.09375
4
def factorial(n): if(n == 0 or n ==0): return 1; else: return n * factorial(n-1) def main(): n =eval(input("Number to find factorial: ")) print(" The value of the n input: ",n) n_fac = factorial(n) print("The factorial of n: ", n_fac) main()
f53afe3fdc65cf9c14389d66d69608c0b586e960
Macage/learningFile
/test.py
1,414
3.546875
4
def count(): fs = [] for i in range(1,4): def f(j): def g(): return j * j return g r = f(i) fs.append(i) return fs #f1, f2, f3 = count() #print(f1,f2,f3) """ class Person(object): pass xiaoming = Person() xiaoming.name = "Xiao Ming" xiaomi...
ae11045ac15e81874517267aae2f4924db867e89
leanbarrios/ptrFog
/auto.py
1,542
3.53125
4
#-- @Autor: Maximiliano Rodrigo Soria #-- Version: 1.0 #-- Python 2.7.13 #-- Anio 2013 #-- Programacion en Tiempo real import random from error import * class Auto(): def __init__(self, modelo, tipo, patente): self._modelo = modelo self._tipo = tipo self._velocidad = 0 self._estado = "" self._patente = pa...
f5d8593aaf3ef88bff1d3d0ecf1064c0ddb4b4a2
tekiegirl/SafariPython
/conditions.py
470
4.21875
4
# PEP 8 "python enhancement proposal" -- style guide x = int(input("enter a number ")) y = int(input("enter a number ")) if x > y: print("x is bigger than y!!") print("yup, did you hear me") # else: # if x == y: elif x == y: print("they're the same") else: print("x is not bigger than y!") # and, ...
2d13213698509a24faf67976cc4b7ce09e1a9800
nickyrabit/DataStructureAndAlgorithm
/sorting/bubble_sort.py
340
3.96875
4
#in bubble sort i iterate items in an array and compare them then swap if a condition is true def bubble_sort(a): n = len(a) for i in range(0,n-1): for j in range(0,n-i-1): if a[j] > a[j+1]: a[j], a[j+1] = a[j+1], a[j] print(a) if __name__== '__main__': bubble_s...
8bd765da612adc6a931457b11be5b66d2fe10432
ggarvey-python/matrix-math-libary
/logic(for github)/adding logic.py
2,161
3.84375
4
import numpy as np #matrix math libary logic testing #NOT THE COMPLETE APP test_matrix = [[3,2,6], [4,3,7], [3,4,2]] test_matrix2 = [[7,3,2], [5,3,5], [6,2,6]] ## to see the amount of numbers in each matrix columns = len(test_matrix[0]) columns2 = len(...
7841eb8d7d1c1bd11f6bd8ac8aff73912c00fae2
JHocevar/3354-TheBookaholics
/Test Cases/TestCode.py
1,218
3.96875
4
import unittest class Bookaholics(): def __init__(self): self.booklists = [] self.add_list('To Be Read') # Initialize with a standard list def get_list_names(self): list_names = [] for booklist in self.booklists: list_names.append(booklist.name) return list_names def add_...
d351f3132cdbf0a924a189e6d46e209b411e61d7
alalexl/python-projects
/pythonProjects/checkPeriod.py
314
4.0625
4
#return true if string contains xyz that doesnt have . in front def checkPeriod(str): n = str.find('xyz') if n == 0: return True elif str[n-1] != '.': return True else: return False if __name__ == '__main__': print(checkPeriod(input("Enter a string: ")))
0f6fd1e452d3540778a611ee0d54d70cd2460aba
yanchen036/euler
/p31.py
359
3.703125
4
coins = [200, 100, 50, 20, 10, 5, 2, 1] def recurrent(total, cur_coin, succ): if total == 200: succ[0] += 1 return else: while cur_coin < 7: if total + coins[cur_coin] <= 200: recurrent(total + coins[cur_coin], cur_coin, succ) cur_coin += 1 ret =...
4affdbc161e5abec4685fac2f1801a855e6eade4
ravikishorethella/Algo_Practice
/7. Linked List Construction/linked_list_construction.py
3,280
4.09375
4
''' construct a doubly linked list ''' class DoublyLinkedList: def __init__(self): self.head = None self.tail = None # time: O(1) | space: O(1) def setHead(self, node): if self.head is None: self.head = node self.tail = node return self....
16db3e93ec3850bac70c974c4c9a3e3a78b08b42
ravikishorethella/Algo_Practice
/14. Selection Sort/selectionSort.py
603
4.09375
4
''' Given an array, sort the numbers using selection sort technique input: nums = [8,5,1,6,7] output: [1,5,6,7,8] ''' # Time - O(n^2) # Space - O(1) def selectionSort(nums): currentIndex = 0 # first num in the unsorted list while currentIndex < len(nums) - 1: smallestIndex = currentIndex for i ...
4f525f38c5a2b6d40e850e2f48869e154f2eb4db
ravikishorethella/Algo_Practice
/Sliding Window/minimum_window_substr.py
1,021
3.921875
4
''' https://leetcode.com/problems/minimum-window-substring/ Given two strings s and t, return the minimum window in s which will contain all the characters in t. If there is no such window in s that covers all characters in t, return the empty string "". ''' def minWindow(s, t): t_counter = Counter(t) chars = len...
e424648b7cec07d0f2566e896666fad6a7b66d6c
uc007/logparser
/lib/dicttools.py
1,835
4.0625
4
__author__ = 'Ralf' # !/usr/bin/env python import functools def count_key_level(x, s, i=0): """ This function counts the level of nested keys. :param x: Dictionary to be analyzed. :param s: Potential key within the dictionary. :param i: Result level. :return: Level of nests as a number. ...
7d6fa879c3750bb358c80eb6c13fae3448fd3c8b
Rohitimb/mycodepractice
/pythonpractice/prime.py
639
3.703125
4
def prime_check(num): '''Prime check function''' for x in range(2,(int)((num/2)+1)): if not num % x: return None return num print('\n') for y in range(1,101): if y == prime_check(y): print(y) print('series\n') def prime_series(num): m = 0 '''Prime series function'...
3e3e856b7e26ddb2f7f27725fcbb89059e174c15
ritikjain09/Pythontask
/roles.py
756
4.0625
4
class file: def userfile(self,obj): self.obj=obj print("1.employee") print("2.manager") n = int(input("select the user:")) if n==1: a=str(input("Enter the name of the file with extension:")) file1=open(a,'r') line=file1.readline() while(line!=""): print(line) line=file1.re...
4999b01dffdbc70ed79e8f9e99e68a6159dbb9b8
tigerthelion/advent-of-code-2020
/01.py
2,018
4.28125
4
""" Specifically, they need you to find the two entries that sum to 2020 and then multiply those two numbers together. For example, suppose your expense report contained the following: 1721 979 366 299 675 1456 In this list, the two entries that sum to 2020 are 1721 and 299. Multiplying them together produces 1721 *...
f46eb1ee29035a8d5659b4e2243ca9b6f134456a
abhishek09091/competitive-programming
/Interview Questions Asked to me/News Timeline/out/production/News Timeline/numbers-containing-1-2-and-3.py
611
3.625
4
# code import re def contains_123(): t = int(input()) for i in range(t): n = int(input()) arr = list(map(int, input().split())) # print(arr) res = [] expression = "[4-9]+" expressionzero = "0+" for ele in range(len(arr)): if not bool(re.searc...
f79b60aef0897051529523989e43e628366948fb
nicobtech/practicosbtech
/AA YO/pract1.py
246
4.09375
4
#1 valor = input("ingresa algo") print(len(valor)) #2 string = input("ingresa algo: " ) print(string[5].upper()) print(string[6].upper()) #3 nombre = input("pone tu apellido: ") apellido = input("pone apellido: ") print("hola",nombre,apellido )
f90efb7017ace8b8f23d97df5f41f15f37267fa8
mattjmorrison/pycrap
/tests/sample_app/life.py
2,625
3.546875
4
import re class Life(object): def __init__(self, name): self.name = name def can_drink(self, liquid): return liquid in self.drinks def can_eat(self, food): return food in self.food class Animal(Life): drinks = ('milk', 'water',) food = ('meat', 'potatoes') poisons = ...
367ec7f445391444e26367c547cf8e25225b0840
Tian99/Basic_depth_analysis
/disparity_ssd.py
2,274
3.53125
4
import cv2 as cv import numpy from PIL import Image from math import pow def disparity_ssd(L, R, scale): """Compute disparity map D(y, x) such that: L(y, x) = R(y, x + D(y, x)) Params: L: Grayscale left image R: Grayscale right image, same size as L Returns: Disparity map, same size as L, R ...
e0a7c5832147a3997868e88b492033ff40ab7720
FranciscoCanas/mintermer
/pytermer/mintermscript.py
3,287
3.890625
4
#!/usr/bin/python import sys import math import cgi import cgitb cgitb.enable() VERI_AND = "&" VERI_OR = "|" VERI_NOT = "~" SYMB_AND = "*" SYMB_OR = "+" SYMB_NOT = "!" LB = "[" RB = "]" IN = "In" SEP = " " LBr="(" RBr=")" LRET="\n" input_symbol=IN def main(): if (len(sys.argv)>2): input_symbol = str(sys.argv[2]) ...
99c35a975687c776a079bb623002304ee4ac7ab5
msaqibdani/LeetCode-Practice
/practice.py
1,737
3.8125
4
from collections import deque class MaxQueue(): def __init__(self): q = deque() max_q = deque() def push(num): if not q: max_q.append(num) q.append(num) else: while max_q[0] <= num: max_q.popleft() def pop(): def max_num(): return ''' [9, 5, 7, 1] [9, 5, 7, 1] -> how to trac...
07f5a7c5d5ea64041639f57ae921cead44003737
onyxcode/copilot-testing
/isthiswebsiteon.py
1,558
3.640625
4
# check if a given website is up or down def main(): import requests import sys import time import argparse import socket import re import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) parser = argparse.ArgumentParser(description='Check if a website is ...
555983c602a99ea4a80823173712b75440db408d
onyxcode/copilot-testing
/calculate-tax.py
424
4.21875
4
# calculate florida sales tax for a given amount def main(): # get the amount of the purchase amount = float(input("Enter the amount of the purchase: ")) # calculate the tax tax = amount * 0.07 # display the result print("The tax is $", format(tax, ',.2f'), sep='') # print the total includin...
8d13aa1027a59de441eb6fa4b5c49280b4e72dcd
alce65/python_febrero
/04_str_operations.py
301
3.78125
4
cadena = 'Un anillo para gobernarlos a todos' l_c = len(cadena) lista = cadena.split(' ') print(lista) print(len(lista)) print(l_c) print(lista[0]) print(cadena[0]) lista[0] = 'EL' print(lista) # cadena[0] = 'E' -> error print(cadena[-1]) print(cadena[3:9]) print(cadena[10:]) print(cadena.count('a'))
5707f71ee8e2ee5c6c2f8f90394f0e6e7ffd3468
alce65/python_febrero
/06_operadores.py
735
3.8125
4
print(3 + 4) print(3 - 4) print(3 * 4) print(4 // 3) print(4 % 3) print(4 / 3) print(3 ** 4) print((3 + 4) * 2) x = 8 x += 2 # x = x + 2 d = 0 e = 2 print(d == e) print(d != e) print(d > e) print(d >= e) print(d < e) print(d <= e) print('Pepe' < 'Valerio') a = [1,2,3] a1 = a b = [1,2,3] print(a == a1) print(a == ...
ca593ab655f6b23d36ce716aa3be24340c396c34
alce65/python_febrero
/05_funciones_def.py
448
3.890625
4
def suma(a,b): # parámetros r = a + b return r # Mala práctica por mezclar distintas funcionalidades def suma_y_muestra(a,b): def sum (a,b): return a+b r = sum(a,b) print(r) print(type(suma)) indice = 6 print(suma(3,indice)) #pasamos argumentos suma_y_muestra(8,75) def resta(a = 0, b = ...
019858e53f17505050287bbcd76e5a10997cdbd1
alexis5999/Backend_Python
/Semana1/sesion2/excepciones.py
339
4.0625
4
try: numero = int(input("Ingresar un numero")) numero/0 except ValueError : print('Tiene que se un numero') except ZeroDivisionError: print('No se puede hacer la division entre cero') except: print('huno un error') else: print('todo fue bien') finally: print('Yo siempre me ejecuto') print('yo soy otra ...
47b0b66cd7c997144c6f0970d7671c0f56ec3408
reasad/Undergrad-Assignments
/Artificial Intilligence/ass 1/py4.py
2,567
3.78125
4
# Find the grandchildren of X tupleList1=[('parent', 'Hasib', 'Rakib'),('parent', 'Rakib', 'Sohel'),('parent', 'Rakib', 'Rebeka'),('parent', 'Hasib', 'Rashid'),('parent', 'Hasib', 'Salma')] maleList=['Hasib','Rakib','Sohel','Rashid'] #find brother print('Finding Brother...') X=str(input("Person: ")) print('Brother:', ...
4d2272472dd1b2d1d5eb75eb0139f4929caf959b
reasad/Undergrad-Assignments
/Pattern Recognition/Assignment 1/160104004.py
3,526
3.609375
4
#!/usr/bin/env python # coding: utf-8 # Course Name: Pattern Recognition Lab # Course No : CSE 4214 # Experiment Name: Designing a Minimum Distance to Class Mean Classifier # Name: Md. Reasad Zaman Chowdhury # Section: A1 # Student ID: 160104004 # In[1]: get_ipython().run_line_magic('matplotlib', 'inline') import m...
1688b83064ad9f0946c60b8257b47731cedad28d
gmg444/GTECH733_2018
/06_network_simulation/network2listmatrix.py
1,972
3.875
4
""" A couple of functions that convert a network file to a distance matrix or a list. Contact: Ningchuan Xiao The Ohio State University Columbus, OH """ __author__ = "Ningchuan Xiao <ncxiao@gmail.com>" INF = float('inf') def network2list(fname, is_zero_based = True): """ Converts a network file to a list da...
b237eaf21cdeca9fdfd3d0d98804f7a0f8c94c39
mfranceschi/Minesweeper
/mfranceschi_minesweeper/model/fill_grid.py
2,050
3.65625
4
from abc import abstractmethod import random from typing import Callable, Set, Tuple from overrides.overrides import overrides from ..utils import Point2D class GridFiller: """Base class for algorithms for filling a grid with mines.""" def __init__(self, grid_dim: Point2D, nbr_mines: int) -> None: ...
308f11310851b720abb3b50b245070429dc087e7
juniormauricio23/TCC
/mouse_controller.py
691
3.578125
4
from pynput.mouse import Button,Listener, Controller import time mouse = Controller() #m=0 while True: mouse.click(Button.left) time.sleep(.5) #def click(x,y,button,pressed): #print(x,y,button,pressed) #listener monitorar o mouse #listener = Listener(on_click=click,on_move=move,on_scroll=scroll) #listene...
50a567fc5c1faf73cc6e919e047513bed6e58d3d
ernest-q/AI_Work
/Markov Decision Processes/mdp.py
8,093
4.03125
4
""" Originally Found in http://aima.cs.berkeley.edu/python/ Markov Decision Processes First we define an MDP, and the special case of a GridMDP, in which states are laid out in a 2-dimensional grid. We also represent a policy as a dictionary of {state:action} pairs, and a Utility function as a dictionary of {stat...
7eaaebddb16fb1f2d66e29357787b317e52490cb
ehabosaleh/parallelism
/multiprocessing/Example_2/data_parallelism.py
533
3.515625
4
import time from multiprocessing import Pool import numpy as np def square(x): return x**2 if __name__=='__main__': numbers =np.linspace(1,10000000) p=Pool(4) t1=time.process_time() print(p.map(square,numbers)) t2=time.process_time() p.close() p.join() print("executing time when using po...
8ab2c737afd65ddb69a4098de0f58575af2eaa55
jvpb/PYTHON3
/CAPITULO4/capitulo4.py~
29,903
4.09375
4
#!/usr/bin/env python3 '''estructuras de control y funciones''' # importar modulo import sys print ('VERSION en uso de PYTHON\n') print (sys.version,'\n') print ('¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬\n') print ('uso de condiciones multiples -if elif else- \...
50f0ef535e635d7dafe112da9408d7dca4d4e3dc
diegorafaelvieira/Programacao-1
/Aula 12/CódigosProfessor/ex1.py
209
3.65625
4
def maior(v1,v2): if v1>v2: print(v1) else: print(v2) def multiplos(v1,v2): if v1%v2==0: return True else: return False maior(10,-1) print(multiplos(10,5))
79a9989abd1d0f0455c665f10cabf3b7ba2cf8ea
diegorafaelvieira/Programacao-1
/Aula 12/CódigosProfessor/tarta1.py
547
3.609375
4
def quadrado(t,c): #Define a cor de preenchimento t.color(c) #Inicia preenchimento t.begin_fill() t.forward(100) t.left(90) t.forward(100) t.left(90) t.forward(100) t.left(90) t.forward(100) t.left(90) #Finaliza preenchimento t.end_fill() #Importa a biblio...
27dfdf9b2fa5daf0aaa1c0676562b99cd9d88997
diegorafaelvieira/Programacao-1
/Aula 03/ExercíciosCondicional/Exercicio12.py
731
3.96875
4
v1 = int(input("Informe o primeiro valor:")) v2 = int(input("Informe o segundo valor:")) v3 = int(input("Informe o terceiro valor:")) if (v1 > v2) and (v1 > v3) and (v2 > v3): print (" A ordem decrescente é:",v1,v2,v3) elif (v1 > v2) and (v1 > v3) and (v2 < v3): print ("A ordem decrescente é:",v1,v3,v2) elif (v...
fd374d60e3244b5d7d78a4dbb4da01a0b9d3bb75
diegorafaelvieira/Programacao-1
/Aula 03/ExercíciosCondicional/Exercicio6.py
1,456
4
4
c1 = float(input("Informe o valor do corretor 1:")) nomec1 = input("Informe o nome do corretot 1:") c2 = float(input("Informe o valor do corretor 2:")) nomec2 = input("Informe o nome do corretot 2:") c3 = float(input("Informe o valor do corretor 3:")) nomec3 = input("Informe o nome do corretot 3:") totalVendas = c1 + c...
826386c4522e2ac91ff199fde7b1000984568473
diegorafaelvieira/Programacao-1
/Aula 02/ListaDeExerciciosExtra/Lista15.py
596
4.03125
4
valor = float(input("Informe o valor da hora trabalhada R$:")) hora = int(input("Informe o números de horas trabalhadas no mês:")) salarioBruto = valor * hora ir = salarioBruto * 0.11 inss = salarioBruto * 0.08 sindicato = salarioBruto * 0.05 salarioLiquido = (salarioBruto - (ir + inss + sindicato)) print ("O salár...