max_stars_repo_path
null
max_stars_repo_name
null
max_stars_count
null
id
null
text
string
score
float64
int_score
int64
from
string
blob_id
string
repo_name
string
path
string
length_bytes
int64
null
null
null
null
import cmd, math, random def plural(number, name): if number > 1: name += 's' return str(number) + ' ' + name class Whatever(cmd.Cmd): def __init__(self): super().__init__() self.pistol1 = Gun("pistol", ".22 bullet", 6, 6, 50) self.pistol2 = Gun("pistol", ".38 bullet", 6...
3.65625
4
smollm
a6b3bde9f7a8417c0f707f59d5414d131586bb41
gobodom/gunslinger
/cmdr.py
5,365
null
null
null
null
from nltk.corpus import swadesh from tkinter import * en2de = swadesh.entries(['en','de']) # English-German translate = dict(en2de) def translate_word(): eng_word = english_word.get().lower() german_words = translate[eng_word] list1.insert(END,german_words) window=Tk() window.wm_title("Translater") ...
3.5625
4
smollm
318ae05eed402df835f50e0c4d094bfe67151bb1
MyHackInfo/My-Project
/Translate English-German.py
855
null
null
null
null
# -*- coding: utf-8 -*- class DialogError(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) class UnsufficientInputError(DialogError): """ This exception is raised when discrimination routines need more information from the user to ...
3.984375
4
smollm
8522c17ad95da8a08cd9cf0dea5bf0966d23180a
severin-lemaignan/dialogs
/src/dialogs/dialog_exceptions.py
3,137
null
null
null
null
""" Is Your Number Narcissistic? (100 Marks) This challenge wants that you have familiarity with following topics in order to solve this problem - Loops - while or do-while functions operators like division and mod. pre-defined functions like that of power function or you can create on your own.(Yeah, at this stag...
4.25
4
smollm
4e6d03deb08e13abd5bec53c1df031fc45de61d7
sharatss/python
/techgig_practice/narcissistic.py
1,491
null
null
null
null
# Add element colours = {"red","green"} print("Adding yellow to the set", colours) colours.add("yellow") print("After adding ", colours) # Clear the set cities = {"Stuttgart", "Konstanz", "Freiburg"} print("Clear the set ", cities) print("After clearing ", cities) # Copy the set more_cities = {"Winterthur","Schaffhau...
3.984375
4
smollm
c16a6db6aa7240c6d87869a1c235679636ebfb80
sharatss/python
/python_basics/set_operations.py
1,652
null
null
null
null
""" Exploring Data Types (100 Marks) This problem is all about various data types available in the languages. Task: For this challenge, you need to read a line from stdin and check whether it is of type integer, float or string. If input is- Integer print 'This input is of type Integer.' to the stdout Fl...
4.0625
4
smollm
41b1202ca5c8fe09950919765d29a6b6a63dba9b
sharatss/python
/techgig_practice/check_datatype.py
1,536
null
null
null
null
""" How Much Big Is Your Number (100 Marks) This challenge will help you in getting familiarity with division operator and the while loop which will be helpful when you will solve further problems on Techgig. Task: For this challenge, you will take an integer input from stdin, store it in a variable and calculate ...
3.796875
4
smollm
abed67db5de1adec518d830a2b33461d29e0606b
sharatss/python
/techgig_practice/num_of_digits.py
1,177
null
null
null
null
""" in nn we need to have a non-zero value for the biases becuase if one nueron outputs 0 the if the bias is 0 too part of the network will become dead and zero so we define initial biases non-zero to prevent that issue ---------------------------------------------------------------------------------------------------...
3.625
4
smollm
e454a57789cb8b87e116436460511c380c2a031f
AlirezaRezaie/nueralNetworks
/nn2.py
499
null
null
null
null
# Programs displays n-polygon using nested loops # 032219 # P4HW4 - Nested Loops # Aaliyah Hubbard # # import turtle, create canvas # define variables # using nested loop, create shape that arguably looks like pacman. # may or may not have been done accidentally on purpose. def main(): #create turtle ...
4.3125
4
smollm
91b44038f077e1994875a6e874970b45a4249334
alyhhbrd/CTI110-
/P4HW4_NestedLoops_Hubbard_2.py
765
null
null
null
null
# program converts LBs to KG Converter using (KG= LB/2.2046) # 02162019 # CTI-110 P2HW1 - Pounds to Kilograms Converter # Aaliyah Hubbard # # PSUEDOCODE: user input LBs > calculate KGs as LB/2.2046 > display KG amount # user input LB amount lb_amount = float(input('Enter Pound Amount: ')) # calculate KGs as LB/2.204...
4.15625
4
smollm
bbd33cac0571d27bf8be07819d7d26641e7d27bf
alyhhbrd/CTI110-
/P2HW1_PoundsKilograms_AaliyahHubbard.py
442
null
null
null
null
yeslist = ["Yes", "YES", "yes", "Y", "y"] nolist = ["No", "NO", "no", "N", "n"] import sys from random import randint from time import sleep def restart(): print("You wanna new name?") yesno = input() if (yesno in yeslist): print("Okay!") sleep(1) name() elif (yesno in nolist): ...
3.953125
4
smollm
1fc381118687c423ae0fbf3e76c02780ac7df440
skinnyporkbun/cs114
/namerandom.py
893
null
null
null
null
from time import sleep print ("Hello world") sleep( 2 ) print ("How are you feeling today from 1 to 10? 1 being bad and 10 being good.") sleep( 3 ) feeling = int(input("Tell me here: ")) #loop the code if user gives invalid number while ( 10 < feeling or feeling < 0 ): print( "Oi, Oi! I said between 1 and 10 m...
4.125
4
smollm
bfedb39b6a55cfd247c8acd97587cee5dd761c58
skinnyporkbun/cs114
/hellofunction.py
1,172
null
null
null
null
import curses from curses.textpad import rectangle scr = curses.initscr() # Window begin_x = 2; begin_y = 1; height = 13; width = 26; win = curses.newwin(height, width, begin_y, begin_x) winS = curses.newwin(height, width, begin_y, begin_x+width) horLine = "-----( )-----( )-----" verLine = " | | " ...
3.71875
4
smollm
abc136fad6eba5f1e26181dced65d50bb472f10e
Laurence-RM/SujikoSolver
/ConGUI.py
2,860
null
null
null
null
str1 = input('Please enter a string') #get user input str2 = str1[:len(str1) - 2] #delete the last 2 characters from the string print(str2[::-1]) #print resulting string, reversed num1 = int(input('Please enter a number')) #input 2 numbers num2 = int(input('Please enter another number')) #print sum, difference...
4.21875
4
smollm
039b634143961a1a8d5a7235a270f0f1acc80e6d
dk4267/CS490
/Lesson1QuestionTwo.py
632
null
null
null
null
""" Differences between Python 2 and Python 3: 1. Python 2 is no longer being maintained, while Python 3 is. 2. Python 3 is gradually starting to replace Python 2. Python 2 is mostly used for legacy code written in that version. 3. A lot of modern libraries are written only for Python 3, and Python 2 libraries ar...
3.96875
4
smollm
0f7000964d50163699277a6332efbd520d26072a
dk4267/CS490
/Lesson1Question1.py
788
null
null
null
null
poundsList = [] numStudents = int(input('How many students do you have?')) for i in range(numStudents): studentWeight = int(input("What is the student's weight in lbs?")) poundsList.append(studentWeight) kgList = [round((poundsList[i]/2.2), 2) for i in range(numStudents)] print(poundsList) print(kg...
3.84375
4
smollm
6d5d6775b936c227d9fb5761e3dd10a7ba90b919
dk4267/CS490
/1.py
327
null
null
null
null
import random def inputList(l): size = int (input("Введите размер: ")) i = 0 for item in range(0,size): l.append(int(input(str(i) + ": "))) i+=1 return l def outputList(l): print("\n") for item in l: print(item, end=" ") def bubleSort(l): size = len(l) for i in...
3.5625
4
smollm
9d1527b7e2176f1122262b56e096058c576119f1
Starantsov/PythonShort
/Python/buble/func.py
630
null
null
null
null
myDict = {} def minimumStepsToOne(num): # Write your code here if num in myDict : return myDict.get(num) if num == 1: myDict[1] = 0 return 0 st = minimumStepsToOne(num - 1) if (num % 3 == 0): st3 = minimumStepsToOne(num / 3) st = min(st3, st) if (nu...
3.890625
4
smollm
ce54a52c89a8374c7748507b79d08501bab050bd
appsjit/testament
/LeetCode/ctuoJul/minToOneMemo.py
449
null
null
null
null
class MyQueue: def __init__(self): self.stack1 = [] self.stack2 = [] def push(self, val): self.enqueue(val) def pop(self) -> int: return self.dequeue() def enqueue(self, val): # self.stack1.append(val) self.stack1 += [val] def size(): retur...
3.90625
4
smollm
2b43e0831f50bce5080cb628e4a00affcdb779c8
appsjit/testament
/LeetCode/ctuoJul/QueueWIthTwoStacks.py
963
null
null
null
null
class Solution: def trap(self, height: List[int]) -> int: if (height == None): return 0 result = 0 scr = 0 blockLen = len(height) stack = [] def peek(stack): return stack[len(stack) - 1] while scr < blockLen: while (len(s...
3.640625
4
smollm
b0b06cb6b6039578378270af8851c8f994e1af97
appsjit/testament
/LeetCode/soljit/s042_TrappingRainWater.py
2,118
null
null
null
null
class Solution: def isRobotBounded(self, instructions: str) -> bool: ## R stands for row kind of Y axis ## C stands for column kind of X axis locR = 0 locC = 0 ## Direction dirR = 1 dirC = 0 ctr = 0 while ctr < 5: for instr in inst...
3.609375
4
smollm
b2d612e29470718e1e4307a290ef3d981904703a
appsjit/testament
/LeetCode/soljit/s1041_RobotCircle.py
1,034
null
null
null
null
class Solution: def checkPossibility(self, nums: List[int]) -> bool: modified = False for x in range(1, len(nums)): if (nums[x - 1] > nums[x]): if modified: return False modified = True if (x < 2 or nums[x - 2] <= nums[x...
3.59375
4
smollm
b253718bc50da3d73a87645283aa22a17e7e4e9a
appsjit/testament
/LeetCode/soljit/s665_NonDecreasingArray.py
451
null
null
null
null
import sqlite3 def createTable(): conn=sqlite3.connect("lite.db") cur=conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS STORE (item TEXT,quantity INTEGER,price REAL)") conn.commit() conn.close() print("Connection Closed") def insert(item,qty,price): conn = sqlite3.connect("lite.db") ...
3.5
4
smollm
003c86a7f453f7150b0ed7ce52eed57fce47a384
appsjit/testament
/Miscellaneous/DBConnect/dbScript.py
1,339
null
null
null
null
# class MyQueue: # def __init__(self): # self.stack1 = [] # self.stack2 = [] # def push(self, val): # self.enqueue(val) # def pop(self)->int: # return self.dequeue() # def enqueue(self, val): # # self.stack1.append(val) # self.stack1 += [val] # def size(): # return len(self.sta...
4.0625
4
smollm
130fc7e1cdeed28fb5e375a8d3f9d0bfd20dee6e
appsjit/testament
/LeetCode/ctuoJul/heapqBuntoro.py
1,917
null
null
null
null
import heapq class Solution: def scheduleCourse(self, courses: List[List[int]]) -> int: ## Sort by course end date courses = sorted(courses, key=lambda x: x[1]) ##print(courses) course_plan = [] ## Plan to take courses time_spent = 0 for start, end in courses: ...
3.6875
4
smollm
b77e42c89a884f966fa8567e93680318c3e3f1fd
appsjit/testament
/LeetCode/soljit/s630_CourseScheduleIII.py
1,245
null
null
null
null
# list = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] # def foo(m): # print(m) # print(m[1][0]) # # v = m[0][0] # # for row in m: # print(row) # for element in row: # if v < element: v = element # return v # # print(foo(list[0])) ############################################ # lst = [[1, 2, 3, 4], # ...
4
4
smollm
9f33598edc6bd1159dd434ee68a1960e50602a76
appsjit/testament
/LeetCode/educative/edMyTester.py
587
null
null
null
null
# # Target Practice 01 - Recursion # # Problem 1: Power Set # # Prompt: Given a set S, return the powerset P(S), which is # a set of all subsets of S. # # Input: A String # Output: An Array of String representing the power set of the input # # Example: S = "abc", P(S) = ['', 'a', 'b', 'c', 'ab', 'ac',...
4.28125
4
smollm
004257114b70e9acf695124d9c6b32001002fe38
appsjit/testament
/LeetCode/ctuoJul/Rec_Power_Lattice.py
5,841
null
null
null
null
from myStack import myStack def isBalanced(exp): # Write your code here md = {'(': ')', '[': ']', '{': '}'} print(exp) print('--------') stk = myStack() for x in exp: if x in ('(', '[', '{'): stk.push(md.get(x)) if x in (')', ']', '}'): rside = stk.pop() ...
3.515625
4
smollm
98399e9016605c90a2f6c54efee0da904511e35c
appsjit/testament
/LeetCode/educative/StQ_Ch8_Parenthes.py
631
null
null
null
null
from collections import OrderedDict class Solution: def intToRoman(self, num): result = "" # TODO convert int to roman string roman = OrderedDict() roman[1000] = "M" roman[900] = "CM" roman[500] = "D" roman[400] = "CD" roman[100] = "C" roman...
3.515625
4
smollm
e1f0c5bc0b6e4f2e50816a3b5773dd9971257071
appsjit/testament
/LeetCode/soljit/s012_IntToRoman.py
861
null
null
null
null
import math def sqInRect(lng, wdth): # your code # print("lng:"+str(lng)) # print("wdth:"+str(wdth)) if (lng == wdth): return None myList = [] chkLng = lng chkWdth = wdth def processList(): nonlocal chkLng nonlocal chkWdth if (chkLng < chkWdth...
3.640625
4
smollm
2ee103fc49ce3071b6a5ed84ecdf3c2e9767df37
appsjit/testament
/Miscellaneous/CodeWarriors/RectToSquare.py
789
null
null
null
null
from LinkedListNode import LinkedList def delete(list,value): deleted = False if (list.isEmpty()): # Check if list is empty -> Return False print ("List is Empty") return deleted currentNode = list.getHead().nextElement # Get current node previousNode = None # Get previous node if (currentNode.data =...
4.15625
4
smollm
f819d7ea2f3aaf67c54539526097681002fc519c
appsjit/testament
/LeetCode/educative/LinkedList_Ch03_DelHead.py
1,089
null
null
null
null
class Library: def __init__(self): self.lend={} self.list_of_books=self.readfile() print(type(self.list_of_books)) print(self.list_of_books) def displayBooks(self): self.list_of_books=self.readfile().split("\n") for n in self.list_of_books: print(...
3.921875
4
smollm
a68579c93a16297129bc9cdf45c6ac755d93f75d
kapilmaurya/python
/mylibrary.py
2,067
null
null
null
null
def febList(n): if(n == 0): return 0 elif(n == 1): return 1 else: return febList(n-1) + febList(n-2) a = int(input("Enter your number: ")) print(febList(a-1))
3.890625
4
smollm
eec026c6f475734c62eadde74068c022c5478b95
ivsntejesh/DSA_questions
/Day_1/Fibbonacci.py
196
null
null
null
null
#!/usr/bin/python import re pi=3.14159 r=3 b=pi*r*2 print "the circumference of a circle of r is" + str(b)
3.921875
4
smollm
9f9fad87950bcc4453b221848219fb4a94485b2d
xianghuil/LearningPython
/circumference.py
108
null
null
null
null
def divideBySub(a, b): '''Integer division without using / or * Simplest solution implemented below, which is to iteratively subtract the denominator from the numerator while the numerator is bigger than or equal to the denominator.''' count = 0 while a >= b: count += 1 a -= b return count def divi...
4.0625
4
smollm
930643cff66f200a0ae28842495b93af8521b270
RohitK89/BasicCS
/ADM/Chapter 1/IntegerDivision.py
717
null
null
null
null
questions = ["1", "1", "1", "4", "5", "6", "1"] def questionType(questionID): if questionID == "0": return "All Questions" elif questionID == "1": return "Reference Questions" elif questionID == "2": return "Guest Passes" elif questionID == "3": return "Technology Questi...
3.59375
4
smollm
5d34bd66d350ec08d76c07d8df4ffdcb2a78d800
ASatiricalDalek/Tally2.0
/scratch.py
970
null
null
null
null
"""List Practice Edit the functions until all of the doctests pass when you run this file. """ def print_list(items): """Print each item in the input list. For example:: >>> print_list([1, 2, 6, 3, 9]) 1 2 6 3 9 """ for item in items: print i...
4.375
4
smollm
24b0ffce5775f69e9ad97100a6101211841c9f3a
shduttacheezit/Lists-wkendAssessment
/practice.py
11,274
null
null
null
null
############################# # Python Image Pixelator # # Version: 0.0.0 # # Author: k4rth33k # ''' # Supported File Types: # File types supported by the # openCV library # # ''' # ##########...
3.59375
4
smollm
8622c2181511276d08c1694c5a4e5f336a076cdf
k4rth33k/code_bunker
/pixel.py
1,617
null
null
null
null
class Person: """ constructor """ def __init__(self, name = " Pop ", age = "28"): self.name = name self.age = age def __str__(self): return self.name + "has " + str(self.age) def public_methode(self): self.__private_methode() """ abstractizare ""...
4.09375
4
smollm
5f26863cfae19aef88b1e753df054f26d2afcd15
Ella2604/Python
/clase.py
768
null
null
null
null
class WordDictionary: """ Strategy: Use dict O(1) access and O(1) lookup 1.When adding: Store len(word) -> All words under that length O(1) 2.When searching: Get list of all words under that length Iterate over each word, and check char with the target word. Retur...
4.0625
4
smollm
9a63b25037473d67d8e290cd57c4060814753c3e
Hashah1/Leetcode-Practice
/medium/211. Add and Search Word - Data Structure Design.py
3,079
null
null
null
null
class Solution: def intToRoman(self, num: int) -> str: """ Time Complexity: O(len(symbols_list)) Space Complexity: O(len(symbols_list)) Create basic map of all symbols -> integers Create a list of all symbols in decreasing order. In while loop. Iterate until end of...
4.03125
4
smollm
ce33bd3202ef469de83c513c0ddb18b273501e2d
Hashah1/Leetcode-Practice
/medium/12. Integer to Roman.py
1,181
null
null
null
null
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def buildTree(self, preorder, inorder): """ :type preorder: List[int] :type inorder: List[int] :rty...
3.984375
4
smollm
0a165089564c9ec5c895a674cad10187bb76453a
Hashah1/Leetcode-Practice
/medium/construct_tree_2.py
1,317
null
null
null
null
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: """TC: O(len(S) + len(T)), SC: O(1)""" s_idx = len(S) t_idx = len(T) # Iterate while both ptrs are valid while s_idx >= 0 and t_idx >= 0: # Start off with a backspace of 1 since we start outside s...
3.578125
4
smollm
04deb8b46ce77d5ae0d2e62cb94b3e8a6b60dcf0
Hashah1/Leetcode-Practice
/easy/844. Backspace String Compare.py
1,206
null
null
null
null
class Solution(object): def removeOuterParentheses(self, S): """ :type S: str :rtype: str """ count_of_lp = 0 count_of_rp = 0 str = "" list_of_valid_substrings = [] for each_char in S: str += each_char if each_char == ')...
3.640625
4
smollm
0dd305480960a6b3d80c5a79d066267a0cab323c
Hashah1/Leetcode-Practice
/easy/remove_outermost_parenth.py
1,051
null
null
null
null
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def verticalOrder(self, root: TreeNode) -> List[List[int]]: """ Time Complexity: O(NLogN) ...
3.921875
4
smollm
bedb5dcb66b927425247ea7f0525a8093250538c
Hashah1/Leetcode-Practice
/medium/314. Binary Tree Vertical Order Traversal.py
1,048
null
null
null
null
class Solution(object): def myPow(self, x, n): """ :type x: float :type n: int :rtype: float """ def pow_pos(x, n): if n == 0: return 1 # Bubble down to the smallest num half_prod = pow_pos(x, int(n / 2)) ...
3.59375
4
smollm
e7b3a1625b5a5ab0afdc19bc1d3c2946eebe0154
Hashah1/Leetcode-Practice
/medium/myPow.py
636
null
null
null
null
class Solution: def intervalIntersection(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]: """ Time Complexity: O(len(A) + len(B)) Space Complexity: O(len(A) + len(B)) """ if not A or not B: return [] def merge(inter...
3.734375
4
smollm
c6a454242f4e6952baa19b0dc9d64e3f3c8be485
Hashah1/Leetcode-Practice
/medium/986. Interval List Intersections.py
1,143
null
null
null
null
from heapq import heappop, heappush, heapify class Solution: def threeSumClosest(self, nums: List[int], target: int) -> int: """ Strategy: Find triplets with sum closest to target. 1. Get list of all triplets generated from each pivoted element along with its sum 2. Store (d...
3.59375
4
smollm
dd1b2541c3f9101aa9ceb183447cc3b52779a2da
Hashah1/Leetcode-Practice
/medium/16. 3Sum Closest.py
1,649
null
null
null
null
print("How old are you?") x = input() print("How old are you?") z = input() y = x+z print (y) # This code is incorrect! Fix it and make it better! student = input("What is your name?") print(student + "'can't wait to start writing harder programs") instructor = input("Who is your favorite instructor?") print(...
4
4
smollm
7edf79e7dd1db73bb695afe0b8dcde97cc2583eb
forat19-meet/meet2017y1lab3
/age.py
474
null
null
null
null
# 딕셔너리 선언{key:value, .....} # key -> inrt, str, bool # value -> 숫자, 문자열, bool, list, dict dic_a = { 'name':'홍길동', 'phoneNumber':'010-1234-5678', 'birthday':'2020/02/02' } print('--------- <dic_a> ---------') print(dic_a) print('------- <요소 추가> -------') dic_a['age'] = 20 print(dic_a) # 기존의 데이터 변경 : key ...
3.625
4
smollm
e203c0e162d6be8a4f3c4360e6b643dbf6c23e5c
yjlee0209/kite
/Python/dic_1.py
1,367
null
null
null
null
print("First Python") # print 실행 # 기본 내장 함수 # abs print(" <<절대값 abs() 함수>>") print(abs(5)) print(abs(-5)) #max print(" <<최대값 max() 함수>>") print(max([1,2,3])) print(max([1,2,3],[4,5,6])) a = 10 b = 20 nums1 = [10,40,100,60,30] nums2 = [10,40,100,60,50] names = "python" # 문자열 print(max(a,b)) print(max(nums1)) p...
4.125
4
smollm
f633a2929691b7425b970f7ff8e02f837ad31397
yjlee0209/kite
/Python/first.py
3,471
null
null
null
null
# list 선언 list_ex = ['요소1', '요소2', '요소3'] # index와 요소값을 같이 출력 - 1 print('----- <출력1> -----') idx = 0 for val in list_ex: print('{}번째 요소는 {}입니다.'.format(idx, val)) idx += 1 # index와 요소값을 같이 출력 - 2 print('----- <출력2> -----') for index in range(len(list_ex)): #반복의 횟수는 list 사이즈 만큼 반복한다. print('{}번째 요소는 {}...
3.75
4
smollm
aae9bed12f9bc0f53734d3984553af368eeee3e6
yjlee0209/kite
/Python/func_3.py
737
null
null
null
null
# Bool 타입으로 치환되는 상황 # 0 -> False # None -> False # 빈 문자열 -> False # 빈 리스트 -> False num = 10 str_blank = "asd" nums = [1,2,3] if num: print('0은 True 처리가됩니다.') else: print('0은 False 처리가됩니다.') if str_blank: print('빈 문자열은 True 처리가됩니다.') else: print('빈 문자열은 False 처리가됩니다.') if nums: print('빈 리스트는 True...
3.71875
4
smollm
3caff7578ebecfc2db4f329ee650ba812749e314
yjlee0209/kite
/Python/if_6_Bool.py
523
null
null
null
null
#!/usr/bin/env python # -*- coding: utf-8 -*- """ ### Interval List Intersections Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order. Return the intersection of these two interval lists. (Formally, a closed interval [a, b] (with a <= b) denotes the set of real numbers...
4.125
4
smollm
2a8679c747893070e7d14b0c259f1c66419bfab4
voitenko-lex/leetcode
/Python3/30-day-leetcoding-challenge/week-8/intervalIntersection.py
3,105
null
null
null
null
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Implement Trie (Prefix Tree) Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); // returns false trie.startsWith("app"); // returns tru...
4.4375
4
smollm
55630d6a3badf0e38d4fadba96a646aa11059733
voitenko-lex/leetcode
/Python3/30-day-leetcoding-challenge/week-6/Trie.py
3,909
null
null
null
null
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Valid Perfect Square Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Output: true Example 2: Input: 14 Output:...
4.21875
4
smollm
240cc12eabe441d4fe9b3f6a69a3a0feb7afabd7
voitenko-lex/leetcode
/Python3/30-day-leetcoding-challenge/week-6/checkStraightLine.py
1,820
null
null
null
null
dict1 = {'key1':{'a': 1, 'b': 2},'key2':{'a': 3, 'b': 4},'key3':{'a': 5, 'b': 6}} print(sum(i['b'] for i in dict1.values()))
3.875
4
smollm
3cf004b064949e8f348fe6aa1a2cb821bfdad418
voitenko-lex/leetcode
/Python3/07-reverse-integer/test.py
127
null
null
null
null
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? Example 1: Input: [2,2,1] Output: 1 Example 2: ...
4.03125
4
smollm
06dbbba8f8f62b5c64b24edfdd3e7bb979d9107a
voitenko-lex/leetcode
/Python3/30-day-leetcoding-challenge/week-1/singleNumber.py
1,203
null
null
null
null
from typing import NamedTuple, Tuple import re from lib import Point PROBLEM_INPUT = "target area: x=102..157, y=-146..-90" class TargetRange(NamedTuple): x_range: range y_range: range def __contains__(self, p: "Probe") -> bool: return p.position.x in self.x_range and p.position.y in self.y_ran...
3.84375
4
smollm
8b4958c844c47ebdf367437fb0eb7cff6e4b7ba7
adamhammes/advent-of-code
/aoc_2021/day17.py
2,526
null
null
null
null
import typing import lib Instruction = typing.Tuple[str, int] def parse_input(raw: str) -> list[Instruction]: instructions = [] for line in raw.strip().splitlines(): i_type = "addx" if "a" in line else "noop" val = int(line.split(" ")[1]) if i_type == "addx" else 0 instructions.appe...
3.6875
4
smollm
8b71b01a441311f4a912761e22fa897f4e3037a9
adamhammes/advent-of-code
/aoc_2022/day10.py
1,462
null
null
null
null
import math import typing from lib import Point import lib class Instruction(typing.NamedTuple): direction: str distance: int def as_point(self) -> Point: return { "U": Point(0, 1), "R": Point(1, 0), "D": Point(0, -1), "L": Point(-1, 0), }[...
3.6875
4
smollm
eb1c0817f264f4a74844ff336032556ad2f80cf3
adamhammes/advent-of-code
/aoc_2022/day09.py
1,758
null
null
null
null
import collections import re from typing import * import lib WORD = re.compile("[a-z]+") Ingredient = str Allergen = str Recipes = Dict[Tuple[Ingredient, ...], Tuple[Allergen, ...]] PossibleAllergens = Dict[Allergen, Set[Ingredient]] def parse_input(raw: str) -> Recipes: recipes = {} for line in raw.strip...
3.53125
4
smollm
73db6baf67f318c46255c31489f42934778d179a
adamhammes/advent-of-code
/aoc_2020/day21.py
2,688
null
null
null
null
# File: wc.py # Date: October 4, 2017 # Author: Adam Abad # Purpose: To count the lines, words, and bytes in a file def main(): print() print("Program to print the number of newlines,") print("words and characters in a file") print("You will be asked to enter the name of a file.") print("Writt...
4.25
4
smollm
b64601561deb934b5c7a18b547d4993281b0cf14
adamabad/WilkesUniversity
/cs125/projects/wc/wc.py
934
null
null
null
null
############################################################################ # # PROGRAM: mult.py - Multiplications # # AUTHOR: Adam Abad # # DATE: September 5, 2017 # # FOR: CS-125 # Wilkes University # # PURPOSE: This Python program will ask the user to enter a number, # then...
4.1875
4
smollm
937c5cc30a7b0e737040b38dde6f0540f5c24926
adamabad/WilkesUniversity
/cs125/labs/2/mult.py
881
null
null
null
null
# File: points.py # Author: John Koch # Date modified: 3/11/2014 # Further modification: 10/8/2015 # Purpose: to open an image and be able to click on points of the image # to create the code for a Polygon. # Click on the "Stop" box to the top left side of the window to stop creating points # and print the Polyg...
3.890625
4
smollm
37ade339fbc7fcde4ab9431c6bfc4d946031c441
adamabad/WilkesUniversity
/cs125/projects/pumpkinPic/points.py
1,768
null
null
null
null
import sys def Hours(TimeM): try: Total_M = int(TimeM) if Total_M < 0: raise ValueError else: hour = int(Total_M / 60) minute = Total_M % 60 return hour , minute except ValueError: print("please input a positive, int number") ...
3.90625
4
smollm
787049fa13fc6011d268712ced92ba58cfd54a87
wxwdxx/shiyanlou-code
/MinutesToHours.py
440
null
null
null
null
""" Project Euler Problem 24 ======================== A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, ...
3.875
4
smollm
774afbef3c0ed63836335a96b97e217308d94095
regynald/Project-Euler-Solutions
/Python/024.py
1,154
null
null
null
null
""" Project Euler Problem 17 ======================== If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: D...
3.5625
4
smollm
64d3a7829f20937bcd83828dbabdf61b30458ccf
regynald/Project-Euler-Solutions
/Python/017.py
915
null
null
null
null
#imports block class from block import Block # Creates class Blockchain based on Block as unit class Blockchain: def __init__(self): self.chain=[] self.all_transactions=[] self.genesis_block() def genesis_block(self): transactions={} genesis_block=Block(transactions,"0") self.chain.append(gen...
3.859375
4
smollm
9a38f8c472e481e7d88daee160d710b81f5c93ad
Robson-55/Blockchain-python
/blockchain.py
1,461
null
null
null
null
#!/usr/local/bin/python #We start by importing a few libraries. #Easygui provides our GUI for the game. from easygui import * #Time is a library that introduces the concept of time to the game. import time #Pygame is a series of multimedia tools that can create games using Python. import pygame #To start pygame we ne...
4.03125
4
smollm
12a63588dab79853c63450a4378c9c17f86a37ea
lesp/LinuxVoice_PythonQuiz
/LV_Quiz.py
5,928
null
null
null
null
from math import pi class Circle(object): def __init__(self, x=0.0, y=0.0, r=0.0): self.x, self.y, self.r = x, y, r def area(self): return pi*self.r**2 def setRadius(self, R): self.r = R #c1 = Circle(2.0, 3.0, 2.0) #print(c1.area()) #jc1.setRadius(4.0) #print(c1.area())
3.703125
4
smollm
5f766d4e22ca6cf33d6e3085b92019a5a94da3a2
pprobst/ELC117-2018a
/extras/OOP1_python/circle.py
312
null
null
null
null
import numpy as np if __name__ == "__main__": #size N = int(input()) str = '' for i in range(N): str += input() elements = list(str) count = 0 for ele in elements: if ele == 'G': count += 1 print(count)
3.59375
4
smollm
653f67c10c1b02c1b90427f68467743195457822
AronDJacobsen/Algo_Data_Project
/1_counting.py
277
null
null
null
null
#Variaveis para calculo de media nota_aluno_impar_total = 0 nota_aluno_par_total = 0 total_alunos = 6 #Variavel de com o total de alunos #Entrada de dados alunos impares print("**********VOCÊ ESTÁ DIGITANDO AS NOTAS DOS ALUNOS ÍMPARES**********") for i in range (1,total_alunos+1,2): nota_aluno_impar = input(...
4
4
smollm
ad04f04600721f1678c7c205bf4779c71a85ffdd
LugBastos/Projetos-Faculdade
/mediaAlunos.py
1,918
null
null
null
null
# python 3 for i in range(1, 101): if not (i % 3): print("Fizz", end="") if not (i % 5): print("Buzz", end="") if (i % 3) and (i % 5): print(i, end="") print()
3.796875
4
smollm
aa49c1ae1818cfcb3ba6d78aff9febc966e45962
piwikjapan/pentester2019
/fizzbuzz/fizzbuzz.py
200
null
null
null
null
list_one = ['celery','carrots','bread','milk'] list_two = ['celery','carrots','bread','cream'] if list_one == list_two: print "The lists are the same" elif list_one != list_two: print "the lists are Not the same" # x = 0 # if len(list_one) != len(list_two): # print "The lists are not the same." # else: # ...
3.875
4
smollm
ae8c597727553dedad85bb7768d072e9becc4e50
howard199113/Python-Assignments
/Compare List.py
537
null
null
null
null
n = int(input('Digite um número para ver sua tabuada: ')) print('-' * 12) print('{} x {:2} = {}'.format(n, 1, n*1)) print('{} x {:2} = {}'.format(n, 2, n*2)) print('{} x {:2} = {}'.format(n, 3, n*3)) print('{} x {:2} = {}'.format(n, 4, n*4)) print('{} x {:2} = {}'.format(n, 5, n*5)) print('{} x {:2} = {}'.format...
3.984375
4
smollm
86180792f349f7e70330ec0e30261ae922554e63
moniqueds/FundamentosPython-Mundo1-Guanabara
/ex009.py
719
null
null
null
null
largura = float(input('Informe a largura da sua parede em metros: ')) altura = float(input('Informe a altura da sua parede em metros: ')) area = largura * altura print('Sua parede tem a dimensão de {} (largura) x {} (altura) e sua área é de {}m²'.format(largura, altura, area)) tinta = area / 2 # /2 pq a cada 1L pin...
4.03125
4
smollm
1de48afdfaffafa692245439107afedd6143196c
moniqueds/FundamentosPython-Mundo1-Guanabara
/ex011.py
478
null
null
null
null
def pad(m, blength): numPad = (blength - len(m)) paded = (chr(numPad)*numPad).encode() ans = m+paded return ans def main(): blength = 20 m = b'YELLOW SUBMARINE' print(pad(m, blength)) if __name__ == '__main__': main()
3.578125
4
smollm
c0a2971d35256e47db2ec165a90a8a18a52420ba
srikoder/CryptoStuff
/CryptoPals/2018csb1098_9.py
251
null
null
null
null
# %% RECURSION def factorial(n): if n == 1: return n else: return n * factorial(n - 1) # %% result = factorial(9) print(result) # %% SUM DIGITS OF NUMBER def sum_digits(n): if n < 10: return n else: all_but_last = n//10 last = n % 10 return sum_digits...
3.96875
4
smollm
a6ce170e0e246b703385cb4c6e333ea5f1779fae
slutske22/Practice_files
/python_quickstart_lynda/recursion.py
896
null
null
null
null
# %% number = int(input("Pick a number:")) if number < 0: print("Dont be so negative") elif number > 0 and number < 10: print("Fair enough") elif number > 10 and number < 1_000_000: print("Good attitude") else: print("Dont be greedy") # %%
3.84375
4
smollm
27a86b2dfa4e9c18d2b332427b5739b535ec2a52
slutske22/Practice_files
/python_for_js_devs/flow.py
258
null
null
null
null
def mario_number(level): if level == '-' or level == '--': return 1 elif level[-3:] == 'P--': return mario_number(level[:-1]) elif level[-3:] == '---': return mario_number(level[:-1]) + mario_number(level[:-2]) elif level[-3:] == '-P-': return mario_number(level[:-2]) ...
4.0625
4
smollm
ccb9c20aa2ee93e2eb06e9b01c96d1ba539cd13c
acxg/cs61a
/lab/test.py
612
null
null
null
null
from datetime import datetime, timedelta, date sprintEpoch=18 cadreonEpoch=date(2016,1,4) #Day 1 of Sprint 18 ''' sprintEpoch=57 cadreonEpoch=date(2017,7,10) #Day 1 of Sprint 57 ''' def determineSprintNumber(): today=date.today() thisMonday=today-timedelta(days=today.weekday()) # discard the remainder in the nex...
3.609375
4
smollm
d8c641dabd8bc08595497150742af987560beb8f
johnhofmeyer/test-coverage
/determineSprintNumber.py
544
null
null
null
null
matriz=[[1,2], [3,4] ] matriz2=[["a","b"], ["c","d"] ] matriz3=[[0]*2]*2 #==> No se recomienda ya que cualquier modificacion, va a cambiar varios datos matriz4=[[0 for i in range(2)] for j in range (2)]
3.671875
4
smollm
136f39422dd97e8837e701eb9f5f4d1c5696d297
ccamargo8/Mi-primer-repositorio
/Matrices.py
247
null
null
null
null
# REMOVE THIS AFTER USE # Task 5 # In this task you should create your very own news data set by scraping it from the web. We will be looking at the "Politics and Conflict" section of the Wikinews site (https://en.wikinews.org/wiki/Category:Politics_and_conflicts), which contains about 7500 articles sorted by the fir...
3.5625
4
smollm
420600206c8daf2b060dab7638108916d7015eef
SystemOut1324/Datascience_Final_Project
/Appendix/Code/Wiki_News_Scrapy/Wiki_News_Scrapy/spiders/wikiSpider.py
13,405
null
null
null
null
# Importing webbrowser module from Python standard library import webbrowser class Movie(): """This class provides a way to store movie data Each movie has the following attributes (all strings): title: Name of the film year: Year in which film was released genre: Genre of film ...
3.71875
4
smollm
c81e36f555248bff05bc8236d001be3506d64b5e
xaliceli/nd004-movie-site
/media.py
1,031
null
null
null
null
#! 両者ともに計算量は O(log min(a,b)) # LCM(Least common multiple):最小公倍数 # こちらは自分で実装する必要あり """ 2つの自然数の積はその最小公倍数と最大公約数の積に等しくなる a×b=lcm×gcd を利用 """ from math import gcd def lcm(a, b): return a // gcd(a, b) * b # GCD(Greatest common divisor):最大公約数 gcd(X, Y)
3.875
4
smollm
c1d39604ec6d71b9e3e77fe3828a8f34bb35da00
kathmandu777/CompetitiveProgramming
/note/Python useful func/gcd_and_lcm.py
396
null
null
null
null
import pygame from pygame.sprite import Sprite class Ship(Sprite): def __init__(self, ai_settings, screen, ship_width, ship_height): ''' Init of the spaceship and its location on the screen ''' super().__init__() self.ai_settings = ai_settings self.screen = screen ...
3.875
4
smollm
1daea3f25bdcd6ba553218850b15ba98836f777c
katRoman99/Alien_Invasion
/ship.py
2,155
null
null
null
null
# team Reduction Eruption - Bo Lu, Soojin Choi # SoftDev2 pd07 # K20 -- Reductio ad Absurdum # 2019-04-28 from functools import reduce def reader(filename): file = open(filename, "r") l = file.read().split("\n") list = [] for each in l: list+=each.split() #print(list) return list #bo...
3.78125
4
smollm
4b988763819b64c4813fce662cba5e7270e3b46f
Soojin-C/Soft_Dev_Work
/20_anon-reduce/cw.py
1,616
null
null
null
null
# Classes are named in capitalized camel-case # Classes are preceded and followed by 2 line breaks class Point: def __init__(self, x, y): self.x = x self.y = y def move(self): print("move") def draw(self): print("draw") point1 = Point(10, 20) point1.draw() print(point1.x...
4.0625
4
smollm
843902b899596868ad0e79ed20929035befffb56
MacLure/python-basics
/classes.py
1,018
null
null
null
null
def add(first, second) : return first + second def sub(first, second) : return first - second def mul(first, second) : return first * second def div(first, second) : return first / second def addother(*nums) : sum = 0 for x in nums : sum += x return sum def addkv(**knnums): ret...
3.75
4
smollm
b9f184ca35f25bc371d8f2a767c5b09deb7a6f27
Cliedy-s/AIclass
/1911/1115/1115/_1115_02.py
572
null
null
null
null
""" command.py - """ class Command(object): """ Command - class representing CLI command This class has the following properties: name - name of the command, of course syntax - syntax of the command desc - short description of the command help - longer...
3.640625
4
smollm
c8cf975dae3fa1490d5628ea62c32dc857620536
mraitmaier/pyrus
/utils/cli/command.py
5,107
null
null
null
null
# -*- coding: utf-8 -*- # UTF-8 encoding when using korean class Person: def __init__(self, name, age): self.name = name self.age = age def aboutMe(self): print "나는 부모 클래스 입니다." class Student(Person): school = "goorm school" def aboutMe(self): print("이름 : {} 나이 : {}".format(self.name, self.age...
3.71875
4
smollm
434e7b7e77440c96d29d4d9ea292ca2199f1ea4b
gangys0411/python
/day06/class_04.py
409
null
null
null
null
# -*- coding: utf-8 -*- # UTF-8 encoding when using korean class phoneBook(object): def __init__(self, name, number, religion, photo): self.name = name self.number = number self.religion = religion self.photo = photo print "info is saved" def showData(self): print("이름 : {}\n번호 : {}\n사는 곳 : {}\n사진...
3.609375
4
smollm
888c9396c3e1e5ad98157504f5d63e657543bea5
gangys0411/python
/day06/class_05.py
657
null
null
null
null
""" Marvick Felix File : guessversion1.py A prototype that lays out the user interface for a GUI-based guessing game. """ import random from breezypythongui import EasyFrame class GuessingGame(EasyFrame): def __init__(self): EasyFrame.__init__(self, title = "Guessing Game") self.setSize(...
3.6875
4
smollm
9f94121dbc455bf4ae8b73b9f51922caea3f138a
MarvickF/Coding-from-School-2020
/guessversion1.py
1,999
null
null
null
null
from abc import ABCMeta, abstractmethod class TextFinder(metaclass=ABCMeta): def find(self,text): pass class SpanishFinder(TextFinder): def find(self,text): return " {} fue encontrado".format(text) class EnglishFinder(TextFinder): def find(self,text): return " {} w...
3.78125
4
smollm
cb0e85ec1335bef13595604630776e226fd24041
alejo-moreno/design-patterns
/Design_Pattern/Behavior/Strategy.py
516
null
null
null
null
''' module: `csvwriter` exposes a class CsvWriter that writes Urban Dictionary words and their definitions to many CSV files. ''' import csv import os from typing import List, Set class CsvWriter: ''' Writes Urban Dictionary definitions according a spec set by Wei Xu. ''' def __init__(self, limit=10...
3.515625
4
smollm
df488c5e1675bdbce16dbc8f22cc2774ae07de91
samuelstevens/ubscrape
/ubscrape/csvwriter.py
1,934
null
null
null
null
import random import string WORDLIST_FILENAME = "words.txt" #################################################### with open("words.txt") as f: words = f.read().split() ########################################################### secret_word = random.choice(words) letters_guessed = set() wrong_guesses = set() max_g...
4
4
smollm
1036c2610d5a52069428c6499878c5aed0936411
h12bn/hangman-game
/hangman.py
2,233
null
null
null
null
""" Renders post edit form, and writes edits to database get(self, author, post_id): Renders a form for editing a post post(self, author, post_id): Sends post edit information to database, where it is written """ import handler as handler import models.post as db_post # facilitates creation and query for b...
3.6875
4
smollm
9111a8d21af17e08b25509eed874584a31aa0199
tony-blake/MultiUserBlog3
/handlers/editpost.py
1,225
null
null
null
null
#!/usr/bin/python import sys print len(sys.argv) threshold = 4 if len(sys.argv) < threshold: print "Script requires at least", threshold, "arguments" elif len(sys.argv) >= 8 and len(sys.argv) <= 10: print "You have entered way too many arguments" print "Thank you!", "You have entered" , len(sys.arg...
3.65625
4
smollm
d3e4a3caf4fb794f7e22a2c05a9e4a8fa2ec07f1
scriptedinstalls/Scripts
/python/conditionals/ifthen.py
399
null
null
null
null
import calculator as cal x=int(input("Enter the number")) y=int(input("Enter the number")) z=cal.add(x,y) print(z) z=cal.sub(x,y) print(y)
3.71875
4
smollm
932cc82f1a0cb3135de918b6ba446c126a5970e1
Esther145/Machine-Learning-sessions
/app.py
138