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
81ff670128257e2cce2719213a46b885ff4cce05
AnishGG/Bomberman
/brick.py
632
3.5625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # /usr/bin/python from random import randint from unoccupied import unoccupied class brick: # un is a list containing unoccupied places in our dic and oc is vice-versa def __init__( self, un, oc, dic, ): self._un = un ...
5d467cc09935f128bbe0ca2c1665cdf4a1e3363b
Ajita2015/EulerProject
/EvenFibonaccinumbers.py
585
3.859375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: ''' Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four m...
a8a7b3d0a42ddd22c88073c4df721292e0dfca76
crampon231/ALDS
/ALDS1_1/ALDS1_1_C.py
420
4.15625
4
# -*- coding: utf-8 -*- import math def isPrime(x): if x == 2: return True if x < 2 or x % 2 == 0: return False for i in range(3, int(math.sqrt(x)) + 1): if x % i == 0: return False return True if __name__ == '__main__': n = int(input()) cnt = 0 for ...
0d3c043c0b16afac9150d1ff53162d8ed73e6403
crampon231/ALDS
/ALDS1_8/ALDS1_8_A.py
1,482
3.859375
4
# -*- coding: utf-8 -*- class Node(): def __init__(self, key, parent=None, left=None, right=None): self.key = key self.parent = parent self.left = left self.right = right class BinarySearchTree(list): def __init__(self): list.__init__(self) self.root = None ...
6de3b8d1c6689771aa551c3b1c4fd6ad1aafd2b3
crampon231/ALDS
/NTL_1/NTL_1_B.py
288
3.5
4
# -*- coding: utf-8 -*- def pow(x, n, M=1): if n == 0: return 1 res = pow((x * x) % M, n // 2, M) if n % 2 == 1: res = (res * x) % M return res if __name__ == '__main__': M = 1000000007 m, n = map(int, input().split()) print(pow(m, n, M))
86f1236ef135f01a137efb04b7379872c0d98084
crampon231/ALDS
/ALDS1_2/ALDS1_2_D.py
867
3.828125
4
# -*- coding: utf-8 -*- def insertionSort(A, n, g): global cnt for i in range(g, n): v = A[i] j = i - g while j >= 0 and A[j] > v: A[j + g] = A[j] j -= g cnt += 1 A[j + g] = v def shellSort(A, n): def func(m): if m == 0: ...
b3b68ae99b8e37f49e08da38442989b5f664db81
crampon231/ALDS
/CGL_1/CGL_1_C.py
1,943
3.78125
4
# -*- coding: utf-8 -*- import collections import math class Vector2(collections.namedtuple("Vector2", ["x", "y"])): def __add__(self, other): return Vector2(self.x + other.x, self.y + other.y) def __sub__(self, other): return Vector2(self.x - other.x, self.y - other.y) def __mul__(se...
620fd48781c6f225226e91f33c9f7718bdfb294f
aford4074/HackerRank
/python/numpy/concatenate.py
503
3.625
4
''' Concatenate www.hackerrank.com/challenges/np-concatenate python 2.7 Sample Input 4 3 2 1 2 1 2 1 2 1 2 3 4 3 4 3 4 Sample Output [[1 2] [1 2] [1 2] [1 2] [3 4] [3 4] [3 4]] ''' import numpy as np def hackerrank(l1, l2): a1 = np.array(l1, int) a2 = np.array(l2, int) print np.concatenate((...
16bd589da4443dd5cff7094b65c761e83f5d927c
aford4074/HackerRank
/python/classes/complex_numbers.py
1,169
4.03125
4
''' Classes: Dealing with Complex Numbers ''' from math import sqrt class Complex(object): def __init__(self, real, imaginary): self.real = real self.imaginary = imaginary def __add__(self, no): return Complex(self.real + no.real, self.imaginary + no.imaginary) def __sub__(self, ...
ed4233b9cdef94ea4a353d9872a0aa948c7a43e6
rishabh0509/python_first
/list_example.py
204
3.8125
4
fruits = ['apple', 'pear'] #can store diff. datatypes in a list print (fruits) fruits.append('strawberry') print(fruits) fruits[1]='blueberry' print(fruits) color=(255,255,255) print(type(color))
cbdd97c14e7764903d723471f532ba06b8ac3f34
gchapa22/python_workshop
/ciclos.py
289
3.859375
4
#Ciclos #For #While cuenta = 0 while cuenta < 10: print "while: Hola amigos", cuenta cuenta += 1 print "\n" #For for i in range(10): print "for (range): Hola amigos", i print "\n" lista = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for i in lista: print "for (list): Hola amigos", i print "\n"
a855b847eb732f4e7af1ee18c11d1c6d24e24aa3
satfail/Python
/03_PrimerProyecto/app.py
1,619
4.375
4
""" --Peliculas 'a' añadir, 'l' list, 'f' buscar y 'q' salir Tareas: -Menu -Añadir -Listar -Buscar -Salir """ peliculas = [] def add_movie(): name = input("Nombre de pelicula : ") director = input("Nombre de director : ") año = input("Año de pelicula : ") pelicula = { 'nombre' : name, ...
d48405b1a1bf7a5d7bf34409eded0a4f8d0f13f3
satfail/Python
/02_Fundamento/masSobreListas.py
521
3.6875
4
numeros = [0,1,2,3,4,5] doble = [] for numero in numeros: doble.append(numero*2) print(doble) doble_corto = [numero*2 for numero in numeros] #doble_corto = [numero*2 for numero in range(5)] print(doble_corto) edades = [33,45,50,70,80] edad_string = [f"Mi amigo tiene {edad} " for edad in edades] print(edad_str...
567699b665fd5b526c33e31e090ac3ab1ef8c77e
fan-tian0/happy-journey
/day02.py
1,529
4.21875
4
#print()的用法 #1、用法 print('hello world') name = '小小' print(name) #2、用法:print(name,age,gender) age = 18 gender = 'boy' #3、用法print(value,value,value,...sep = ' ' ,end = '\n') print(name,age,gender) #sep(separation:分割)默认的分割是空格 print(name,age,gender,sep='_')#sep='&' sep = '%' #print()后面默认跟两个sep(分割)空格,end(换行)\n ...
b0761bb436a0e44a461a1bc7cb6921e0875f0cc2
MRSD2018/reefbot-1
/reefbot-controller/bin/SpinTracker.py
1,846
3.640625
4
'''Module that keeps track of the total spin of the robot. This is necessary so that we can unwind the robot. ''' import math class SpinTracker: # Constants for how much spinning has been done IN_BOUNDS = 0 IN_TIGHT_BOUNDS = 1 NEEDS_STARBOARD = -2 # We need to spin to starboard to unwind NEEDS_PORT = -1 # ...
1e7a5c403d1243d40cb74129eb35956828a49ac8
marissa-graham/undergraduate_work
/Non-ACME classes/cs557proj4.py
4,633
3.671875
4
from __future__ import division import sys import numpy as np from matplotlib import pyplot as plt def deCasteljua(P,n,u): """Better because doesn't require calculating Bernstein schtuff.""" Q = np.copy(P) #print "Q.shape, n: ", Q.shape, n # Need each column of Q to be a point # P is an...
d5e2e88640dd218b79fe78f3fb8fb46f953943eb
marissa-graham/undergraduate_work
/LLNL+research/intersect2d.py
19,063
3.703125
4
from __future__ import division import pylab import numpy as np from matplotlib import pyplot as plt from scipy import linalg as la """ All polygons are defined by an array P that contains at least three points, assumed to be in counterclockwise order (non-counterclockwise order breaks everything). """ de...
5756b7e44e52c49aa547f45c27008e2e8f105977
BruceHi/numpy_pandas_matplotlib
/numpy_learn/learn5.py
389
3.71875
4
# numpy 线性代数 import numpy as np a = np.array([[1, 2], [3, 4]]) b = np.array([[11, 12], [13, 14]]) print(np.dot(a, b)) print(np.matmul(a, b)) a = np.array([1, 2, 3]) b = np.array([2, 3, 4]) print(np.dot(a, b)) print(np.inner(a, b)) a = np.arange(10).reshape(2, -1) print(a) c = np.where(a > 3) print(c) print(np.tran...
44a723d80f4669bc2e50c348dfb5a59085f6d9ae
BruceHi/numpy_pandas_matplotlib
/pandas_learn/learn5.py
1,096
3.65625
4
# 连接 concat:concatenation import pandas as pd import numpy as np df1 = pd.DataFrame(np.ones((3, 4)) * 0, columns=['a', 'b', 'c', 'd']) df2 = pd.DataFrame(np.ones((3, 4)), columns=['a', 'b', 'c', 'd']) df3 = pd.DataFrame(np.ones((3, 4)) * 2, columns=['a', 'b', 'c', 'd']) print(df1) res = pd.concat([df1, df2, df3]) # ...
5a6c390c0661c3707fc9bf97d5f7fddb2ac23692
BruceHi/numpy_pandas_matplotlib
/matplotlib_learn/learn_second.py
359
3.96875
4
# 次坐标轴 import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 10, 0.1) y1 = 0.05 * x ** 2 y2 = -y1 fig, ax1 = plt.subplots() ax1.plot(x, y1, 'g') ax1.set_xlabel('x data') ax1.set_ylabel('y1 data', color='g') # 生成一个新的轴,x 轴共享 ax2 = ax1.twinx() ax2.plot(x, y2, 'r') ax2.set_ylabel('y2 data', color='r') pl...
9933d02694472aab53e5b797386799ca566cd2aa
ignacioPastor/code-algorithms
/python/learning/5_write_a_function/write_a_function.py
311
4.09375
4
#!/bin/python3 import sys def is_leap(year): if year % 4 == 0: if year % 100 != 0: return True elif year % 400 == 0: return True return False return False def main(year): print(is_leap(year)) if __name__ == '__main__': main(int(sys.argv[1]))
f13e841d3a8ef2d2e46bd958811aa53409350686
niyatigulati/Calculator.py
/calc.py
524
4.125
4
def calc(choice, x, y): if (choice == 1): add(x, y) elif (choice == 2): sub(x, y) elif (choice == 3): mul(x,y) elif (choice == 2): div(x,y) # the below functions must display the output for the given arithmetic # TODO def add(a, b): pass def sub(a, b): pass ...
b5aad4033db5c5d12d1095a79e83c00936167fc9
johnbain881/zoo
/zoo.py
359
3.765625
4
zoo = ("dog", "cat", "bear", "coyote", "zebra", "lion", "tiger", "goldfish", "cobra", "turtle") animal_to_find = "zebra" zoo.index(animal_to_find) if animal_to_find in zoo: print("Found it!") (animal1, animal2, animal3, animal4, animal5, animal6, animal7, animal8, animal9, animal10, ) = zoo animal_list = [] for anim...
5a156ee0bd41b37c0733f019836756bae462cf81
Pwojton/gitrepo
/python/cw2.py
438
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # cw2.py # #DANE WEJŚCIOWE: # początek i koniec przedziału podanego przez użytkownika #DANE WYJŚCIOWE: #liczby naturalne w przedziale # print(i ," ",end='') def main(args): a = int(input("Podaj start: ")) b = int(input("Podaj stop: ")) for i in range...
259d408966ad800275836bac6daed966955696eb
greenfox-velox/bizkanta
/week-03/day-02/functions/37.py
438
4.0625
4
numbers = [3, 4, 5, 6, 7] # write a function that filters the odd numbers # from a list and returns a new list consisting # only the evens def even_nums(list): otherlist = [] for i in range(len(list)): if list[i] % 2 == 0: otherlist.append(list[i]) return otherlist print(even_nums(numbers)) # or def filter_...
07a980c302d2be437359eed677108490a104b5cc
greenfox-velox/bizkanta
/week-03/day-01/28.py
671
3.859375
4
aa = [1, 2, 3] out = 0 # if the aa list contains one element set the out to 1 # if the aa list contains two element set the out to 2 # if the aa list contains more than 2 set the out to 10 # if the aa contains no elements it should set to -1 # first solution # if len(aa) == 0: # out = -1 # elif len(aa) == 1: # out...
ab7ba605e8420261b7a6a9e6f50ac0313dfcb67f
greenfox-velox/bizkanta
/week-04/day-03/10.py
558
4.03125
4
# create a 300x300 canvas. # create a square drawing function that takes 1 parameter: # the square size # and draws a square of that size to the center of the canvas. # create a loop that draws 20 squares with that function. from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pa...
7482d942e97a74847cbcdccf6e4809450238e845
greenfox-velox/bizkanta
/week-04/day-03/08.py
523
4.1875
4
# create a 300x300 canvas. # create a square drawing function that takes 2 parameters: # the x and y coordinates of the square's top left corner # and draws a 50x50 square from that point. # draw 3 squares with that function. from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.p...
1d2f7c0baac41219951f37d4a8ec54975bc63a3d
greenfox-velox/bizkanta
/week-04/day-03/02.py
454
3.890625
4
# create a 300x300 canvas. # draw a box that has different colored lines on each edge. from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() red_line = canvas.create_line(20, 20, 100, 20, fill='red') green_line = canvas.create_line(100, 20, 100, 50, fill='green') blue_line...
a35413038dc25063fa1bda9bf93a868010510ce9
greenfox-velox/bizkanta
/week-03/day-02/functions/39.py
250
4.1875
4
names = ['Zakarias', 'Hans', 'Otto', 'Ole'] # create a function that returns the shortest string # from a list def shortest_str(list): short = list[0] for i in list: if len(i) < len(short): short = i return short print(shortest_str(names))
0c1cedbaa3a31450caae59fd00de54f21f2da412
greenfox-velox/bizkanta
/week-04/day-04/09.py
329
4.125
4
# 9. Given a string, compute recursively a new string where all the # adjacent chars are now separated by a "*". def separated_chars_with_stars(string): if len(string) < 2: return string[0] else: return string[0] + '*' + separated_chars_with_stars(string[1:]) print(separated_chars_with_stars('...
bb3dba4d859fc1d1f4bc9e20e451501c52528bc4
Beloslav13/progs_and_code
/boock_test/dice/random_dice.py
574
3.515625
4
from random import randint class Die: def __init__(self): self.sides = 6 def roll_die(self): number = randint(1, self.sides) print(number) def upgrade_side(self, sides): self.sides = sides die = Die() print(f'{die.sides} сторон') for _ in range(11): die.roll_die() ...
c14312e3b59967d2e3d612bffcde164eb0ca5b20
cifpfbmoll/practica-2-python-rdtorres-cfgs
/P2EJ3.py
157
3.8125
4
import sys print("Escriba un número") N = int(input()) if N%2 ==0: print (N, 'es un número par') else: print(N, 'es un número impar') sys.exit()
616b18b5459caa026ecfc922566dc3cf5e847a81
andriiglukhyi/codewars
/dashatize/solution.py
307
4
4
def dashatize(num): a = '' if num == None: return 'None' else: num = abs(num) for item in list(str(num)): if int(item)%2 == 1: a+= '-'+item+'-' else: a+=item b = a.replace('--', '-') return b.strip('-')
8691a45b072900ccd315dd84af65fe81079e89f5
andriiglukhyi/codewars
/sumofdigits/solution.py
141
3.703125
4
def sumDigits(number): total = 0 for item in str(number).replace('-', ''): total+= int(item) return total
18fd44382321ebcc36f1c4555354a36f3d03d192
erardlucien/transposematrix
/trans_main.py
871
3.875
4
import transpose matrix = 4 * [[x for x in range(4)]] matrix1 = 2 * [[x for x in range(4)]] matrix2 = 5 * [[x for x in range(3)]] matrix3 = [[[1, 23, 4], [1, 2, 3], [1, 5, 6]], [[1, 23, 4], [1, 2, 3], [1, 5, 6]]] array = [x for x in range(1, 4)] trans_m = [] print("matrix:") print(matrix) transpose.transp...
fc2c3f5eeb94d3564cbd9e1fa502176302c19af8
choogiesaur/codebits
/challenges/python/isomorphic-strings.py
2,340
3.5
4
# LC 205 # Another solution I wrote that was slightly faster; Array of encodings instead of incremented char class Solution: def isIsomorphic(self, s: str, t: str) -> bool: # traverse strings and encode to number s_dict = {} curr = 0 s_rep = [] for char in s: # E...
055b1173cbe0bc9a383f8863016bdf26b1285a00
choogiesaur/codebits
/data-structures/py-trie.py
1,350
4.21875
4
# Implement a version of a Trie where words are terminated with '*' # Efficient space complexity vs hashtable # Acceptable time complexity. O(Key_Length) for insert/find # Handle edge cases: # - Empty String # - Contains non alphabet characters (numbers or symbols) # - Case sensitivity class StarTrie: # Each node ...
406bbf1479e8c0bf119b566e4aab895ecdbc01e8
choogiesaur/codebits
/data-structures/py-stack.py
1,319
4.28125
4
### A Python implementation of a Stack data structure class PyStack: # Internal class for items in stack class StackNode: def __init__(self, val = 0, child = None): self.val = val self.child = child # Check if stack has items def is_empty(self): return self.size() == 0 # Get number of items in stack ...
3f899bbb212215d77023a3e584aa5fdd184a6687
choogiesaur/codebits
/challenges/python/frequency-queries.py
1,257
4.09375
4
# https://www.hackerrank.com/challenges/frequency-queries/ #!/bin/python3 import math import os import random import re import sys from collections import defaultdict # Works for most test cases. # Operation 3 is slow; solution could be some sort of reverse lookup dictionary where: # key is frequency, value is True/...
ef1d83b26cad74e8fd13e486824d37ee37128dcf
choogiesaur/codebits
/challenges/python/nth-tribonacci.py
228
3.5625
4
# LC 1137 class Solution: def tribonacci(self, n: int) -> int: d = {0: 0, 1: 1, 2: 1} for i in range(3, n+1): d[i] = d[i-1] + d[i-2] + d[i-3] print(d[i]) return d[n]
79c40150edff26a25d012493f9a6a1a05377258f
choogiesaur/codebits
/challenges/python/making-anagrams.py
1,045
3.984375
4
# https://www.hackerrank.com/challenges/ctci-making-anagrams #!/bin/python3 import math import os import random import re import sys # added this from collections import defaultdict # # Complete the 'makeAnagram' function below. # # The function is expected to return an INTEGER. # The function accepts following param...
762763c503714d9693c450499110dad0f7a25f19
choogiesaur/codebits
/challenges/python/multiply-strings.py
959
3.90625
4
# Given two numbers, represented as strings, multiply them and return as string # Rules: CANNOT directly convert string to int using built in methods def parse_number(self, num): result = 0 for i in range(1, len(num) + 1): char = num[-i] if char == '9': multiplier = 9 elif ch...
78a94d555bc786d7e4b274a4c62a447dd3ff9d50
vineetkorpal/py4e-lessons
/ex_03_02.py
264
3.921875
4
try : h = float(raw_input("Enter Hours: ")) r = float(raw_input("Enter rate: ")) except : print("You have to input numbers. Try again.") quit() if h <= 40.0 : pay = h * r else : pay = (40.0 * r) + ((h - 40.0) * r * 1.5) print("Pay:",pay)
05cf4516e7311425a2aa4ce9013719c867c78bce
minkyukim44/Jump2Python
/Chapter 2/practice_2_4.py
271
3.84375
4
## Practice Tuple t1 = (1,) t4 = 1,2,3 t1 = (1,2,'a','b') del t1[0] # cannot delete an element in a tuple t1[0] = 'c' # cannot change an element in a tuple t1[0] t1[3] t1[1:] t2 = (3,4) t1 + t2 t2*3 len(t1) t0 = (1,2,3) t00 = (4,) tadd = t0 + t00 tadd
84f967680207a1faac35167d1d3493e3aacf8a16
minkyukim44/Jump2Python
/Chapter 4/practice_4_2.py
276
4
4
# 'input()' function a = input() number = input("Type a number:") # 'print()' function a =123 print(a) print("life" "is" "too short") print("life"+"is"+"too short") print("life","is","too short") for i in range(10): print(i, end=' ') # put all outputs on a line
6d8013ed6098625c21bbff913843ed872f424336
shanike/ex12
/ex12_utils.py
8,519
3.640625
4
from constants import NEIGHBORS, FOUNT_MAX_FOR_WORD, PLAYER_NAMES def is_valid_path(board, path, words): """ returns None if path is not a valid path, or if the word created through the path is not in the words list. otherwise returns the word :param board: {[[str]]} -- board game ...
5fff89d4c3f1a2bd58ed8b3098499ebb10d29a54
gprice1129/interview
/sorted_insert.py
388
3.578125
4
def goodInsert(array): goodInsertHelper(array, 0, len(array)) def goodInsertHelper(array, left_bound, right_bound): size = right_bound - left_bound if (size < 1): return mid = (right_bound + left_bound) / 2 print array[mid] goodInsertHelper(array, left_bound, mid) goodInsertHelper(array, mi...
7513472d24d6090efd5a3c9def621a59b41405ab
jchavez2/COEN-144-Computer-Graphics
/Jason_C_Assigment1/assignment1P2.py
1,936
4.21875
4
#Author: Jason Chavez #File: assignment1P2.py #Description: This file rasters a circle using Bresenham's algorithm. #This is taken a step further by not only rastering the circle but also filling the circle #The file is saved as an image and displayed using the computers perfered photo drawing software. from PIL imp...
d84b9afd6ce8278c8de1869410105636ac325be2
calury/INTERVIEW-2
/数据结构/lst.py
3,259
3.578125
4
# coding:utf-8 class ListNode: def __init__(self, x): self.val = x self.next = None def construct(lst): if lst is None or len(lst)==0: return None head = ListNode(lst[0]) i, p = 1, head while i < len(lst): p.next = ListNode(lst[i]) i, p = i+1, p.next ret...
27163d8d89a9b1c466b20c0fb54aa7830bbe4014
Wobum/checkio
/OReilly/checkio_4.py
524
3.546875
4
#checkio_4.py def checkio(date1,date2): s = '' for i in range(len(date1)): for j in range(len(date1[i])): if date1[i][j] == 'X': s += date2[i][j] return s def Rotate(matrix): l = [] l1 = [] for i in range(len(matrix)): list1 = list(matrix[i]) l.append(list1) l2 = zip(*l[::-1]) for i in l3: f =...
dc9d95ec63607bec79a790a0e0e898bebe9998bc
nisarggurjar/ITE_JUNE
/ListIndex.py
559
4.1875
4
# Accessing List Of Items li = ["a", 'b', 'c', 'd', 'e', 'f', 'g'] # index print(li[2]) # Slicing print(li[2:5]) # <LIST_NAME>[starting_index : ending_index] ==> ending_index = index(last_value) + 1 # stepping (Index Difference) print(li[::2]) # <LIST_NAME>[starting_index : ending_index : index_difference] # N...
2dd8c379fa9ec125aac12d1a67ab9049f23634c4
nisarggurjar/ITE_JUNE
/ErrorHandeling.py
804
4.0625
4
# try # except # finally # else # raise ''' try: a = int(input("Enter first number: ")) b = int(input("Enter second number: ")) print(a/b) except: print("You Got an Error") finally: print("Block is over!") ''' ''' try: a = int(input("Enter first number: ")) b = int(input("Enter second nu...
330ffa3c0f75a1fae5d7af3d0597ccb7d1286de1
nisarggurjar/ITE_JUNE
/ConditionalStatements.py
2,228
4.21875
4
# if # if else # elif ''' rain = False # if --> single condition if rain == True: print("I will take a leave") # if else if rain == True: print("I will take a leave") else: print("I will go to office") # if else sunny = False if rain: print("I will take a leave") elif sunny: print("I will go...
ec04f85ea120b4ee7556143b931b0d98144b0668
nisarggurjar/ITE_JUNE
/Variable.py
767
3.8125
4
# Variable #Rules for declaring Variables # #1. It can consist only numbers, characters and underscores #2. It can not have any special characters expecte underscore #3. variables name cant have any space in between #4. it can never start with a number #5. Variable name cant be a keyword Fname = "Nisarg" Lname = ...
c297bab61ceae1cf0bdeff5307133a90de77465c
nisarggurjar/ITE_JUNE
/String.py
2,591
4.09375
4
# String --> it is a clollection (array) of characters (alphabets, numbers, symbols, etc) # String also supports forward (positive) and backward (negative) indexing s = "Python is a programming language" s1 = 'django' print(s) print(s[2]) print(s[-2]) print(s[2:15]) print(s[2:15:2]) print(s[::-1]) s = s + "." p...
43ed9a489bd1fb43343479edfbde71a091d7345f
PacktPublishing/Python-Natural-Language-Processing
/Chapter04/4_5_regualrexpression.py
2,964
3.875
4
import re def searchvsmatch(): line = "I love animals."; matchObj = re.match(r'animals', line, re.M | re.I) if matchObj: print "match: ", matchObj.group() else: print "No match!!" searchObj = re.search(r'animals', line, re.M | re.I) if searchObj: print "search: ", sear...
dcd2292d98493a102fb0a4e13b89132407061079
PacktPublishing/Python-Natural-Language-Processing
/Chapter04/4_4_wordtokenization.py
1,023
4
4
from nltk.tokenize import word_tokenize from nltk.stem.wordnet import WordNetLemmatizer def wordtokenization(): content = """Stemming is funnier than a bummer says the sushi loving computer scientist. She really wants to buy cars. She told me angrily. It is better for you. Man is walking. We are meeting to...
7ef3ad389458dd68c9864283cedd4b15bd4b227d
alvaro0701/PruebaGit
/Prueba.py
83
3.734375
4
a=int(input("Ingrese un num: ")) b=int(input("Ingrese otro num: ")) c=a-b print(c)
28eba67ffc0e1affd01e375a1a8a7ab8646dc93c
stefanos1316/Rosetta-Code-Research
/Scripts/Task/zig-zag-matrix/python/zig-zag-matrix-2.py
392
3.546875
4
def zigzag(n): def move(i, j): if j < (n - 1): return max(0, i-1), j+1 else: return i+1, j a = [[0] * n for _ in xrange(n)] x, y = 0, 0 for v in xrange(n * n): a[y][x] = v if (x + y) & 1: x, y = move(x, y) else: y, x...
6b2d2673fa0c2eaba070c6ffbe3897a578089c6d
cartman9999/Microsoft-Python-Summer-Camp
/second-class/honour_roll.py
271
3.96875
4
gpa = float(input('Ingresa tu promedio: ')) lowest_grade = float(input('Ingres tu calificación máas baja: ')) honour_roll = False if gpa >= 85 and lowest_grade >= 70: honour_roll = True if honour_roll: print('Well done'); else: print('Not honour roll');
54ef853fbbda89374a388a2ab2ccca5b6b69647c
nicholas-maltbie/PyDataStrucutres
/Heap/Heap.py
2,824
3.609375
4
import math def get_parent(node): return (node - 1) // 2 def get_left(node): return node * 2 + 1 def get_left(node): return node * 2 + 1 def get_right(node): return node * 2 + 2 class Heap: """ Contains a definition for a Heap >>> heap = Heap() >>> heap.insert(10) >>> heap...
48f8edc788db701e27f5fb1ac2ef0d75453f9714
fbabaei/projects
/practice/src/rotate.py
548
4.09375
4
''' Created on Mar 17, 2018 @author: fereydounb ''' class Solution(object): def rotate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: void Do not return anything, modify nums in-place instead. """ i = 1 nums2 = [] while i <= k: ...
a714402ef8921b97870d62f24222575ba39fc5cb
Wakarende/chat
/app/main/helpers.py
1,230
4.1875
4
def first(iterable, default = None, condition = lambda x: True): """ Returns the first item in the `iterable` that satisfies the `condition`. If the condition is not given, returns the first item of the iterable. If the `default` argument is given and the iterable is empty, or if it has no items matching ...
a4f5c85d69abec28b9c63e28351ec4901731786a
dhariskov/python-advanced
/Advanced/Exams/Paint colors.py
1,409
3.8125
4
string = input().split() colors = ["red", "yellow", "blue", "orange", "purple", "green"] temp_color = "" temp_color2 = "" result = [] # for i in range(len(string)//2): while string: if len(string) > 1: temp_color = string[0] + string[-1] temp_color2 = string[-1] + string[0] if temp_color i...
fd9a63c95a1c6b118c64530bccb6785e4c326398
dhariskov/python-advanced
/Advanced/Exams/Expression Evaluator.py
359
3.6875
4
import math string = input().split() result = 0 # string = [int(x) if x not in "+-*/" else x for x in string] eval_result = "" result = 0 temp = [] for i in range(len(string)): if string[i] not in "+-*/": temp.append(string[i]) else: result = eval(string[i].join(temp)) temp = [str(mat...
1f442506904c3fc0119571df5e6bef3b632008db
dhariskov/python-advanced
/Advanced/My_Exam/Snake.py
2,269
3.625
4
def movement(territory, row, col, food_quantity, burrows): if territory[row][col] == "*": food_quantity += 1 elif territory[row][col] == "B": if [row, col] in burrows: burrows.remove([row, col]) territory[row][col] = "." row = burrows[0][0] col = burrows[0][1]...
41ab9d0e10b83df7b0a9bfe89d740c2c36ec75f4
dhariskov/python-advanced
/Advanced/Functions Advanced/5. Function Executor.py
346
3.5625
4
def func_executor(*args): ll = [] for each in args: func = each[0] arguments = each[1] ll.append(func(*arguments)) return ll def sum_numbers(num1, num2): return num1 + num2 def multiply_numbers(num1, num2): return num1 * num2 print(func_executor((sum_numbers, (1, 2)), (mu...
752b55a862a2084c952d0107f540e01777950724
dhariskov/python-advanced
/Advanced/Multidimensional Arrays/3. Maximal Sum.py
786
3.640625
4
r, c = [int(x) for x in input().split()] matrix = [] for row in range(r): matrix.append([int(x) for x in input().split()]) biggest_sum = 0 for row in range(3): for col in range(3): biggest_sum += matrix[row][col] current_sum = 0 biggest_matrix = [[0, 0, 0]] * 3 last_index = (2, 2) for row in range(r-...
5761dee5c4e27fd7eb74ac3842dfbdcb81ee16d6
JoelNiklaus/ProjectEuler
/src/problems/until099/Problem071.py
466
3.5625
4
from fractions import Fraction import math import operator n = 1000000 fraction = Fraction(3, 7) print("generating list") list = [] for i in range(n): if i % 7 != 0: k_exact = fraction * i k_int = math.floor(k_exact) difference = (k_exact - k_int) / i if difference < 0.00001: ...
b80434bb1dd0542602a7eff361f61f2cd1230b56
thebreakcoder/HackerRank-ProblemSolving
/Mini-Max Sum.py
614
4.0625
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 21 12:49:26 2020 @author: lenovo """ import math import os import random import re import sys # Complete the miniMaxSum function below. def miniMaxSum(arr): x = sorted(arr) minimumSum = 0 maximumSum = 0 result = "" for i in range (len(x) - 1): ...
506c1dd5299992bbf36c76458ce7029738cb4d1a
thebreakcoder/HackerRank-ProblemSolving
/Sequence Equation.py
559
3.5625
4
import math import os import random import re import sys # Complete the permutationEquation function below. def permutationEquation(p, n): mylist = p[0:len(p)] p.sort() y = [] for i in range (n): y.append(mylist.index(mylist.index(p[i]) + 1) + 1) return y if __name__ == '__main__': ...
dce69a552c400f95529bccfb3415838117e8adb6
pluto-the-lost/LeetCode
/solutions/day3_prob15_3Sum.py
2,696
3.578125
4
''' link: https://leetcode.com/problems/3sum/description/ Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums = [-1, 0...
696d791bba19e977c73f76dcc3e67ecb4f71b13d
instantpun/python-automation
/sort-by-low/sortlowest1.py
1,550
3.71875
4
# working with file parsing and sorting algorithms # GOAL: # read file and determine which interface has the lowest throughput associated with it. import time start = time.time() # A little more complicated, but we could easily turn this into a function as well, and pass it any file with open("example.csv", "r") as ...
097ce8b859d33f24fc259dfc0aabdea733f22f93
Rattlesnek/IMS
/plots/plot_consumption.py
747
3.546875
4
import sys import numpy as np from matplotlib import pyplot as plt def num_to_weather(num): if num == 0: return 'sunny' elif num == 1: return 'middle' else: return 'cloudy' try: filename = sys.argv[1] except IndexError: print('Wrong arguments!') sys.exit(1) csv = np....
ec4eea384367bf2b3662ac820a69f9a8ef5035ef
aryamanchoudhary123/CODEFORCES-SOLUTIONS
/4A.py
93
3.859375
4
n=int(input()) ans="YES" if n<=2: ans="NO" else : if n%2!=0 :ans="No" print(ans)
3ceb4fb94e70975eaae8d3926036fde2300615a8
aryamanchoudhary123/CODEFORCES-SOLUTIONS
/469A.py
232
3.546875
4
n=int(input()) x=list(map(int,input().split())) p=x[0] x=x[1:] y=list(map(int,input().split())) q=y[0] y=y[1:] ans="I become the guy." for i in range(1,n+1): if i not in x and i not in y : ans="Oh, my keyboard!" print(ans)
e86e0e98a18de5de262967053c9bc13537c88fef
imtiaz-emu/10DaysOfStatistics
/BinomialDistribution_I.py
1,000
4.03125
4
__author__ = 'Imtiaz' ''' problem statement: https://www.hackerrank.com/challenges/s10-binomial-distribution-1 solution: Brute Force Python Version: 3.5 ''' # binomial_distribution_formula = n!/(x! * (n-x)!) * p^x * q^(n-x) # where n = number of trials # x = number of successes # q = failure ratio #...
cb61049d42725ce631ad850148908d2a9122610d
surkhay911/binary_search
/binary_search.py
739
3.75
4
from random import randint #import time #start_time = time.time() def search(x, y): # функция бинарного поиска # start_time = time.time() low = 0 high = len(x) - 1 while low <= high: mid = (low + high) // 2 guess = x[mid] if guess == y: return mid + 1 elif ...
12df85fabdd74ebbeb9d98a87bd2ac5b8632eee3
SimonBCox/coding-skill-test-python
/text_processing_lib/word_frequency.py
4,661
4
4
# Import modules # import re import warnings # Class definitions # class WordFrequency: """ A class containing a word and its frequency of occurrence in a text ... Attributes ---------- word (str) : A word in a text frequency (int) : The frequency of the word occurring in a text ...
946ae5bfe188e431d77776602e9964db618264f2
cj1597/python_part_1
/Item_2.py
294
3.890625
4
def get_even_num(min_num, max_num): """ :param min_num: :param max_num: :return: """ res_list =[] for x in range(min_num + 1, max_num): if x % 2 == 0: res_list.append(x) print(res_list) if __name__ == '__main__': get_even_num(2,10)
8d198ecf63b25d6c6d370b51889f615d0bf08dce
cj1597/python_part_1
/Item_10.py
221
4.09375
4
def palindrome(given_string): if list(given_string.upper()) == list(reversed(given_string.upper())): print(f"{given_string} - true") else: print(f"{given_string} - false") palindrome('clarence')
3951ed56ed50a92dd918d4352559c6e800d8c76e
fatihul-falah/labspy05
/project.py
2,446
3.859375
4
daftar = {} while True: print("") c = input("A)dd, E)dit, D)elete, S)earch, L)ist, Q)uit: ") if c.lower() == 'a': print("Add Data Nilai Siswa") nama = input("Nama: ") nim = input("NIM: ") tugas = float(input("Tugas: ")) uts = float(input("Uts: ")) uas = float(...
a1ca3e7485c471666d6620a0d23831ce29fd8f3f
matheus-valentim/projetos-python
/pequenos projetos/validação de número.py
305
4.09375
4
def leiaint(num): valor = 0 while True: if num.isnumeric(): valor = int(num) break if num.isnumeric() is False: num = input('diga um numero: ') return valor n = input('diga um numero: ') print(f'o numero que voce digitou é: {leiaint(n)}')
88c0171ef22e44f511e63c3b48cfb02f08c8ce62
matheus-valentim/projetos-python
/pequenos projetos/identificar valores.py
526
3.75
4
lista = [] maior = menor = menorP = maiorP = 0 for n in (range(0, 5)): lista.append(int(input(f'diga um valor para a posição {n}: '))) if n == 0: maior = menor = lista[n] menorP = maiorP = n else: if lista[n] > maior: maior = lista[n] maiorP = n elif...
4eced5949a2c098e011e1212d723035c034420e4
matheus-valentim/projetos-python
/pequenos projetos/cadastrador.py
1,001
3.65625
4
pessoas = {} lista = [] contador = 0 media = soma= 0 while True: pessoas.clear() print('=' * 30) contador += 1 pessoas['nome'] = input('nome: ').strip() pessoas['idade'] = int(input('idade: ')) soma += pessoas['idade'] pessoas['sexo'] = input('sexo (M/F): ').strip().lower()[0] while pe...
82b065a5066fdd293e6e63f152024b90c639637d
matheus-valentim/projetos-python
/pequenos projetos/pedra papel e tesoura.py
866
3.796875
4
from random import choice e = input('escolha um \nA)pedra \nB)papel \nC)tesoura \nqual a sua escolha? ').strip().upper() p = 'pedra' pa = 'papel' t = 'tesoura' L = [p, pa, t] c = choice(L) if e == 'A': print('voce escolheu pedra') if c == 'pedra': print('voces empataram!!') elif c == 'papel': ...
2a7ecc1aba82299a38a61c52a290fa07ed113182
csaiprashant/regression_python
/logistic_regression.py
1,552
3.515625
4
import pandas as pd import numpy as np from matplotlib import pyplot as plt df = pd.read_csv('university_admissions.txt', header=None, names=['x1', 'x2', 'y']) X = np.array(df[['x1', 'x2']]) y = np.array(df['y']) y = y.reshape(y.size, 1) X = np.hstack((np.ones((y.size, 1)), X)) theta = np.zeros((X.shape[1],...
1b511d37c044e4ca3f9f7ad64d8fee479ecb878c
mjayhhh/PycharmProjects
/pythonProject/Day02/Test.py
2,144
4.09375
4
""" 입출력 1. 출력 print( 출력하고 싶은 데이터 ) 2. 입력 input() : 입력받기 [ 문자로 입력받음 ] -> int(input()) 로 int형으로 변경 가능 3. 변수[저장소/변하는값] <----> 상수[저장소/고정값] # 1. 입력받기 input("이름 : ") # 2. 입력받은 값을 변수에 저장 & 출력 이름 = input("이름 : ") print("당신의 이름 : " + 이름) # 3. 출력 코드에 입력받고 받은 값을 출력 print("이름 : " + input("이름 : ")) # 4.입력받은...
3e8228502aaf5702c9ed36009326148b53019dca
mjayhhh/PycharmProjects
/pythonProject/문제 300/문제 21~40 ( 문자열 ).py
3,447
4.03125
4
# 21. letters가 바인딩하는 문자열에서 첫번째와 세번째 문자를 출력하세요 letters = 'python' print(letters[0],letters[2]) # 22. 자동차 번호가 다음과 같을 때 뒤에 4자리만 출력하세요. license_plate = "24가 2210" print(license_plate[4],license_plate[5],license_plate[6],license_plate[7], sep='') # 23. 아래의 문자열에서 '홀'만 출력하세요. string = "홀짝홀짝홀짝" for i in string: if i == "...
6057669b5500193fcefd909c4e8a306d594af6a1
mjayhhh/PycharmProjects
/pythonProject/game/계산기.py
5,199
4.1875
4
# 계산기 만들기 # 1. 화면 만들기 # 2. 계산창 버튼 추가 # 3. 버튼에 명령 추가하기 # 4. 함수( 여러개의 코드 묶음 ) # 5. 계산 창에 클릭된 값을 저장 import tkinter as tk from tkinter import * # tkinter : UI[이미지] from tkinter import ttk operation = [] number_list = [] def button_pressed(value): if value == "AC": number.delete(0,"end") ...
04ab2e4467f75b16ed3ccea541c3ab5c7293d39c
mjayhhh/PycharmProjects
/pythonProject/1차 2급/1차 2급 1_initial_code.py
781
3.65625
4
#You may use import as below. #import math def solution(shirt_size): answer = [] for i in range(6): answer.append(0) for i in range(len(shirt_size)): if shirt_size[i] == "XS": answer[0] += 1 elif shirt_size[i] == "S": answer[1] += 1 elif shirt_size[i]...
7ddaf5cd2d7df219655e1ac919b6ec1e352f1ac8
mjayhhh/PycharmProjects
/pythonProject/Day12/Quiz.py
10,163
3.625
4
""" # 1. "비트코인" 문자열을 화면에 출력하면 print_coin() 함수를 정의해라. def print_coin(): print("비트코인") """ """ # 2. 1번에서 정의한 print_coin 함수를 호출해라 print_coin() """ """ # 3. 1번에서 정의한 print_coin을 100번 호출해라 for i in range(100): print_coin() """ """ # 4. "비트코인" 문자열을 100번 화면에 출력하는 print_coins() 함수를 정의해라. def print_coins(): for i...
bbd3196abd14b37a84124fbb1b6c1d2b278c90f1
dbaron15/Geocomp1-F18
/dbaron_finalproject.py
3,446
3.875
4
#SDSS AHP implementation from __future__ import division import numpy as np import matplotlib.pyplot as plt print ("Welcome to Deana's GTECH731 Final Project!") print ("Part 0: Load the raster criteria") #Load the rasters into Python as numpy arrays using arcpy #I struggled with this immensely, therefore I'm generat...
b079b932056b052e9425f8a7cecae6ca592be4f2
BatheFu/bio_learn
/w2/strand.py
4,526
3.59375
4
def dna_rv_complement(pattern): """return the reverse complement""" project_d = {'A': 'T', 'C': 'G'} project_d.update({v: k for k, v in project_d.items()}) rv_pattern = '' for i in range(-1, -len(pattern)-1, -1): rv_pattern = rv_pattern + project_d[pattern[i]] return rv_pattern def coun...
d24bf6ef536dd7e3ea4ed10453526709aac9ece5
dylansanderson/openCV
/openCV-face.py
1,905
3.515625
4
import numpy as np import cv2 import time """ This program uses openCV to detect faces, smiles, and eyes. It uses haarcascades which are public domain. Haar cascades rely on xml files which contain model training data. An xml file can be generated through training many positive and negative images. Try your built-in c...
96e06fb5cd013b4c85cb1046446ed12be0c7aec2
randhawp/rl-gridworlds
/basics/policy_iteration_dynamicP_deterministic.py
3,719
3.875
4
''' - Synchronous Dynamic programming - that is sweep across all states - Deterministic actions - i.e all possible actions have equal probability This example illustrates policy iteration with with the help of a [ n x n ] grid The top left and bottom right are terminal states with value 0 The agent is following a unif...
06252c2fe64aac6a408579656c4415b0f10b4abe
Etril/hangman
/guesses.py
673
3.5
4
import math import random initial_list=[] for i in range (0,101): initial_list.append(i) guesses=0 while True: guesses+=1 n=random.choice(initial_list) q=input("Is your number {}? If not, is it greater(g) or lower(l)".format(n)) if q=="y": print ("I've won in {} gu...
cb8a0d965ca2b62c8b50e54621e50f524366727d
tcaserza/coding-practice
/daily_coding_problem_20.py
1,003
4.125
4
# Given two singly linked lists that intersect at some point, find the intersecting node. The lists are non-cyclical. # # For example, given A = 3 -> 7 -> 8 -> 10 and B = 99 -> 1 -> 8 -> 10, return the node with value 8. # # In this example, assume nodes with the same value are the exact same node objects. # # Do this ...
3b5e97f33277ee345b584501f9495e4f38c0b0e6
tcaserza/coding-practice
/daily_coding_problem_12.py
882
4.375
4
# There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. # Given N, write a function that returns the number of unique ways you can climb the staircase. # The order of the steps matters. # # For example, if N is 4, then there are 5 unique ways: # # 1, 1, 1, 1 # 2, 1, 1 # 1, 2, 1 # 1,...