blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
fa94be8d11690dbfdb2bdf05a6a0d08bd80b0694
mukesh-jogi/python_repo
/Sem-5/Conditional Statements/ifcondition.py
193
3.71875
4
# Indentation v = -50 if v < 0: print("Value is negative") else: print("Value is not negative") print("This is second line") print("This is third line") print("End of program")
b95829b214316a5bf7343c3f821d9543b96c9d42
mukesh-jogi/python_repo
/Sem-6/numpy/bitwiseor.py
182
3.59375
4
import numpy as np a = 10 print("binary representation of a:",bin(a)) b = np.invert(a) print("binary representation of c:",bin(b)) print("Bitwise-and of a and b: ",b)
3ee9a1d5a4a46c637818f5ad1ff4e3ba05783088
mukesh-jogi/python_repo
/Sem-6/numpy/bitwiseand.py
244
3.515625
4
import numpy as np a = 15 b = 14 print("binary representation of a:",bin(a)) print("binary representation of b:",bin(b)) c = np.bitwise_and(a,b) print("binary representation of c:",bin(c)) print("Bitwise-and of a and b: ",c)
4b25119f29299efe1c9a60553790c5563464db06
mukesh-jogi/python_repo
/Sem-5/OOP/overriding.py
496
3.84375
4
class A: def __init__(self,firstname,lastname): self.fname = firstname self.lname = lastname def printname(self): print(self.fname,self.lname) class B(A): def __init__(self,firstname,middlename,lastname): self.middlename = middlename super().__init__(firstname,l...
28aa918bff12bcde92fd906dea693da87e9f45fe
mukesh-jogi/python_repo
/Sem-5/try_except/multiple_except.py
407
4.09375
4
try: num1 = int(input("Enter any number : ")) num2 = int(input("Enter any number : ")) num3 = num1 / num2 print("Answer is ",num3) except ValueError: print("Invalid input") except ZeroDivisionError: print("Second value can not be zero") except: print("Other error") else: print("No Errors...
8335a312e8d204b7a539e36f66985f9f0da80ecb
mukesh-jogi/python_repo
/Sem-6/numpy/min-max-sum.py
498
3.984375
4
import numpy as np # a = np.array([1,2,3,10,15,4]) # print("The array:",a) # print("The maximum element:",a.max()) # print("The minimum element:",a.min()) # print("The sum of the elements:",a.sum()) import numpy as np a = np.array([[1,2,30],[10,15,4]]) print("The array:",a) print("The maximum elements...
ce913eb76bc3f5ca5fdede86abd6cb9080d2ec34
mukesh-jogi/python_repo
/Sem-5/strings/stringasarray.py
61
3.515625
4
s1 = "I love India" for i in range(len(s1)): print(s1[i])
c4c752e7213150b873b817bd106c4a6d77d39efb
mukesh-jogi/python_repo
/Sem-5/RegularExpression/re2.py
463
3.625
4
import re fp = open("data.txt","r") data = fp.read(); result = re.findall("\d{10}",data) print(result) result = re.findall("\d{2}[-|/]\d{2}[-|/]\d{4}",data) print(result) result = re.findall("[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-..]+",data) print(result) import re txt = "I love my India, India is my country, ...
e321759c85fa184f7fdb08811827a36faadc8317
mukesh-jogi/python_repo
/Sem-5/Collections/Set/set1.py
1,960
4.375
4
# Declaring Set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} print(set1) # Iterate through Set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} for item in set1: print(item) # Add item to set set1 = {"Apple","Banana","Cherry","Mango","Pinapple"} set1.add("NewFruit") for item in set1: print(item...
e2ea5e9760291b121ecbc69b466559e71e8af6c4
mukesh-jogi/python_repo
/Sem-5/Operators/in_operator.py
143
3.84375
4
lst = [10,50,60,45,1,2,-2] sv = 500 if sv in lst: print("Search value is in the list") else: print("Search value is not in the list")
a364ea4e9b6beb7ebd0f069ec6b894dd043042e0
sumeyyekaratekin/GlobalAIHubPythonProjects
/homework_1.py
745
4.0625
4
#Global AI Hub Python Course Homework - 1 #Sümeyye Karatekin value1 = input("string bir deger giriniz : ") print(f"Girilen deger : {value1}\t girilen degerin veri tipi : {type(value1)} ") value2 = int(input("integer bir deger giriniz : ")) print("Girilen deger {}\t girilen degerin veri tipi : {}".format(value2, type...
e15cb899e299eb06603272affbde3e8e37e31dd1
saanghyuk/python_django_study
/Codeit/Python_Basic/number_operations.py
741
4.0625
4
print(4+7) print(2-4) print(5*3) print(7%3) print(2**3) print("---------------------") #floor division, 버림나눗셈 print(7//2) print(8//3) #round print("=====================") print(round(3.142194124)) print(round(3.142194124, 2)) #String print("=====================") print("코드잇") print("Hello"+" World") print("I\'m \...
a6885c761cbf2d54c530a8a114c7782dabb2631b
Karolina-Wardyla/Practice-Python
/list_less_than_ten/task3.py
400
4.15625
4
# Take a random list, ask the user for a number and return a list that contains only elements from the original list that are smaller than the number given by the user. random_list = [1, 2, 4, 7, 8, 9, 15, 24, 31] filtered_numbers = [] chosen_number = int(input("Please enter a number: ")) for x in random_list: if...
3b6824ea991b59ccd05b3d42f872c5e8d1313d4a
Karolina-Wardyla/Practice-Python
/divisors/divisors.py
522
4.34375
4
# Create a program that asks the user for a number and then prints out a list of all the divisors of that number. # Divisor is a number that divides evenly into another number. # (For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) chosen_number = int(input("Please enter a number: ")) possible_diviso...
421c1836ee61613bfade7090aa897d20e670865f
Karolina-Wardyla/Practice-Python
/list_overlap/task2.py
551
4.03125
4
# Take two random lists and write a program that returns a new list that contains only the elements that are common between the given lists (without duplicates). # Make sure your program works on two lists of different sizes. # Sort numbers in a new list. list1 = [10, 71, 22, 3, 5, 8, 13, 21, 55, 89, 19, 34, 14, 28, 3...
44a11337e51d833f47004aea2763fc8f96927437
shaoy001/zwj001
/day04/文件与文件模式介绍.py
5,073
3.65625
4
# coding:utf-8 # 1、如何用文件:open() # 控制文件读写内容的模式:t和b # 强调:t和b不能单独使用,必须跟r/w/a连用 # t文本(默认的模式) # 1、读写都以str(unicode)为单位的 # 2、文本文件 # 3、必须指定encoding='utf-8' # b二进制/byte # 控制文件读写操作的模式 # r 只读模式 # w 只写模式 # a 只追加写模式 # +:r+、w+、a+ # 1、打开文件 # open('C:/a/b/c') # open(r'C:\a\b\c') # 推荐 # 2、文件类型 # f的值是一种变量 # f = open('file1',encoding='...
c58f620b8cea937edfe7e7b1141971d826fc54c6
shaoy001/zwj001
/day01/base_learn.py
1,935
3.625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Author : Ayden Lee Date : 06/27/2020 Desc : Change LOG : """ # for i in range(1, 9, 2): # if i == 5: # continue # for j in range(5): # print(i, j) # print('hello', end='*') # print('world') # # age = 10 # print(id(age), typ...
e84311e2aabbc468687c4c619b75a31f226d06f5
KimNamjoon/repmon
/hw3/programming_hw3_im_anna.py
269
3.953125
4
w = input("Введите слово: ") ##w - word, список я не использовала, т.к. в условии просят выводит не элементами, а цельными кусками слова for i in range(len(w)): print(w[:i+1])
0300e80274211bce55e6b5f0c11b8f4404e83c45
KimNamjoon/repmon
/hw14/hw14.py
681
3.578125
4
import re def prepare(): with open('text.txt', encoding='utf-8') as f: text = f.read() parts = re.split('[.!?…]+', text) clean_parts = [re.sub('[,:;—–­()&“”«»/*\"\'\n]', '', part) for part in parts] return clean_parts def searching(clean_parts): for clean_part in clean_parts: words...
df3a670513867f8163f779d22328a1eba4d10caf
AllaKutina/lesson2
/exception2.py
1,197
4.09375
4
""" Домашнее задание №1 Перепишите функцию discounted(price, discount, max_discount=20)из урока про функции так, чтобы она перехватывала исключения, когда переданы некорректные аргументы (например, строки вместо чисел). """ def discounted(price, discount, max_discount=20): try: if(not type(price) is int or...
fe7bd34314af0b07172576844c53d2f1560493ae
Skuzzzy/graveyard
/ryry4u/parse_test.py
1,816
3.609375
4
import unittest from parse import label, numerical class TestParse(unittest.TestCase): def test_label_operator_plus(self): expected = ('+', 'OPERATOR') result = label('+') self.assertEqual(expected, result) def test_label_operator_minus(self): expected = ('-', 'OPERATOR') ...
0fcfd16f975cb57bc5d2b5ee8d04a63cbf9a9fae
kapil-vyas/elements
/python/merge_lines.py
718
3.734375
4
# lines that do not start with a token, say "Begin" # need to be merged with previous line that begins with token import sys def parse(in_file, token): handle = open(in_file, 'r') output = open('parsed.out', 'w+') prev_line = "" lines = handle.readlines() i = 0 while i < len(lines): c...
1321a894a55643ba0cd693e10239d7035e6eae6f
HugoPorto/PythonCodes
/codility/prime.py
218
3.75
4
q = input() a,b = raw_input().split(' ') def is_prime(a): return all(a % i for i in xrange(2, a)) print 1 for i in range(2, q): for j in range(int(a), int(b)): if is_prime(j): print j
b650d685931f3eac9e523239ef90d31857350f87
HugoPorto/PythonCodes
/CursoPythonUnderLinux/Aula0028ForIn/ForIn.py
116
3.78125
4
#!/usr/bin/env python # -*- coding:utf8 -*- texto = raw_input("Digite um texto: ") for letra in texto: print letra
06f1799f54bc2cf938b987f7ac44ce3dae138562
HugoPorto/PythonCodes
/codility/unpaired.py
109
3.53125
4
a = [0,0,1,1,2,2,3] def solution(A): for i in A: var = i if (A.count(i) <=1) print solution(a)
cfb27a2ed6831016afb5ff1215eeb920d03a23f8
HugoPorto/PythonCodes
/Trabalhos/Rot13/TestaRot13.py
2,425
3.984375
4
#!/usr/bin/env python # coding: utf-8 # Importando as funcoes do arquivo que tem todas as funcoes (Funcao.py) from Funcao import Rot13 # Execucao inicial # Aqui estamos montando o menu que sera mostrado para o usuario MENU = """ 1 - Para testar com Dicionarios{}\n 2 - Para testar com Listas[]\n 3 - Para testar com...
74d796b056647055de34931429b50eb2eff50643
HugoPorto/PythonCodes
/PythonZumbis/lista4/questao04.py
562
3.65625
4
lista = """ The Python Software Foundation and the global Python community welcome and encourage participation by everyone Our community is based on mutual respect tolerance and encouragement and we are working to help each other live up to these principles We want our community to be more diverse w...
56fcbf843fd7171d47538c38a7bb6c7af82cc998
HugoPorto/PythonCodes
/CursoIntermediarioPythonDjango/OO/11 - ClasseConcreta.py
578
3.71875
4
# encoding: utf-8 __author__ = 'gpzim98' from abc import ABCMeta, abstractmethod class ClasseAbstrata(object): __metaclass__ = ABCMeta @abstractmethod def meu_metodo_abstrato(self): print 'My abstract method' class ClasseConcreta(ClasseAbstrata): def meu_metodo_abstrato(self): prin...
e8acc631c63ef1be8ff77aab5dc1ddf72f92eabe
HugoPorto/PythonCodes
/CursoPythonUnderLinux/Aula0017IfElse/IfElif.py
222
3.796875
4
#!usr/bin/env python #-*- coding:utf8 -*- a = raw_input() if a > 0: print 'Você digitou um número positivo' elif a < 0: print 'Você digitou um número negativo' else: print 'Você digigou o número Zero (0)'
5bf4a3b018d1ec02e5dc007da9e8ad0d7758c02b
HugoPorto/PythonCodes
/CursoPythonUnderLinux/Aula0028ForIn/ForInComLisa.py
578
4.125
4
#!/usr/bin/env python # -*- coding:utf8 -*- cont = 1 lista = [] while cont <= 6: lista.append(input("Digite qualquer coisa: ")) cont = cont + 1 print lista for item in lista: if (type(item) == int): print 'Item inteiro: %d' % item elif (type(item) == str): print 'Item string %s ' % item elif (type(item) ==...
0895fb38db2d666ca7523a8b47c1d553d317d9da
wangli02025/sandbox
/simanneal.py
5,119
3.578125
4
#!/usr/bin/env python # http://www.theprojectspot.com/tutorial-post/simulated-annealing-algorithm-for-beginners/6 # http://www.psychicorigami.com/2007/06/28/tackling-the-travelling-salesman-problem-simmulated-annealing/ import argparse, sys, random, math from argparse import RawTextHelpFormatter __author__ = "Autho...
0a43c57a016eb641a07c8f0e2ed16080da2866b2
Aaron-Nazareth/Code-of-the-Future-NumPy-beginner-series
/6 - Basic operations on arrays.py
707
4.5
4
# Tutorial 6 # Importing relevant modules import numpy as np # We can create an array between numbers like we can do with lists and the 'range' command. # When using arrays, we use the 'arange' command. a = np.arange(0, 5) # Creates an array from 0 up to 5 - [0 1 2 3 4] print(a) # Basic math operations on arrays b ...
078332068db32e5c9a8744682c58f1e8c93aa144
JustinD724/Random-Scenario
/random_scenario.py
11,195
4.15625
4
while True: ###------------RANDOM_SCENARIO_GENERATOR---------------#### #an unending matrix of possible solutions, scenarios, outcomes for the past, present, and future. #based on an idea that we may ourselves be living in a matrix or advanced computer simulation. print('\n') print("####...
18bded8b1595fb531dbda8b236c335a0dc8e6c33
ApnaSoftware/ApnaAutomizer
/modules/library/valid_hoare.py
5,694
3.578125
4
def find_var_with_time(formula, variable): start=formula.find(variable+"_") if(start==-1): return "error" # if(start==-1): # start1=formula.find(variable+" ") # start1=formula.find(variable+")") # if(start1==-1): # start=start2 # elif(start2==-1): # ...
440f0d05fb7ffc172d779a61496dbad629254e68
adamreis/puzzles
/reverse_binary.py
577
3.546875
4
__author__="Adam Reis <ahr2127@columbia.edu>" __date__ ="$Nov 3, 2013" from sys import stdin def reverse_binary(): """ Reverses a single integer read from stdin in binary and prints the result to stdout in the fashion described here: https://www.spotify.com/us/jobs/tech/reversed-binary/ (base_10 input -> bina...
1672647fc0453c4716981e89a188e47071856fcb
FelipeToshio/Sd_Trontry
/Old/tron1.py
3,907
3.65625
4
from turtle import Turtle, Screen class tron(): def set_screen(): screen = Screen() screen.bgcolor('black') return screen def up(who): global previousMove turtle, path = players[who] turtle.setheading(90) if previousMove != 'up': path.append...
24f1470aefca7f62d0d6ead3bc7d69b0077ddf90
brillantescene/Coding_Test
/Programmers/High-Score_Kit/BruteForce/find-prime.py
574
3.8125
4
# 완전탐색 level 2 소수찾기 from itertools import permutations import math def isPrime(n): if n < 2: return False for i in range(2, int(math.sqrt(n))+1): if n % i == 0: return False return True def solution(numbers): answer = 0 result = [] for i in range(1, len(numbers)+...
8779b26a4c2d5c571166f36d428bee69c72b35f8
brillantescene/Coding_Test
/BOJ/No_10828_timeover2.py
803
3.84375
4
class stack: def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): if self.isEmpty(): return -1 return self.items.pop() def isEmpty(self): return not self.items count = int(input()) stk =...
05823c1178751d2defd02fc52b25d9bf36916a16
brillantescene/Coding_Test
/LeetCode/most-common-word.py
427
3.59375
4
import re import collections class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: paragraph = "Bob hit a ball, the hit BALL flew far after it was hit." banned = ["hit"] words = [word for word in re.sub( '[^\w]', ' ', paragraph).lower().split() if word not in banned] counts =...
dc77e64af3aeb1b72e5593124ee18b9fefa15bcb
brillantescene/Coding_Test
/Programmers/High-Score_Kit/stack-queue/printer.py
383
3.6875
4
from collections import deque def solution(priorities, location): q = deque([(idx, p) for idx, p in enumerate(priorities)]) answer = 0 while q: j = q.popleft() if any(j[1] < x[1] for x in q): q.append(j) else: answer += 1 if j[0] == location: ...
b9d83eaf3ee426bc531064aec51ddc7e79aa0fa7
brillantescene/Coding_Test
/Programmers/Level1/make-prime.py
417
3.625
4
import math def is_prime(num): for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: return False return True def solution(nums): cnt = 0 for i in range(len(nums)-2): for j in range(i+1, len(nums)-1): for k in range(j+1, len(nums)): sum ...
32390e98caeb7608c2a6ccb0e3bc3e10e242e43c
brillantescene/Coding_Test
/BOJ/No_9012_stackX.py
459
3.5625
4
t = int(input()) for _ in range(t): left, right = 0, 0 testdata = input() for i in range(len(testdata)): if testdata[i] == '(': left += 1 elif testdata[i] == ')': right += 1 if left == right: left, right = 0, 0 elif left > righ...
abbd47864534e590ccfd9494128a819331533526
brillantescene/Coding_Test
/BOJ/No_11720.py
115
3.890625
4
sum = 0 count = int(input()) number = list(input()) for num in number: sum = sum + int(num) print(sum)
cddd9a913c63a6d393b3f7318af180f410f58133
brillantescene/Coding_Test
/LeetCode/Graph/subsets.py
773
3.515625
4
# check 없는 방법 class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: result = [] def dfs(index, path): result.append(path) for i in range(index, len(nums)): dfs(i+1, path+[nums[i]]) dfs(0, []) return result ''' class Soluti...
1829554fba90c2d4166c1970f7857173202a72d0
davisarthur/Kattis
/Four.py
1,099
3.609375
4
# Davis Arthur # 10-10-2019 def convert(operand): if operand == 0: return " + " if operand == 1: return " - " if operand == 2: return " * " if operand == 3: return " // " # variables operandSets = [] answerEqs = [] # generate all operand combinations for i in range(4):...
7d3c2fa11f744516a2cdd92148709792a629e231
ZackHolmberg/4190-a2
/objects/key_iterator.py
2,819
3.5625
4
""" Course: COMP 4190 Instructor: Cuneyt Akcora Assignment 2 Submission by: Yaroslav Mikhaylik, 7853156 Zack Holmberg, 7777823 File purpose: A class that generates keys to index into a factors' dictionary, which contains the probabilistic values. Keys represent rows in a CPT, so one key may equal "+T,-R...
f9b4498a1161648eafeacab241ccae3ea43620d3
greitzmann/LAPOS
/pos-tagging/readPickle.py
405
3.515625
4
import pickle import argparse def main(): parser = argparse.ArgumentParser(description='Sample code to read pickle file') parser.add_argument('--pickle-file', help='Input pickle file', required=True) args = parser.parse_args() print 'Reading file' f = open(args.pickle_file, 'rb') dataStructure = pickle.load(f)...
766fbe896ae33ec51c1c6a73ac038122dbd92400
mibmol/dscc
/monolit_cache_docker/users/utils/password_generator.py
512
3.578125
4
import random import string def getPassword(): minus = 4 mayus = 4 numeros = 2 longitud = minus + mayus + numeros run = True while run: caract = string.ascii_letters + string.digits contra = ("").join(random.choice(caract) for i in range(longitud)) if(sum(c.islower() f...
14bc4dc59b0edbbdbd121924793d60506a7e01d9
jamesfebin/company_full_contact
/read_records.py
464
3.890625
4
import csv import requests import json #Example Parsing JSON BACK def read_csv_input(): try: filename = raw_input("Please enter input file name you want parse json records ") with open(filename) as csvfile: reader = csv.DictReader(csvfile) for row in reader: record = row['Records'] company = ...
ede8a710ea563aa8b8bf8ff1e453ff848857bb37
mikaph/advent-of-code-2017
/day12.py
853
3.515625
4
import random input_file = open('input12', 'r').read().splitlines() parsed_input = [list(x[x.find('>') + 1:].split(',')) for x in input_file] the_group = set([0]) searched_lines = set([]) not_searched = set([]) not_searched.update(range(len(parsed_input))) def add_connections(value): searched_lines.add(int(value...
4baea18d287badc1c6dd3c051c07689a17cd4263
newmanjb/DigestiveSystem
/com/noomtech/building_blocks/BuildingBlocks.py
2,706
3.953125
4
from abc import ABC, abstractmethod from time import sleep import threading """The higher level objects used to form the components of the body""" #todo -- add synchronization to multithreaded functionality class Producer(ABC): """Producer is anything that produces an object that can be transported or...
b1b17773696b406c5682d1ad6549aad66789e111
Elizabethcase/unitconvert
/unitconvert/temperature.py
1,020
4.25
4
def fahrenheit_to_celsius(temp): ''' Input: temp: (float) - temp in fahrenheit Returns: temp: (float) - temp in celsius ''' celsius = (32.0 - temp)*(5.0/9) return celsius def celsius_to_fahrenheit(temp): ''' Input...
9519d25c32ac136ff355e521e4bf36dc80eee71b
meghasundriyal/MCS311_Text_Analytics
/stemming.py
609
4.3125
4
#stemming is the morphological variants of same root word from nltk.tokenize import word_tokenize from nltk.stem import PorterStemmer ps = PorterStemmer() #words to be stemmed (list) stem_words = ["eat", "eats", "eating", "eaten", "eater", "received","receiving"] #find stem word for each of the word in the list for ...
2960db7dd34d4a578dc94d92453689ac1ae0775e
pobiedimska/python-laboratory
/laboratory1/task2.py
1,804
3.5625
4
""" До фіналу конкурсу кращого за професією «Спеціаліст електронного офісу» були допущені троє: Іванов, Петров, Сидоров. Змагання проходили в три тури. Іванов в першому турі набрав t1 балів, у другому - n1, в третьому - p1. Петров - t2, n2, p2 відповідно; Сидоров - t3, n3, p3. Скласти програму, що визначає, скільки...
b968ea71ca11e907758c402424ae3f7437332fbf
Reena-Kumari20/code_war
/Are arrow functions odd?.py
176
3.671875
4
def func(list): x=[] i=0 while i<len(list): if list[i]%2!=0: x.append(list[i]) i=i+1 return x list=[2,7,8,6,9,4,3] print(func(list))
9937cae75d06147093025d2482225550aace9f9a
Reena-Kumari20/code_war
/Reversed_Words.py
213
4.1875
4
# Complete the solution so that it reverses all of the words within the string passed def reverse_words(s): a=(' '.join(s.split(" ")[-1::-1])) return a string=["hell0 world!"] print(reverse_words(string))
8b99f60f51da55d805fcfdd13bf0e34bc71b8386
Reena-Kumari20/code_war
/sum_of_string.py
586
4.1875
4
'''Create a function that takes 2 positive integers in form of a string as an input, and outputs the sum (also as a string): Example: (Input1, Input2 -->Output) "4", "5" --> "9" "34", "5" --> "39" Notes: If either input is an empty string, consider it as zero.''' def sum_str(a, b): if a=="" and b=="": ...
bfc0067aeac80916b8a3ebda365f913a37c6d392
ratanhodar/data-py
/2/Activities/08-Stu_ReadNetFlix/Untitled-1.py
785
3.65625
4
import os import csv title = [] rating = [] score = [] path_of_file = os.path.join('Resources', 'netflix_ratings.csv') with open(path_of_file) as csvfile: csvreader = csv.reader(csvfile, delimiter=',') print(csvreader) csv_header = next(csvreader) print("CSV Header: " + str(csv_header)) for row...
a984524e644e530145a0f54a9c14fe7e6d42f3df
Xaintailles/Exercices
/queue_implementation.py
1,187
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 19 17:38:19 2021 @author: Gebruiker """ """ This problem was asked by Apple. Implement a queue using two stacks. Recall that a queue is a FIFO (first-in, first-out) data structure with the following methods: enqueue, which inserts an element into the queue, and deque...
bcd1be094afbf358e213421c7877f7352837f08e
sucomaestre/Learning
/Calculator.py
129
3.796875
4
num1 = raw_input( "Enter first number ") num2 = raw_input( "Enter second number ") result = float(num1)+float(num2) print(result)
822f13df89ee7e5ff0bd870f3427facd3afb36f7
jatimberlake2/CS250
/pb.py
1,015
3.84375
4
import sys class Phonebook: #Method (constructor) def __init__(self): self._entries = [] #private #methods (mutator) def add_entry(self, name, number): self._entries.append([name, number]) #accessor/query methods def lookup(self, name): for entry in self._entries: if entry[0] == name: return entry[1...
3e3bf6acf0a419f22235b6bdd43ca478b65794b3
standrewscollege2018/2020-year-11-classwork-bfo1056
/hello world.py
176
3.96875
4
hello="hello" name="john" last_name="smith" print(hello, name , last_name) age=18 print("you are", age, "years old") fav_animal= input("what is your favorite animal?")
a8f1686e91d5d88daa6d7c91644b2e872923367e
Sudhakaran7/Ruby_Dictionary
/Ruby_dictionary.py
525
3.796875
4
import collections class MagicDictionary(object): def __init__(self): self.buckets = collections.defaultdict(list) def buildDict(self, words): for word in words: self.buckets[len(word)].append(word) def search(self, word): return any(sum(a!=b for a,b in zip(word, candid...
42a745d8a69bf7348ac0887de7b681d76cb715b0
pyvonpyton/drugspend
/python/datawrangling/cms-openpayment/general_payment_process_manufacturer.py
5,290
3.53125
4
""" This script attempts to create a canonical name for the names of the manufacturers and GPOs. The script first checks whether the mapping between ID and name/state/country information is consistent, then converts the names into a canonical form and outputs a csv containing this information. Inconsistency in raw da...
ba78a09029166d422c3d08e2067cbc23065be99a
totalwar235/linear
/Linear_Mul/main.py
494
3.890625
4
import header import util import func #main program starts print("this is for linear systems") matrixes = [] end = 0 while end != 1: #main loop print("1) quit") print("2) add matrix") print("3) print a matrix") print("4) test") op = input("enter operation number: ") #operations if op == '1': end = 1 elif op...
eefb70d55ebb5195d73c40617a3f5ea111ebb7d5
Rakib126/online-course-reg-system
/project.py
12,848
3.828125
4
import json def read_from_file(): try: file = open("student.json", "r") file_content_as_text = file.read() students = json.loads(file_content_as_text) file.close() return students except : return [] def write_to_file(student): file = open("stu...
a95b20e39f2f4dbb66b8f231ea556a934fc2c8eb
snowgoon88/CozmoBot
/harriscorner.py
9,290
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Detect corners using C. Harris and M. Stephens 1988 # see https://medium.com/data-breach/introduction-to-harris-corner-detector-32a88850b3f6 # Pseudo code # 1.Take the grayscale of the original image # 2. Apply a Gaussian filter to smooth out any noise # 3. Apply Sobel ...
62aff43415c9f3161e8e2adeea63d240e7986a44
marloncalvo/PODG-Analysis
/analysis.py
8,220
3.546875
4
import random import re from functools import reduce import heapq common_words = { "the", "of", "to", "and", "a", "in", "is", "it", "you", "that", "he", "was", "for", "on", "are", "with", "as", "I", "his", "they", "be", "at", "one", "have", "this", "from", "or...
5a13aa95094af2a7281a31049390c272405b194c
NishanthMHegde/DeepLearingProjects
/Self_Organizing_Maps/som.py
6,771
4.15625
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd from pylab import bone, colorbar, plot, show, pcolor from sklearn.preprocessing import MinMaxScaler from minisom import MiniSom """ What is a self organizing map? SOM is a grid of nodes where each of the the node is color coded and represents ...
1f9d67ff1355d352b80ef88b60fab98f40f3b9e1
NikitaSmol67/homeWork-1
/homework_6.py
4,960
3.734375
4
# Exercise 1 from time import sleep class TrafficLight: __color = ['Красный', 'Желтый', 'Зеленый'] def running(self): i = 0 while i < 3: print(f'Светофор переключается \n ' f'{TrafficLight.__color[i]}') if i == 0: sleep(7) ...
301a64567164a85abdef442a8672c985776a87e0
jreichardtaurora/hmwk_2_test
/HW2_Prob_1_JaredReichardt.py
1,398
4.3125
4
''' Created on Sep 13, 2019 @author: jared r CSC1700 section AM The purpose of this problem was to write a calculator that calculates the user's total shipping cost. It handles negative inputs properly, and prompts the user for their package weight, and what type of shipping they used. ''' def main(): print("Sta...
15f6a28c1c394a1b10bbfd9c5fcdfc00ac891b1b
JGrundyHudd/SoftDesDevProgramming
/CelsiusToFahrenheit.py
152
4.125
4
celsius = input('Please enter a temperature in celsius followed by the unit "C": ') print(celsius + ' is ' + str(float(celsius[:-1]) * 1.8 + 32) + 'F')
7b64c622c5166b7c8b29fcae9455c92124e0ddb0
petrperovsky/lesson08
/ex01.py
1,020
4
4
''' Надеюсь, я правильно понял, что по "этикету" мне не понадобится отдельно запрашивть @classmethod, т.е. оперирую им внутри класса''' class Date: def __init__(self, date: str): day, month, year = self.transform(date) self.day = day self.month = month self.year = year if n...
50484b73b2656360580ee39e48cbd2240fec0ee2
renatocrobledo/probable-octo-spork
/path_counter.py
1,503
3.84375
4
''' Having a matrix n x n, starting point from top-left and end bottom-right we want to count all the possible paths to reach the end so posible moves are right down S o o o o o o o o o o x o x o o x o o o o o o o E S = start E = end o = possible step field x = block ''' from collecti...
88b954e1465b806c15318999a4715c0e6c7d7cc4
renatocrobledo/probable-octo-spork
/codingame/src/norm_calculation.py
1,538
4.65625
5
''' You are given an integer matrix of size N * M (a matrix is a 2D array of numbers). A norm is a positive value meant to quantify the "size/length" of an element. In our case we want to compute the norm of a matrix. There exist several norms, used for different scenarios. Some of the most common matrix norms are : ...
a624e721dbe9426390922b420d7ebf565f67331c
renatocrobledo/probable-octo-spork
/poison_bottles.py
2,243
3.953125
4
''' You have 1000 bottles of soda, and exactly one is poisoned. You have 10 test strips which can be used to detect poison. A single drop of poison will turn the test strip positive permanently. You can put any number of drops on a test strip at once and you can reuse a test strip as many times as you'd like (as long a...
60a420580a9e70e8a723096437ba76af8800ea73
renatocrobledo/probable-octo-spork
/data_structures/doubly_linked_list.py
1,109
4.09375
4
class Node: def __init__(self, value): self.value = value self.prev = None self.next = None class DoublyLinkedList: def __init__(self): self.root = None def print(self): actual_node = self.root result = [] while actual_node.next and actual_node.next != self.root: result....
0cc8b1788de765be64682b98edb831b0442f490c
renatocrobledo/probable-octo-spork
/fibonacci_experiment.py
230
3.90625
4
def add(n): if n == 1: return 1 return n + add(n - 1) def fib(n): if n == 1 or n == 0: return n return fib(n - 1) + fib(n - 2) print(add(5)) # 5 + 4 + 3 + 2 + 1 = 15 print(fib(5)) # 5
b063425e6e7ae6b3f676bde163305b2f9308a4cb
renatocrobledo/probable-octo-spork
/hanoi_towers.py
3,652
3.5
4
from collections import defaultdict import datetime def benchmark(f): def inner(*args, **kwargs): start_time = datetime.datetime.now() f(*args, **kwargs) end_time = datetime.datetime.now() time_diff = (end_time - start_time) print(f'{f.__name__} ->', time_diff.total_secon...
4aee35b998a58a307f6d35bae325ddf1c1f81108
renatocrobledo/probable-octo-spork
/collections.py
1,064
4.03125
4
''' collections ides some useful enhancements to tuples, list & dictionaries ''' import collections def collection_counter(): example = 'A B B C D D D A B C C C' c = collections.Counter(example) print(c) # Counter({' ': 11, 'C': 4, 'B': 3, 'D': 3, 'A': 2}) ''' if there's no key in a 'normal' dictio...
4fef59f6780b0ac8c43ed9811c812b6d46924c39
adityaaggarwal19/Python-Code
/duplicate_char_in_string.py
226
3.53125
4
def dup_char(s): l=[] l=set(l) for i in range(0,len(s)-1): if s[i]==s[i+1]: l.add(s[i]) l=list(l) for i in range(0,len(l)): print(l[i],end=" ") dup_char("aabbccdddee")
e33d126b42f6a7889e6c878904d9545ae27fc36a
adityaaggarwal19/Python-Code
/Bubble_Step.py
339
3.8125
4
def bubbleStep(lst,index,i=-1,j=-1): if j==index: return lst else: if i==-1: i=len(lst)-1 j=i-1 if lst[i]<lst[j]: temp=lst[i] lst[i]=lst[j] lst[j]=temp return bubbleStep(lst,index,i-1,j-1) print(bubbleStep([1...
68e5f703297633b3b530d5d76a36887cbe85eae8
adityaaggarwal19/Python-Code
/day_of_programmer_HR.py
849
3.515625
4
#!/bin/python3 import math import os import random import re import sys # Complete the dayOfProgrammer function below. def dayOfProgrammer(year): res="" if year<1918: if year%4==0: res="12.09."+str(year) else: res="13.09."+str(year) elif year>1918: ...
683c04045dcb023ecaaec10c3d64db5ffc73e83f
adityaaggarwal19/Python-Code
/Recursive_digit_sum_HR.py
621
3.5
4
#!/bin/python3 import math import os import random import re import sys # Complete the superDigit function below. def superDigit(n, k): n=str(n) a="" for i in range(0,k): a=a+n a=int(a) while a>9: a=supSum(a) return a def supSum(p): if p>=0 and p<=9: ...
c24e9dd3f7f9d22f830f767bcad92bb268fa04ba
adityaaggarwal19/Python-Code
/find_digits_HR.py
555
3.609375
4
#!/bin/python3 import math import os import random import re import sys # Complete the findDigits function below. def findDigits(n): count=0 i=n while i>0: x=i%10 if x!=0 and n%x==0: count=count+1 i=i//10 return count if __name__ == '__...
be76c33e6aac835fe63d86d321fa11a230cd021f
haowen-xu/tfsnippet
/tfsnippet/dataflows/base.py
14,107
3.53125
4
import numpy as np __all__ = ['DataFlow', 'ExtraInfoDataFlow'] class DataFlow(object): """ Data flows are objects for constructing mini-batch iterators. There are two major types of :class:`DataFlow` classes: data sources and data transformers. Data sources, like the :class:`ArrayFlow`, produce...
a6ab8793c87ce514b267f51b7451b37abcb3e32e
DariaMikhailovna/Algorithms
/DP/barn/small.py
1,149
3.609375
4
def main(): def calc(): max_square = 0 for nn in range(n): for mm in range(m): new_square = find_max_square(nn, mm) if new_square > max_square: max_square = new_square return max_square def find_max_square(nn, mm): ...
e17968afe10fee2874f224355babb2046fcc8082
DariaMikhailovna/Algorithms
/Hash/binary_object_tree.py
2,642
3.796875
4
from typing import Optional class Node: def __init__(self, key=None, value=None, left=None, right=None): self.key = key self.value = value self.left = left self.right = right class BinaryTree: def __init__(self): self._root: Optional[Node] = None def __iter__(sel...
3e4b5368adbdc26b9a6b1a60483f6cab3c4ebd70
DariaMikhailovna/Algorithms
/Sorting/quick_sort.py
783
3.65625
4
import random def partition(arr, left, right): num = random.randint(left, right - 1) # num = left # num = right - 1 # num = (left + right) // 2 p = arr[num] arr[num], arr[right - 1] = arr[right - 1], arr[num] i = left j = left while j < right: if arr[j] > p: ...
4f0f9c8d2d749a8ade298a8f6c70a5c66a4cfdd0
kundan7kumar/Algorithm
/SearchInsertPosition.py
745
4.0625
4
""" Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. return len([x for x in nums if x<target]) class Solution: ...
88963ec18f118fca69d3e26b3b57db8c5a2736cc
kundan7kumar/Algorithm
/Hashing/basic.py
476
4.1875
4
# Python tuple can be the key but python list cannot a ={1:"USA",2:"UK",3:"INDIA"} print(a) print(a[1]) print(a[2]) print(a[3]) #print(a[4]) # key Error # The functionality of both dictionaries and defualtdict are almost same except for the fact that defualtdict never raises a KeyError. It provides a default value fo...
e7c65b7c3d9b948dce5964081eae9f847f8393de
cadenclaussen/battle
/Mob.py
1,034
3.6875
4
import random class Mob(): name = "" health = 0 initial_health = 0 heal_multiplier = 0 attacks = {} def __init__(self, name, health, heal_multiplier): self.name = name self.health = health self.initial_health = health self.heal_multiplier = heal_multiplier ...
d3b0362d92ee945a68bcbb045f806b8bd1a354d1
RamkumarChandrasekar/Python
/QueenProgram.py
2,198
3.9375
4
# -*- coding: utf-8 -*- """ Created on Fri Jul 3 17:37:23 2020 @author: 687079 """ import random def assign_list(): i=1 list1=[] while i<=64: list1.append(i) i=i+1 return list1 def remove_list(list1,val1): for l in list1: if(l==val1): list1.remove(l) r...
7af320a9e544b616d143fdc0f9b913d6ed51aff9
phoxelua/matcha
/matcha/lib/utils/lazy.py
7,068
3.796875
4
import functools import inspect from threading import Lock import weakref class Lazy: """ Descriptor for values to be loaded lazily. Note: Instances of the new Lazy class must be a class variable; it's implemented as a descriptor, which only work as class variables. 1) The patterns for Laz...
c595246a53e00cd4008f5c112bcb4dd8e2a992f8
omarsagoo/animal-classifier
/main.py
16,604
3.984375
4
import csv from pprint import pprint class Clasifier: """Decision tree that goes through a csv file and makes predictions based on the set of attributes.""" def __init__(self, filename): # takes in a csv file name as a parameter and stores it. # instantiate the header as an empty list. the hea...
1b7667023653fbc7c70b6464e60c7c25996ebec4
S-a-k-s-h-i/100_days_with_python
/Day-001-i/Armstrong.py
244
4.0625
4
number=int(input("Enter the no: ")) test=number sum=0 while test: n=test%10 sum=sum+pow(n,3) test=test//10 if sum==number: print("{} is an Armstrong no".format(number)) else: print("{} is not an Armstrong no".format(number))
b82db28469b1b40392d1dbd036533703b11c2e49
S-a-k-s-h-i/100_days_with_python
/Day-046/sortedDictinaries.py
163
3.6875
4
def SortDictionary(d): sorted(d) print(d) d=dict() n=int(input()) for i in range(n): data=input().split() d[data[0]]=int(data[1]) SortDictionary(d)
748575c7db6583a5184abec663205faa9e264498
S-a-k-s-h-i/100_days_with_python
/Day-039/mergeTwoList.py
118
3.703125
4
def merge(A, B): for i in range(len(B)): A.append(B[i]) print(sorted(A)) A=[-4,3] B=[-2,-2] merge(A,B)
c4ff83e3e42078a249aad03e66ba8300662e32f4
tongyaojun/corepython-tongyao
/chapter02/Test04.py
204
4
4
#!/usr/bin/python # InputTest userInput = input('Please input a name:') print('Your input name is :', userInput) numInput = input('Please input a number:') print('Your input number is :', int(numInput))
43a8fae76b90437274501bafd949b39995401233
tongyaojun/corepython-tongyao
/chapter02/Test15.py
430
4.125
4
#!/usr/bin/python #sort input numbers userInput1 = int(input('Please input a number:')) userInput2 = int(input('Please input a number:')) userInput3 = int(input('Please input a number:')) def getBiggerNum(num1, num2): if num1 > num2: return num1 else : return num2 biggerNum = getBiggerNum(user...