blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
36238f0533462385c4955c948fbf673eacce60ca
bpjordan/pressYourLuck
/trivia.py
4,986
4.03125
4
from random import randint class Question: def __init__(self, prompt:str, answer:int): self.prompt = prompt self.answer = answer class TriviaGame: def __init__(self): self.state = 0 #states: 0-need to ask a question, 1-waiting for first response, 2-waiting for second response #3-...
1c20867e9a49f9276a3a1cdd898115e80d3a6b98
toroc85/git-practice
/veneer.py
1,551
3.765625
4
class Marketplace: def __init__(self): self.listings = [] def add_listing(self, listing): self.listings.append(listing) def remove_listing(self, listing): self.listings.remove(listing) def show_listings(self): for listing in self.listings: print(listing) ...
32c8676dda6a1d37b8cc15358d5cd14c05d70623
WinterBlue16/Coding_Test
/Basic_library/itertools/02_combinations.py
224
3.640625
4
# itertools 라이브러리 활용 2 from itertools import combinations data = ['A', 'B', 'C'] # 데이터 준비 result = list(combinations(data, 2)) # 데이터에서 2개를 뽑는 모든 조합 구하기 print(result)
414b7d5156f03ad31544d713de201331a31f147d
H-Cong/LeetCode
/269_AlienDictionary/269_AlienDictionary.py
1,636
3.625
4
from collections import defaultdict, Counter, deque class Solution: def alienOrder(self, words: List[str]) -> str: ''' Topological Sorting / BFS ''' adj_list = defaultdict(set) in_degree = Counter({c : 0 for word in words for c in word}) ...
a07b54494b34a67fa2099a15f03f11267bb8becf
friendbear/AutomateWithPython
/basic/yourName.py
144
4.09375
4
name = '' while True: print('please input your name:') name = input() if name == 'Your name is:': break print('thanks!')
031ddf391c0a759cc1221b66227f54b66937ff9c
qwangzone/app_python
/iterationcase.py
217
3.546875
4
from typing import Iterator from typing import Iterable,Generator g = [x for x in range(10)] g1 = (x for x in range(10)) print(type(g)) print(type(g1)) print(isinstance(g1,Iterator)) print(next(g1)) print(next(g1))
b8e4a6fd4292d8cb087a0be92228c525a93b007b
rafmeeusen/python-examples
/projecteuler/problem13/problem13.py
226
3.578125
4
#!/usr/bin/python3 infile=open('inputfile.txt') total=0 for line in infile: number=int(line) total+=number print(total) totalstring=str(total) print('first 10 digits: ') nrdigits=10 print(totalstring[0:nrdigits])
65153f7badfbd82cc76ad072bad9277971945c8f
AlexanderFabisch/slither
/slither/core/unit_conversions.py
2,741
4.25
4
"""Unit conversions.""" import numpy as np def semicircles_to_radians(angles_in_semicircles): """Convert semicircles to radians. 180 degrees correspond to 2 ** 31 semicircles. This unit is mostly used in Garmin systems or FIT files. Parameters ---------- angles_in_semicircles : float or arra...
99e85c5259410181914a51738d33b51051e94769
LeafNing/Ng_ML
/ex6/plotData.py
662
3.953125
4
import matplotlib.pyplot as plt import numpy as np def plot_data(X, y): plt.figure() # ===================== Your Code Here ===================== # Instructions : Plot the positive and negative examples on a # 2D plot, using the marker="+" for the positive # examples ...
a2490cd1ea799997af7c75540aa2ddc33db876b7
GuilhermeGoya13/exercicios-python
/IF...ELSE/ex034.py
269
3.890625
4
# Informa o aumento do salário salario = float(input('Digite o valor do seu salario: ')) if salario >= 1250: print('Seu salário será de {} reais'.format(salario*0.1+salario)) else: print('Seu salário será de {} reais'.format(salario*0.15+salario))
611658987c6308d75c32e4777a4b25fb717b8933
omtelecom/python3007
/06_home_task_is_due/06_home_task_10.py
376
4.375
4
""" 10. В одномерном списке удалить все четные элементы и оставить только нечетные. """ def odd(lst): return [lst[i] for i in range(0,len(lst),2)] if __name__ == '__main__': assert odd([1, 2, 3, 4]) == [1, 3] # assert odd([0, 1, 1]) == [1, 1] # ошибка ? assert odd([0, 1, 1]) == [0, 1]
6f18a5ed3943d2bed92157a5b55410f7368fa795
ShinjiKatoA16/azuma-python2
/for4-05.py
395
3.75
4
# python2 P36 for4-05 column = int(input('column number=>')) row = int(input('row number=>')) if column < 2 or row < 2: print('invalid!') else: for r in range(row): out_s = '' for c in range(column): if r in [0, row-1] and c in [0, column-1]: out_s = out_s + '■' ...
f84fb7dba8e2425eb153f11d274886f1739de491
adityaskarnik/hiver_test
/2d_pattern.py
416
3.984375
4
# Find 2D pattern of given parent_grid = [[1,2,3,],[4,5,6],[7,8,9]] def search_in_grid(array): for sub_list in array: if sub_list in parent_grid: print("Found") if __name__ == "__main__": n = int(input("Enter number of rows: ")) matrix = [] for i in range(n): m = input("En...
21417e4eee12f2882ae700bd9366ce4f4e062fd1
Puneetsamaiya/PuneetGitDemo
/for.py
145
3.953125
4
number = int (input('Enter the length of execution: ')) for i in range(number): print(i) else : print ("Execution of For loop is done")
d693e34379157750d3e8154ce27df1af664c5f28
aviasd/GUI-Python
/play1.py
5,591
3.59375
4
from tkinter import * from tkinter import ttk from exercise1 import * # reset the tree view def reset_tree(): global tree tree = ttk.Treeview(root) tree["columns"] = ("account_num", "balance", "limit") tree.column("account_num", width=150) tree.column("balance", width=150) tree.col...
4f93032f84b35314cbaa7118199412c5d834fd2f
FahimWeblogicAndCyberTechnologies/PigLatinTranslator
/main.py
802
4.09375
4
sentence = input('Enter a Sentence: ').lower() words = sentence.split() for i, word in enumerate(words): ''' if first letter is a vowel ''' if word[0] in 'aeiou': words[i] = words[i] + "ay" else: ''' else get vowel position and postfix all the consonants present be...
53ff8f228bbd8d0e63c35731ca0cc92a0e3b6709
nadeeha/datacamp
/Introduction_to_python_datacamp.py
28,005
4.875
5
''' Course 1: Python intro - 4 hours Intro to Python Python is an extremely versatile language. To add comments to your Python script, you can use the # tag. Exponentiation: **. This operator raises the number to its left to the power of the number to its right. For example 4**2 will give 16. Modulo: %. This operato...
6fa1120d90af538ff6b075079060cac574733316
xmatheus/Faculdade
/Programação 1/Python 1-semestre/URI/lista2/testeb.py
389
3.71875
4
def main(): from decimal import Decimal i = 0 j = 1 while(i <= 2): if (j==1): j = int(1) if (j==2): j = int(2) if (j==3): j = int(3) if (j==4): j = int(4) if (j==5): j = int(5) if (i==2): i = int(2) if (i==1): i = int(1) print('I={} J={}'.format(i, j)) j = j + 1 if(...
9367b6d084e4a234ab5110bb690f565839b3e44f
Jared-Sanderson/python-challenge
/PyPoll/pypoll.py
1,664
3.5
4
#imports libaries import os import csv #create variable needed total_votes = int(0) poll = {} csvpath = os.path.join ("/Users/Jared/Desktop/DATA HW/python-challenge/PyPoll/Resources/election_data.csv") with open (csvpath) as csvfile: csvreader = csv.reader(csvfile, delimiter=',') csv_header = next(csvreader)...
fe0e93b343ce7e1933238322fafc88eff8124a08
daria-andrioaie/Fundamentals-Of-Programming
/a11-911-Andrioaie-Daria/Service/Domain/board.py
2,558
4.34375
4
import texttable class Board: """ Class that represents the 6 x 7 board of the game, in the form of a matrix. """ def __init__(self): self._number_of_rows = 6 self._number_of_columns = 7 self._representation_of_data = [[None for column in range(self._number_of_columns...
16014eeb740a4842671ef37ba85955469894829d
yixinglin/sobot-rimulator
/supervisor/slam/graph/baseclass/Vertex.py
611
3.5
4
""" The parent class of any types of vertex """ import numpy as np class Vertex: def __init__(self, pose, sigma): """ A vertex class. It is a component of a graph :param pose: a vector of pose :param sigma: a covariance matrix, uncertainty of measurement """ ...
ea87f7fe1285c7c0766e746c396522e19446d8ab
lambda-space/UJ-PyQuant
/uj.py
4,084
3.609375
4
import random import matplotlib.pyplot as plt def hello_world(): print('Hello, World!\n') def draw_stars(n): return ('*' * n) def fib(n): assert n >= 0 return n if n < 2 else fib(n-1) + fib(n-2) def gcd(m,n): return m if (n == 0) else gcd(n, m % n) def ratings(): courses = ['Python for ...
28eebc8b38d04e404429363aed472416320cfe84
jakobkhansen/KattisSolutions
/torn2pieces/torn2pieces.py
1,628
3.671875
4
import sys from queue import Queue class Node: def __init__(self, name, exists=True): self.name = name self.paths = [] self.visited = False self.previous = None self.exists = exists def __repr__(self) -> str: return f"Node({self.name}, {[x.name for x in self.pat...
9d78c7781a33ee015892e251d1fce4e4becd627f
LewisPalaciosGonzales/t07_palacios_ruiz
/ruiz/para01.py
151
3.609375
4
# EJERCICIO N° 01 i = 0 max=100 while(i < max): i += 1 if((i % 2)!= 0): print(i) #fin_si #fin_while print("Termino el ejercicio")
76a56c42cc41cc9e84cc1c816c7d524f4eaf81a2
mattua/machine-learning
/Part 2 - Regression/Section 5 - Multiple Linear Regression/data_preprocessing_template.py
3,727
3.734375
4
# Data Preprocessing Template #multiple linear regression - there are simply more independent variables #y = c + b1x1 + b2X2 + b3x3 etc # need to create dummy variables for categorical variables - New York, California # so if that category applies, that value is zero # dummy variable trap - dont include both dummy v...
200632fa5cc19816a30f1094d2f7e942edeac978
weinapianyun/oneflow
/python/oneflow/nn/modules/tensor_ops.py
6,717
3.71875
4
""" Copyright 2020 The OneFlow Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agr...
225177ff2ae15a415652fe33f6c586713365713b
markellofff/Simple-assessment-System
/project.py
3,332
4.09375
4
def index(): print("""======================================================= Welcome to the Student and Assessment Management System <A>add details of a student. <I>insert assignment marks of a student <S>search assessment marks for a student. <Q>quit. ===================================...
7e36430e33bd822b0aff39a51140aa6529c7654e
imshashwataggarwal/WebCrawler
/Scrapper/Weather.py
803
3.625
4
#! python 2 ''' Weather.py - Launches a weather website in the browser depending upon user choice. ''' import webbrowser,sys,os address = { 1: 'https://www.google.co.in/?gws_rd=ssl#q=weather', 2: 'http://www.accuweather.com/en/in/delhi/202396/weather-forecast/202396', ...
f866a7a2c47a06cc4d6ad85aae9081bc0534f8dc
dmitryro/facebook
/leetcode/408/word_abbreviation.py
400
3.71875
4
import re class Solution(object): def validWordAbbreviation(self, word, abbr): """ :type word: str :type abbr: str :rtype: bool """ substitute = re.sub('([1-9]\d*)', r'.{\1}', abbr) + '$' # end of string to garanttee it covers the entire string # print(re.ma...
e168a2e452f996a8c913173f93d390e5e4f98892
mongoz/itstep
/lesson7/fix_text.py
138
4.03125
4
text = input("add what you want in lowercase : \n") text_1 = text.split(". ") for i in text_1: print(i.capitalize(), end=". ")
4f3159c21ec759f4ab4af53be74a0ea5f0cc448f
valeriybercha/py-test-exercises
/it-academy/hometask6_1_bercha.py
4,699
4.1875
4
# HOMETASK 1 - THREE LISTS print("# HOMETASK 1 - THREE LISTS") import random my_list_1 = [] for i in range(0, 10): x = random.randint(1, 10) my_list_1.append(x) print("- The original random list") print(my_list_1) my_list_2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print("- The second list") print(my_list_2) i = 0 my...
010565a83e2c8173d36a9267b51da495d42b43a3
apoorva2506/CTCI
/Linked Lists/loopDetect.py
2,133
4
4
class Node: def __init__(self, data, nextNode=None): self.data=data self.nextNode=nextNode def getNode(self): return self.data def setNode(self,val): self.data= val def getNextNode(self): return self.nextNode def setNextNode(self,val): self.nextNode = val class Linkedlist: def __init__(self, head...
fd66306fdb1fd5385a70e828462fd6deecac460a
Banzaci/python
/tuple.py
405
3.515625
4
# Mix mellan string och array. Samma func som array men är imutable, som string. Array är mutable ie: arr = [1,2,3] arr[0] = 5 print(arr) tupple = (1,2,3) # tupple[0] = 5 - error a,b,c = (1,2,3) print(a,b,c) # så list funktioner som .sort, .reverse och append finns ej på tupple då det göt ändringar. # använder...
81ee9d0fedfe2bcc2e27ae2b82a0da8d453c8f24
wwylele/chocopy-rs
/chocopy-rs/test/original/pa3/sieve.py
2,587
3.78125
4
# A resizable list of integers class Vector(object): items: [int] = None size: int = 0 def __init__(self:"Vector"): self.items = [0] # Returns current capacity def capacity(self:"Vector") -> int: return len(self.items) # Increases capacity of vector by one element def incr...
933d2c7729b5640845bd9431c54e1c595272d18e
kky0845/coinExchange
/practice.py
448
3.734375
4
##변수 선언 부분 money, c500, c100, c50, c10=0,0,0,0,0 ##메인(main) 코드 부분 money=int(input("교환할 돈은 얼마?")) c500=money//500 money%=500 c100=money//100 money%=100 c50=money//50 money%=50 c10=money//10 money%=10 print("\n 오백원짜리==>%d개" % c500) print("백원짜리==>%d개" % c100) print("오십원짜리==>%d개" % c50) print("십원짜리==>%d개" % c10) prin...
de3c80456644052f3e480e23ddf74176f7797403
matteo-esposito/leetcode
/801+/e1002.py
534
3.625
4
def commonChars(A): """ :type A: List[str] :rtype: List[str] """ chars = {} for word in A: for c in word: if c in chars.keys(): chars[c] += 1 else: chars[c] = 1 sol = [] for c in chars: while (chars[c] > 0): ...
dafb5780017297314c3f9b7321e100f03c2a47d6
viethien/misc
/processing_data.py
484
4.21875
4
#!/usr/bin/python3 #Section Homework def main(): #Introduction to data processing, reading a file line by line file_name = open("integers.txt") process_data(file_name) def process_data(fileName): line_sum = 0 num_lines = 0 lines = fileName.readlines() for line in lines: num_lin...
32d76fdcb97f4d83972e3a41cc4e5576b8bda5f1
jackneer/my-leetcode
/no53_max_subarray.py
501
3.78125
4
def max_subarray(nums): n = len(nums) max = None for i in range(n): for length in range(2, n + 1): temp = nums[i:length] if len(temp) >= 2: total = sum(temp) if max is None: max = total else: ...
ecb1522e57f1a5a77cec56c541cbe48e375c31a5
MSE132/MSE132
/Játék/Szabaduloszoba.py
3,923
3.921875
4
def szabaduloszoba(): '''Ez a játék egy szabadulószoba. Opciók közül kell választanod, hogy mit szeretnél épp csinálni. Eldöntendő kérdésekre "igen" vagy "nem" választ adjál, ahol meg több lehetőséged van, ott mindig az adott döntésed betűjelét add meg. PL.: "b". A játék addig tart, amíg ki nem jutsz a szob...
7bb8c6944acc00cd249453300362bfb4481b7aed
capitan-ariete/memento
/memento.py
327
3.703125
4
"""What is faster, to repeat it 500 times or to stackoverflow it 500 times? 'La letra con sangre entra' """ from typing import Dict import operator def dict_key_from_max_value(d: Dict) -> str: """retrieve the key from a dictionary whose value is maximum""" return max(d.items(), key=operator.itemgetter(...
bf78cc9dfff088ed4ac64398cd603f12e6367ec4
kiminh/offer_code
/09_QuequeWithTwoStacks.py
1,168
3.9375
4
# -*- coding:utf-8 -*- # 因为队列要先入先出,所以栈1杯底的沙子想要取出来,必须把它倒在栈2里,这样栈2栈顶的沙子就是最早的沙子 class Solution: def __init__(self): self.stack1 = [] self.stack2 = [] def push(self, node): # write code here self.stack1.append(node) def pop(self): # 时间复杂度低 # return xx if not se...
29c3c9e3e50bf8f98d2d0878d66bd2460595f8bd
ppbox/leetcode_solutions
/0092_Reverse_Linked_List_II/Solution1.py
1,593
3.984375
4
from utils_py.list import * class Solution: def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode: if not head: return None dummy = ListNode(0) dummy.next = head p = dummy for _ in range(m): node_before = p p = p.next ...
4ba7361ba9b01fc00e4d46bff0f4075770771dcb
muskankapoor/fall2017projects
/Python/lamoda.py
681
3.890625
4
languages = ["HTML", "JavaScript", "Python", "Ruby"] print (filter(lambda x: x == "Python", languages)) cubes = [x ** 3 for x in range(1, 11)] filter(lambda x: x % 3 == 0, cubes) #itenerating over dicitonaries #a codeacademy example movies = { "Monty Python and the Holy Grail": "Great", "Monty Python's Life of...
4a42858d92bc2c1fa3773e937fdf30250d5208a5
yuryanliang/Python-Leetcoode
/100 medium/8/392 is-subsequence.py
1,180
3.890625
4
""" Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a short string (<=100). A subsequence of a string is a new string which is formed from the original strin...
bccd0ef8e0fdbf8fa4ca540af050b6773726923f
Mayuri-hub-lab/Tik-Tak-Toe
/Project Tic Tak Toe.py
2,145
4.03125
4
######################################## PROJECT 1: TIC TAK TOE ########################################### #import library import random import sys # Create gameboard b=[ 0,1,2, 3,4,5, 6,7,8 ] def print_board(): print(b[0],'|',b[1],'|',b[2]) print('--+---+--') print(b[3],'|...
884ea0722f110fb56119812f081c8ba649bc0a36
jaeyoungchang5/interview-practice
/queue-using-two-stacks/program.py
1,466
4.28125
4
#!/usr/bin/env python3 ''' Queue Using Two Stacks: Implement a queue class using two stacks. A queue is a data structure that supports the FIFO protocol (First in = first out). Your class should support the enqueue and dequeue methods like a standard queue. ''' class Queue: def __init__(self): self.stac...
cfbbaa7b5db37fa01a9b67b8da958eee99853d9f
helmetzer/bin
/test.py
137
3.703125
4
mydic = {} for key in range(1, 30): mydic[key] = [0] for key in mydic: if key % 3 == 1: mydic[key].append(3) print(mydic)
6b6cff3d390411aa7761c93a18dea7f2721c4499
LearnerSA/Hackerrank
/Problem-solving/Sherlock and Anagrams.py
743
3.59375
4
#!/bin/python3 import math import os import random import re import sys from itertools import combinations from collections import Counter def allpossible(test_str): res = [''.join(sorted(test_str[x:y])) for x, y in combinations(range(len(test_str) + 1), r = 2)] return res # Complete the sherlockAndAnagrams f...
b4164a37437a78d4f5865e1e00b148fb994342af
Cccmm002/my_leetcode
/224-basic-calculator/basic-calculator.py
1,752
4.1875
4
# -*- coding:utf-8 -*- # Implement a basic calculator to evaluate a simple expression string. # # The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces . # # Example 1: # # # Input: "1 + 1" # Output: 2 # # # Example 2: # # # Input...
4fa42b9d99135b775ec5d554b69f4472259663b6
srp9473/project1
/tute9.py
545
3.703125
4
grocery=["harpic","toothpaste","tommato sause","bhindi","taroai",565] #print(grocery[5:0:-1]) numbers=[3 , 5 , 9 , 7 , 18 , 12 , 4] # print(numbers) # print(numbers[::-1]) # print(numbers.sort()) # print(numbers.reverse()) # print(numbers) # numbers.append(78) # print(numbers) # numbers.insert(2,56) # print(numbers) # ...
6ac36f45fb2da5380c9f4b7cd96654af566cc026
HOcarlos/Snake_Game
/snake_game/scoreboard.py
602
3.546875
4
from turtle import Turtle ALIGNMENT = "center" FONT = ("Courier", 22, "normal") class ScoreBoard(Turtle): def __init__(self): self.i = 0 super().__init__() self.color("white") self.penup() self.goto(x=0, y=270) self.write("Score: " + str(self.i), align=ALIGNMENT, fo...
ccb300f824ae63d2b2d962c8b383d931c2edfdb8
hklinski/cdv
/programowanie_struktularne/4.Instrukcje_warunkowe.py
536
3.703125
4
x=15 if x == 5: print('x jest równe 5') print('wartość x =', x) #x = str(x) #print('wartość x = ' + x) else: print('x jest równe 5') print('wartość x =', x) ########################################### y = True #False if y: print('prawda') else: print('fałsz') j='1' j= False if bool(j)...
922d2a3006bf9c2a159dd9ebce4f127c1e0e5984
RBazelais/coding-dojo
/Python/python_fundementals/StringAndList.py
1,698
4.28125
4
''' Find and replace print the position of the first instance of the word "day". Then create a new string where the word "day" is replaced with the word "month". ''' words = "It's thanksgiving day. It's my birthday,too!" str1 = words.replace("day", "month") #print str1 #Min and Max #Print the min and max values in a...
8493b5c52206277c8926caac2eb2eaeaa2528f2c
dnovelty/happy-shopping
/infrastructure/test.py
174
3.671875
4
def foo(): print("starting...") while True: return 4 print("res:",res) g = foo() for a in g: print(a) print(next(g)) print("*"*20) print(next(g))
cc992952f2c9c65da6eadcd2aaf073392e16c4ca
Mamonter/GB_les_Petryaeva
/bas/less2/ex6.py
1,441
3.890625
4
# Реализовать структуру данных «Товары». Она должна представлять собой список кортежей. # Каждый кортеж хранит информацию об отдельном товаре. # В кортеже должно быть два элемента — номер товара и словарь с параметрами (характеристиками товара: название, цена, количество, единица измерения). # Структуру нужно сформиров...
ea06caf55c5aa0130d0d72bc55c21e669f96b3e1
kun1987/Python
/chapter8_EX10.py
487
4.34375
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- def is_palindrome(word): #this function is a palindrome #A palindrome is a word that is spelled the same backward and forward, like “noon” and “redivider”. if len(word) <= 1: return True if word[::1]== word[::-1]: return True return Fal...
9b5667a97c4a6baa50e7ddf6d7cd5f305c69ed2d
Pyk017/Python
/InfyTQ(Infosys_Platform)/Fundamentals_of_Python_Practise_Problems/Level1/Problem-4.py
434
3.875
4
""" Given a list of numbers, write a python function which returns true if one of the first 4 elements in the list is 9. Otherwise it should return false. The length of the list can be less than 4 also. Sample Input Expected Output [1, 2, 9, 3, 4] True [1, 2, 9] True [1, 2, 3, 4] False ...
f9e52d2f94c825431723f94bf02bf397aa3df7f1
danielelyra/Estudos-em-Python
/funcao_fatorial.py
420
4.15625
4
#função fatorial e um numero binominal que vai chamar 03X a função import math x = int(input("Digite o número de termos: ")) y = int(input("Digite o número da classe: ")) if y == 1 or y == x: print(1) if y > x: print(0) else: a = math.factorial(x) b = math.factorial(y) div = a // (b*(x-y)) ...
f39f56c3009a04bffa3f6b2950905a9af467c8d9
Ihyatt/coderbyte_challenge
/bitwiseone.py
1,104
4.3125
4
def bitwise_one(lst): """Have the function BitwiseOne(strArr) take the array of strings stored in strArr, which will only contain two strings of equal length that represent binary numbers, and return a final binary string that performed the bitwise OR operation on both strings. A bitwise OR operation places a 0 ...
9279aa47625b31c4b0c01748f98419b313ae2f82
un-knower/data-base
/api-test/py-test/Part3_Python_CookBook/merged.txt
7,820
3.625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ #!/usr/bin/env python # -*- coding: utf-8 -*- """ #!/usr/bin/env python # -*- coding: utf-8 -*- """ Author: HuHao <huhao1@cmcm.com> Author: HuHao <huhao1@cmcm.com> Author: HuHao <huhao1@cmcm.com> Date: '2018/7/18' Date: '2018/7/18' Date: '2018/7/21' Info: ""...
e01122da5fdb2f3950e554b831fb50dbe41674f3
2226171237/Algorithmpractice
/fuck/算法思维/回溯组合.py
1,100
3.609375
4
class Solution: def combine(self,n,k): ''' 返回[1,...,n]的k个元素的所有组合 ''' result=[] def dfs(start,path): if len(path)==k: result.append(path[:]) return for i in range(start,n+1): path.append(i) ...
b01a85161d99c0c3810c4e5520df52c986f204b3
ThibaMahlezana/data-structures-and-algorithms-in-python
/DoubleLinkedList.py
4,746
4.1875
4
class Node(object): def __init__(self, value): self.info = value self.prev = None self.next = None class DoubleLinkedList(object): def __init__(self): self.start = None def display_list(self): if self.start is None: print("List is empty") return print("List is : ") p = self.start whil...
60e753281e6bf836cb712ad0172f61ca834adf4d
harshbhardwaj5/Coding-3
/The Stock Span Problem.py
1,313
3.890625
4
# The Stock Span Problem # The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate # span of stock’s price for all n days. # The span Si of the stock’s price on a given day i is defined as the maximum number of consecutive days just befor...
723af2cf899ba903723bd61b9a282f141b06683e
ishaansharma/blind-75-python
/tests/test_problem73.py
970
3.765625
4
import unittest from problems.problem73 import TreeNode, solution class Test(unittest.TestCase): def test(self): root_s = TreeNode(3) root_s.left = TreeNode(4) root_s.left.left = TreeNode(1) root_s.left.right = TreeNode(2) root_s.right = TreeNode(5) root_t = TreeNode(4) root_t.left = TreeNode(1) root...
9da595a9aab65f769c6f104ff33b72c925de079a
RexAevum/Python_Projects
/Bookshop_App/backend.py
2,144
4.0625
4
import sqlite3 db = r"data\books.db" # connect to db def connect(): conn = sqlite3.connect(db) cur = conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS Books (id INTEGER PRIMARY KEY, title TEXT, author TEXT, year INTEGER, isbn INTEGER UNIQUE)") conn.commit() conn.close() def insert(title, autho...
02000b1b1987cef83dbc40a6941de323e0041d47
Susanhuynh/When-the-best-time-for-posts-on-Hacker-News-
/When is the best time of post on Hacker News.py
3,254
4.125
4
#!/usr/bin/env python # coding: utf-8 # **EXPLORE HACKER NEWS POSTS** # In this project, we'll work with a data set of submissions to popular technology site Hacker News. # # We're specifically interested in posts whose titles begin with either Ask HN or Show HN. Users submit Ask HN posts to ask the Hacker News comm...
c3b2e50ef1d0db3ba390bd271bf818d4aae918dc
AdamZhouSE/pythonHomework
/Code/CodeRecords/2893/58616/314564.py
301
3.5
4
# LeetCode 137 class Solution: def singleNumber(self, nums): nums.sort() nums.append(0) nums.append(0) for i in range(0,len(nums),3): if nums[i]!=nums[i+2]: return nums[i] nums = eval(input()) s = Solution() print(s.singleNumber(nums))
27db822505677b7677851946864898670386a7cd
jpgiance/COJ_problems
/binary_search.py
796
4.3125
4
""" Write a function that takes in a sorted array of integers as well as a target integer. This function should use the binary search algorith to determine if the target integer is contained in the array and should returns its index if it is, otherwise -1 Sample input arrar = [0, 1, 21, 33, 45, 45, 61, 71] target = ...
2b3d5d7f36e8f4fd5ae99199114af01c1056f1cb
HarikrishnaRayam/Data-Structure-and-algorithm-python
/Stacks/Lectures/StackUsingList.py
1,004
3.65625
4
# -*- coding: utf-8 -*- """ Created on Sun Apr 19 04:04:10 2020 @author: cheerag.verma """ class Stack: def __init__(self): self.__input = [] def push(self,data): self.__input.append(data) def pop(self): if self.isEmpty() is True: return "Empty A...
f82c6335cffdc149c568a27463c63e76b95e5878
pwittchen/learn-python-the-hard-way
/exercises/exercise48/exercise48/parser.py
1,533
3.625
4
class ParserError(Exception): pass class Sentence(object): def __init__(self, subject, verb, obj): # remember we take ('noun','princess') tuples and convert them self.subject = subject[1] self.verb = verb[1] self.object = obj[1] def peek(word_list): if word_list: word = word_list[0] retu...
ec4e6c8518f1cbb8da963b246b099925a09a6074
eaniyom/python-challenge-solutions
/Aniyom Ebenezer/Phase 2/LIST/Day_47_Challenge_Solution/Question 1 Solution.py
295
4.0625
4
""" Write a Python program to extract a given number of randomly selected elements from a given list. """ import random n_list = [1, 2, 3, 4, 7, 8, 4, 9] n = 3 print("Original List: \n{}".format(n_list)) print() print("Randomly selected elements from the list: ") print(random.sample(n_list, n))
df8cf831627b8ba060cf7cc7e0d2bac2321a7d56
natcaos/Compu-Grafica
/lista.py
549
3.765625
4
list = [1, 2, 3, 4, 5] list.append(9) print list list = [] list.append(8) list.append(12) list.append(2) list.append(0) list.append(4) print list lista1 = ['alba', 1, 2, 3] lista2 = ['listas', 'hola', 5, 8] lista3 = lista1 + lista2 print lista3 import random def intersectarLista(lista, lista4): lista = [2, 4, 6, 8] ...
f52da6ff677b7912202d3f4cf83d5a6e6650ed56
darroyo97/python
/Jan22/LectureNotes/in_class_app.py
1,967
4.21875
4
# Bank Account App class AccountHolder: def __init__(self, fname, lname, mname, type, status, balance): self.fname = fname self.lname = lname self.mname = mname self.type = type self.status = status self.balance = balance class Bank: def __init__(self, name, add...
b7e761712cdee3cdb58f212b76cdb58b60b15baf
AnshumanSwain15/CodeForce-Problems-and-Sollutions
/CodeForces Problems/112A.py
126
3.703125
4
m = input().lower() n = input().lower() if(m == n): print(0) elif(m > n): print(1) elif(m < n): print(-1)
340d5fda3147798fb6174559ed0e40817b677d7f
Rjnd/pyhton_basics
/ex4.py
511
3.5625
4
cars = 100 space_in_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_car average_passengers_per_car = passengers / cars_driven print "There are", cars print "There are only %d drivers and %d cars available." %(drivers, cars) print ...
2d02f0d940138a4b25e33f2f317048b66ae62d98
neko-niko/leetcode
/剑指offer/new3/表示数值的字符串.py
709
3.78125
4
class Solution: # s字符串 def isNumeric(self, s: list): s = list(s) isnum = self.isInter(s) if s[0] == '.': s.remove(0) isnum = isnum or self.isunInter(s) if s[0] == 'e' or s[0] == 'E': s.remove(0) isnum = isnum and self.isInter(s) ...
12d299e56e986d254ff7f94005376cdce6873749
mnishiguchi/python_notebook
/MIT6001x/week7/pset7/draft/isWordIn_test.py
1,562
4
4
import string # one new method def isWordIn(self, text): '''Takes in one string argument text; not case-sensitive. Returns True if the whole word word is present in text. ''' assert type(text) == str # create a list of punctuation signs puncList = [ s...
6859df742adc502d8f0d6eee80d523189ce6bfc4
brenj/solutions
/hacker-rank/python/introduction/loops.py
193
4.15625
4
# Loops Challenge """ Read an integer N. For all non-negative integers i<N, print i2. See the sample for details. """ n = int(raw_input()) for number in range(0, n): print pow(number, 2)
42d3a25c6dffb7d842b5089c886b8d7a3c9f4843
pr656d/HackerRank-Algorithms
/Algorithms/Warmup/Staircase.py
241
3.78125
4
# https://www.hackerrank.com/challenges/staircase/problem n = int(raw_input()) a = "" for i in xrange(n): a = "" b = "" for j in range(0,n-i-1): a += " " for j in xrange(0,i+1): b += "#" print a+b
bb57e6ec589e838c888887ba8fa0019f6bebd79d
kilus666/Python-VCCORP
/Practice excercise/baitap2.py
406
3.515625
4
import codecs import re def WordCount(fileName, encoding): f = codecs.open(fileName, encoding= encoding) dictOfWord={} for line in f: a= re.split("\W",line) for word in a: try: dictOfWord[word]+=1 except KeyError: dict...
b819bfbc747fe8407127dc34424d843aacd2e5a4
Rifat951/PythonExercises
/Dictionary/ex6.5.py
665
4.875
5
# 6-5. Rivers: Make a dictionary containing three major rivers and the country # each river runs through One key-value pair might be 'nile': 'egypt' # • Use a loop to print a sentence about each river, such as The Nile runs # through Egypt # • Use a loop to print the name of each river included in the dictionary ...
21377ec6a0e8eae960708ba3192207e28e064368
alempaz/Remaining_DownloadTime
/Copia.py
2,472
3.53125
4
import sys input_invalido = True def start(): gb1 = input('Tu archivo a descargar esta en Mb o Gb? Responde MB/GB: ') gb = gb1.lower() if gb == 'gb': gb_descargar = input('Ingresa el tamaño en Gb a descargar: ') mb_descargar = float(gb_descargar) * 1024 velocidad_descarga = input...
b473fe7764fc5c229d8bbb61e4b416ad8db372e7
nguyepe2/class_courses
/CS160 Computer Science Orientation/triangle.py
165
4
4
num=1 x=int(input("Input the number of stars, which must be an ood number: ")) space=int((x-1)/2) while(num<=x): print(" "*space+"*"*num) space=space-1 num=num+2
d64066b024e26b1c30238188277efd0a0be2af20
rllabmcgill/rlcourse-february-3-tombosc
/utils.py
1,279
3.59375
4
import numpy as np import matplotlib.pyplot as plt def generate_episode(pi, p_h, n): """ generates an episode in a random state following policy pi updates returns and counts """ assert(np.array_equal(pi[0,:], np.zeros(n+1))) assert(np.allclose(pi.sum(axis=0)[1:-1], np.ones(n-1))) s = np.r...
0ccb57f6aa90b76bd0f73c82ddc05ab29a380d74
james4388/algorithm-1
/algorithms/google/CrackingTheSafe.py
1,053
3.625
4
# Cracking the safe # https://leetcode.com/problems/cracking-the-safe/ # Give password of size n, contain digit 0...k-1 # Find shortest string to unlock # Solution: n = 2, k = 2, sequence: 00 -> 01 -> 11-> 10, ans = 00110 # take n - 1 char and append new number at the end, check if new sequence visited # add it to an...
e4ac2220d8c6e88223bdfcb07b615ee9bd809340
jominkmathew/Programming-lab-Python-
/Course Outcomes/Course Outcome 5/5.py
554
3.84375
4
import csv csv_columns = ['sl.no','subject'] dict_data = [ {'sl.no': 1, 'subject': 'Maths'}, {'sl.no': 2, 'subject': 'Physics'}, {'sl.no': 3, 'subject': 'Chemistry'}, {'sl.no': 4, 'subject': 'Computer'}, {'sl.no': 5, 'subject': 'Biology'}, ] csv_file = "datas.csv" with open(csv_file, 'w') as csvfile: writer = csv.D...
32da7ebe7e81d890e04edb20cec3bb2f13bfec90
hyeokjinson/algorithm
/그리디/곱하기 혹은더하기.py
153
3.765625
4
s=input() data=int(s[0]) for i in range(1,len(s)): num=int(s[i]) if data<=1 or num<=1: data+=num else: data*=num print(data)
fff97ddf949eaee8de4cb63918d38bbbdb43643b
SlamaFR/L1-S2-Algorithm-Programming
/TD/TD2/Ex 1.py
565
3.984375
4
def factorielle_iterative(n): """ Calculer la factorielle de n. :param n: (int) Nombre entier. :return: Factorielle de n. >>> factorielle_iterative(4) 24 """ if n == 0: return 1 resultat = n while n > 1: n -= 1 resultat *= n return resultat def facto...
d56c335541ccd783bce236e0393f55a42dffa0df
SmartPracticeschool/SBSPS-Challenge-4482-Sentiment-Analysis-of-COVID-19-tweets
/plot.py
50,119
3.796875
4
import pandas as pd import numpy as np import plotly.graph_objects as go import plotly.express as px import plotly.offline as offl from plotly.subplots import make_subplots class Plot(): '''Used to plot different graphs by passing relevant arguments; requires main data points; In this particular case thes...
f4e67bec27ded18710b9b835b79efd14f379f838
sethrcamp/cs224FinalProject
/seth_noah_drew_matrix_project.py
25,717
4
4
import unittest import random class Node(object): """ This node class is intended for a 2-D, circular, doubly liked list""" def __init__(self, up, down, left, right, x, y, value=None): """ Creates a node that stores values and pointers to nodes adjacent to the node. :param up:the pointer to the node above the...
73be4f91d94d717afa5693a820e7802e824f6c71
malkam03/Tutorials
/Integratec_WorkShop_2017/3.Game.py
2,977
4.28125
4
# --------------------------------------------------------------- # Integratec programming workshop 2017 # @author Malcolm Davis Steele # @since 5/2/2017 # --------------------------------------------------------------- import random #First learn how to print something print("Hello World! Nice to meet you!") #Then mak...
a75a44018e78014c2729816abf9e61573d5a9e4f
Pratham-vaish/Harshit-Vashisth-Python-Begginer-Course-Notes
/chapter_2/for_loop_introduction.py
165
3.828125
4
i = 1 while i<= 10: print(f"hello world, this is line {i} ") i += 1 print("\n \n") for i in range (1, 11): print(f"hello world this is line {i} ")
f7d49616ecb206f47156133a432c0c0a5fccf7ee
ahraber/euler-py
/p001a.py
314
3.546875
4
factors = [] def factor_calc(n1, n2, limit): for i in range(n1,limit): if (( i%n1 == 0 ) or ( i%n2 == 0 )) and ( i < limit ) and ( i not in factors ): factors.append(i) print(sum(factors)) def main(): n1 = 3 n2 = 5 limit = 1000 factor_calc(n1, n2, limit) main()
855d9e381da76d1dab62bbad9b826bb438fc36ee
mo2menelzeiny/py-datastructure-algorithms-practice
/src/longest_common_substring_dynamic.py
422
3.546875
4
def find_lcs(a, b): row_len = len(b) col_len = len(a) grid = [[0] * col_len for i in range(row_len)] largest = 0 for i in range(row_len): for j in range(col_len): if a[j] == b[i]: grid[i][j] = grid[i - 1][j - 1] + 1 else: grid[i][j] = 0...
001e874633bb2083349c11747d74a01c5f10c975
jagtapshubham/Python
/List/merge_two_list.py
1,007
4.21875
4
#!/usr/bin/python3 def merge_list(list1,list2): list3=[] i=0 j=0 #Sorting list1 and list2 list1.sort() list2.sort() while i<len(list1) and j<len(list2): if list1[i]<list2[j]: list3.append(list1[i]) i+=1 else: list3.append(list2[j]) ...
aed85235e5d3d236d219b8834ccc9cb843ceb292
edmontdants/Programming-Practice-Everyday
/Language/Python3/SYL-Python3/exp3-运算符和表达式/salesmansalary.py
791
3.75
4
""" @Author: huuuuusy @GitHub: https://github.com/huuuuusy 系统: Ubuntu 18.04 IDE: VS Code 工具: python3 """ """ 实验3-4:计算一位数码相机销售人员的工资。他的基本工资是 1500,每售出一台相机他可以得到 200 并且获得 2% 的抽成。程序要求输入相机数量及单价。 """ #!/usr/bin/env python3 basic_salary = 1500 bonus_rate = 200 commission_rate = 0.02 numberofcamera = int(input("Enter the numb...
f0a1b8d8565f26092afb0658f4dedf6d40250672
pranaysapkale007/Python
/Basic_Python_Code/Basic Codes/fact.py
87
3.578125
4
# n = 5 # fact = 1 # # for i in range(1, n+1): # fact = fact * i # # print(fact)
5a853a188cbfd212e98d367d0f9c9bb9aea17478
gitlucaslima/URI-Python3
/1019 - Conversão de Tempo.py
230
3.53125
4
valor = int(input()) horas = valor / 3600 restohoras = valor % 3600 minutos = restohoras / 60 restominutos = restohoras % 60 segundos = restominutos print('{}:{}:{}'.format(int(horas), int(minutos), int(segundos)))
62aa596b5584a5b9ab63d4896531d12f7b3bec8e
benwjohnson/o_isotope_inverse
/nan_helper.py
742
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 22 11:10:30 2018 @author: benjohnson """ # this is a file that interprets between NaN entries in an array import numpy as np def nan_helper(y): """Helper to handle indices and logical indices of NaNs. Input: - y, 1d numpy array wit...
63393599b29382ba70730b229c4693ddbbb02557
osniandrade/hackerrank_python3
/miniMaxSum.py
589
3.78125
4
#!/bin/python3 # https://www.hackerrank.com/challenges/mini-max-sum/problem import math import os import random import re import sys # Complete the miniMaxSum function below. def miniMaxSum(arr): totalSum = 0 highSum = 0 for i in arr: totalSum += i lowSum = totalSum for i in arr: ...