blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9285e410c072e319bcebff3406cbb78203bc3b80
sriniketh28/Python-DSA
/DSA-Questions/check-if-a-binary-tree-is-BST.py
506
3.8125
4
class Node: def __init__(self, data): self.left = None self.right = None self.data = data temp_arr = [] def inorder(root): if root: inorder(root.left) temp_arr.append(root.data) inorder(root.right) def isBST(root): inorder(root) if temp_arr == sorted(tem...
101363890a185c21eb70663bee68cf2a26b5029a
sriniketh28/Python-DSA
/Sorting-Algorithms/bubble-sort.py
250
4.0625
4
def bubble_sort(arr): for i in range(len(arr)): for j in range(0,len(arr)-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr arr = [3,4,2,5,1] print(bubble_sort(arr))
86bcd94779e49952234435f5aa4bcb4f7f355dee
balajich/dlaicourse
/balaji/01-Build and train neural network models using TensorFlow 2.x/02-Build, compile and train machine learning (ML) models using TensorFlow/05-Simple Neural Network/02_preprocess_diabetes _regression_neural_network.py
896
3.9375
4
""" Preprocess the data before training the model """ import keras from sklearn import datasets # load data set and split into train and test diabetes_X, diabetes_y = datasets.load_diabetes(return_X_y=True) diabetes_X_train = diabetes_X[:-20] diabetes_X_test = diabetes_X[-20:] diabetes_y_train = diabetes_y[:-20] diab...
1b259c638fb79a858b740da412d070bbb8c81461
Dev-Jang/BAEKJOON-Algorithm
/๋‹จ๊ณ„๋ณ„๋กœ ํ’€์–ด๋ณด๊ธฐ/02. if๋ฌธ/05. ์„ธ ์ˆ˜.py
195
3.734375
4
#10817 A,B,C = map(int, input().split()) if (B <= A <= C) or (C <= A <= B): print(A) elif (A <= B <= C) or (C <= B <= A): print(B) elif (A <= C <= B) or (B <= C <= A): print(C)
a898774c994432b47dd94b5eb09aef61dd21f55f
S0L4RE/mrbutler-bot
/bot/mrb/fun/dice.py
3,496
3.75
4
""" Copyright 2017 Peter Urda 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 agreed to in writing, software dis...
22dd709d99f557c4da3a3d94870ad0a2c38e9fa0
Greenlightrj/SoftDesSp15
/toolbox/word_frequency_analysis/frequency.py
2,316
4.1875
4
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string from pattern.web import URL from os.path import exists def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The...
b08fab5d393cc43928331321cdfe2d01403c20b8
d3m0n4l3x/python
/file_management.txt
468
3.875
4
#!/usr/bin/python #https://www.tutorialspoint.com/python/os_file_methods.htm import os # Rename a file from test1.txt to test2.txt os.rename( "test1.txt", "test2.txt" ) # Delete file test2.txt os.remove("text2.txt") # Create a directory "test" os.mkdir("test") # Changing a directory to "/home/newdir" os.chdir("/hom...
9afc45506ea176a8631461120990c18ce26b7941
d3m0n4l3x/python
/loop_while.txt
203
4
4
#!/usr/bin/python i = 1 while i < 6: print(i) i += 1 #Break i = 1 while i < 6: print(i) if i == 3: break i += 1 #Continue i = 0 while i < 6: i += 1 if i == 3: continue print(i)
198383efc3ff47628cc64a6b83beba3ed7a188d6
kpbochenek/algorithms
/codingame/medium/apu-init-phase.py
706
3.59375
4
width = int(input()) # the number of cells on the X axis height = int(input()) # the number of cells on the Y axis mapa = [] def print_node(y, x): rx, ry = -1, -1 bx, by = -1, -1 for mx in range(x+1, width): if mapa[y][mx] != '.': rx, ry = mx, y break for my in range(...
26256947e5ffe19090c00220e691618c66ea1ac6
ManasVardhan/Python-Scripts
/renamer.py
619
4.3125
4
# Pythono3 code to rename multiple # files in a directory or folder # importing os module import os # Function to rename multiple files def main(): pathOfFiles = input("Enter directory : ") pathOfFiles+="\\" for filename in os.listdir(pathOfFiles): dst = filename[f...
526f935b0af7b48325089c958f6328506c5215af
CaptainUnbrauchbar/clingo
/libpyclingo_cffi/clingo/symbolic_atoms.py
5,382
3.546875
4
''' Functions and classes to work with symbolic atoms. Examples -------- >>> from clingo.symbol import Function, Number >>> from clingo.control import Control >>> ctl = Control() >>> ctl.add('base', [], """\\ ... p(1). ... { p(3) }. ... #external p(1..3). ... ... q(X) :- p(X). ...
cdf2c5d96ca765bff8dd91e2b9723a44c7421bc6
Hokhanyan/Python
/heap.py
553
3.96875
4
def heapify(array, n, i): largest = i l = 2 * i + 1 r = 2 * i + 2 if l < n and array[i] < array[l]: largest = l if r < n and array[largest] < array[r]: largest = r if largest != i: array[i], array[largest] = array[largest, array[i] heapify(array, n, larges...
fa3bbbec66db85a8d9f0cc4871e81d85b6367cfd
AdrienBertaud/Find-the-Higgs-boson-with-machine-learning
/evaluation.py
6,580
3.5
4
# -*- coding: utf-8 -*- import numpy as np from proj1_helpers import * from implementations import * import random def calculate_accuracy(w, x_test, y_test): """ Calculates the classification accuracy for a trained model on a given test set. """ y_pred = predict_labels(w, x_test) total_number_predi...
7e617408916273a1232e8efc795b60e2c39406bc
Amenable-C/software-specialLectureForPython
/test0812.py
379
3.921875
4
score1 = int(input("์˜์–ด ์ ์ˆ˜ ์ž…๋ ฅ : ")) score2 = int(input("์ˆ˜ํ•™ ์ ์ˆ˜ ์ž…๋ ฅ : ")) if((score1 + score2) >= 100): if((score1 >= 40) and (score2 >= 40)): print("ํ•ฉ๊ฒฉ์ž…๋‹ˆ๋‹ค!") elif((score1 < 40) and (score2 >= 40)): print("์˜์–ด ๊ณผ๋ฝ ๋ถˆํ•ฉ๊ฒฉ") else: print("์ˆ˜ํ•™ ๊ณผ๋ฝ ๋ถˆํ•ฉ๊ฒฉ") else: print("์ด์  ๋ฏธ๋‹ฌ ๋ถˆํ•ฉ๊ฒฉ")
fe171053c1a20f1223088153d0506c0d6fffe577
Amenable-C/software-specialLectureForPython
/ch009.py
178
3.96875
4
days = int(input("How many days are there?")) hours = days * 24 minutes = hours * 60 seconds = minutes * 60 print("hours : ", hours, "minutes : ", minutes, "seconds : ", seconds)
5efed86ecacc83475de4dcb2b58b548ec1b6670b
Amenable-C/software-specialLectureForPython
/ch015.py
188
4.1875
4
color = input("What is your favorite color? ") if(color == "red" or color == "RED" or color == "Red"): print("I like red too.") else: print("I don't like", color,", I prefer red")
a9a9b366c0b5f6e9d118e20fa2d7875810a21a5b
JoaoFelipe-AlvesOliveira/LearningPython
/While/exercicio5.py
541
3.71875
4
contador = 0 while contador<50: p1=float(input("Digite a nota da sua prova P1")) p2=float(input("Digite a nota da sua prova P2")) pap=float(input("Digite a nota do seu PAP")) atividade=float(input("Digite a nota da atividade")) media = p1 *0.3 + p2*0.3 + pap*0.2 + atividade*0.2 contador = cont...
b3d62fd19e076e44a6df676ef633225392de8206
JoaoFelipe-AlvesOliveira/LearningPython
/Vetores/Vetores.MostrandoTamanho.py
235
3.84375
4
print ("\nMostrando o tamanho do vetor") vetPrecos = [] contador = 0 while contador <5: valor = float(input("Digite o valor")) vetPrecos.insert(0,valor) contador = contador +1 print ("Tamanho do vetor =", len(vetPrecos))
f5a07abd0ea1949e5dc7b8210e2b1f542ab5b5ea
JoaoFelipe-AlvesOliveira/LearningPython
/While/exercicio2.py
203
4.09375
4
numInt=int(input("Digite o nรบmero inteiro para tabuada")) numMult=1 while numMult <= 10: calculo = numMult*numInt print("A tabuada รฉ", numInt, "x",numMult ,"=", calculo) numMult=numMult+1
aaf0190603e3c90e9345baf45c5960d7048f710f
joaodematejr/LPII
/E5.py
143
4.09375
4
valor = int (input("Digite um nรบmero inteiro: ")) if valor >= 0: print ("O nรบmero รฉ positivo") else: print("O nรบmero รฉ negativo")
015e42448bd63e1da7f35040b91b6f5714f66955
asha2003/asmagar
/test1.py
115
3.53125
4
str1 = input() str2 = " " flen = str1.find(str2) length = len(str1) print(str1[flen:length], end=" "+str1[0:flen])
c1fe5b95d28788b3ffee4c6001cfb321812fc9eb
asha2003/asmagar
/test10.py
189
3.609375
4
color_list_1 = set(["White", "Black", "Red"]) color_list_2 = set(["Red", "Green"]) for ele in color_list_1: if ele in color_list_2: print() else: print(ele, end=" ")
e75c74a34ba2cd0a50a81168ced25d0bdec7cdac
asha2003/asmagar
/list2.py
64
3.5
4
x=[1,2,3,4,5,6] mul=1 for i in x: mul=mul*int(i) print(mul)
19dac6a71e209f1d53dd190fc78996c5b55c9b9e
VladZg/Flask_project
/Flask_API_v3/test.py
608
3.6875
4
import sqlite3 connection = sqlite3.connect('data.db') cursor = connection.cursor() create_user = 'INSERT INTO users VALUES (NULL, ?, ?)' users = [ ('anatolii', '123'), ('masha', '456'), ('dasha', 'qwe') ] cursor.executemany(create_user, users) for row in cursor.execute('SELECT * FROM users'): print(...
7d39d247eda061643b9c1157ccc6674b7d29409f
aayushakrrana/hangman
/hangman.py
4,327
3.765625
4
import string from words import choose_word from images import IMAGES import re import sys import random def is_word_guessed(secret_word, letters_guessed): a=set(secret_word) b=set(letters_guessed) if(a==b): print(" * * Congratulations, you won! * * ", end='\n\n') sys.exit() ...
86dcfcf780fec925339ff5b7404ebb21d73d5313
JustLeah/GROUP10
/userInterface.py
636
4.09375
4
import os import tkinter #create a new object called window window = tkinter.Tk() mycolor = '#%02x%02x%02x' % (223,74,90) window.configure(background=mycolor) #Add a title, set the size and add a logo window.title("COMSC Learning Styles") window.geometry("400x600") window.wm_iconbitmap('assets/cardiff.ico') #add a ...
bcd208d07fb0463a2aee9aefec0316003974093b
Davitkhachikyan/HTI-1-Practical-Group-2-Davit-Khachikyan
/homework_2/stools.py
302
3.90625
4
def stools(height): int_list = [] summery = 0 for i in height: int_list.append(int(i)) max_height = max(int_list) for i in int_list: x = max_height - i summery += x return summery user_input = input("Enter heights: ").split() print(stools(user_input))
cb110cdb71af8de972cb3ee7818665f732942155
Davitkhachikyan/HTI-1-Practical-Group-2-Davit-Khachikyan
/homework_1/age.py
128
3.828125
4
year = input("Enter year: ") if year[-2:] == "00": age = int(year) // 100 else: age = int(year) // 100 + 1 print(age)
2d6566ba665d4abd57b6d4abac10a4f74101ab0b
ElBell/Assessment1
/src/tests/test_part1/test_basic_array_utils.py
1,118
3.5
4
from typing import List from unittest import TestCase from src.main.part1.basic_array_utils import BasicArrayUtils class TestBasicArrayUtils(TestCase): def test_get_first(self): expected: str = "The" input_array: List[str] = ["The", "quick", "brown"] actual: str = BasicArrayUtils.get_fi...
8d6c7d561a8f6a0ed78c9829ea012cef8f4caf68
ElBell/Assessment1
/src/tests/test_part1/test_integer_utils.py
696
3.734375
4
from unittest import TestCase from src.main.part1.integer_utils import IntegerUtils class TestIntegerUtils(TestCase): def test_get_sum(self): input_int: int = 5 expected: int = 15 actual: int = IntegerUtils.get_sum(input_int) self.assertEqual(expected, actual) def test_get_p...
4623fe454be715cb29d7fe97bb094de5115ee318
Python-Chicago-September-2017/fun-with-functions-nathan
/fun-with-functions.py
754
4.21875
4
def odd_even(): for num in range(1, 2001): if num % 2 == 0: num_as_str = str(num) print "Number is " + num_as_str + ". This is an even number." else: num_as_str = str(num) print "Number is " + num_as_str + ". This is an odd number." # odd_even() a =...
b485342c24ffb4d9706ce1aa2d23d2c6a9a87a1e
joshlevin91/Project-Euler
/p29.py
169
3.609375
4
def main(): end = 100 terms = set() for a in range(2, end+1): for b in range(2, end+1): terms.add(a**b) print(len(terms)) main()
80b4a7871b944908191e706806e46044c634d3b4
JorgeCCV/Taller2
/Cuadrado.py
245
3.984375
4
####Definir una funciรณn para un cuadrado de lado n: import turtle t=turtle.Pen() a=int(input("Ingrese la longitud del cuadrado:")) size=a def micuadrado(size): for x in range(1,5): t.forward(size) t.left(90) micuadrado(a)
d2cba6de2660bd752782c1fd3ac66baac76c099b
robmcl4/Project-Euler
/19/main.py
2,589
3.796875
4
#! /usr/bin/python3.3 """ Project Euler #19 Author: Robert McLaughlin <robert@sparkk.us> Consult LICENSE file for license. """ import datetime MON, TUE, WED, THU, FRI, SAT, SUN = range(7) ONE_WEEK = datetime.timedelta(days=7) MONTHS_WITH_THIRTY = [9, 4, 6, 11] MONTHS_WITH_THIRTY_ONE = [1, 3...
a1c5b2b355746b50c881eecc5663072293f359f6
Cenibee/PYALG
/python/fromBook/chapter6/string/1_palindrome/1-s.py
370
3.53125
4
class Solution: def isPalindrome(self, s: str) -> bool: filtered_str = "".join(filter(str.isalnum, s)).lower() return filtered_str == filtered_str[::-1] print(Solution.isPalindrome(None, "A man, a plan, a canal: Panama")) print(Solution.isPalindrome(None, "A man, a plan, a cnal: Panama")) print(Sol...
adbda106f75a7e3a383f4639340a288171f0d7c7
Cenibee/PYALG
/python/fromBook/chapter6/graph/35-combinations/35-m-2.py
1,013
3.703125
4
from typing import List import copy # ์บ์‹œํ•˜๋ฉด ๋นจ๋ผ์ง€๋‚˜ ํ–ˆ๋Š”๋ฐ copy.deepcopy๊ฐ€ ์ƒ๊ฐ๋ณด๋‹ค ๋น„์‹ธ๊ตฐ class Solution: cache = {} def combine(self, n: int, k: int) -> List[List[int]]: if (n, k) in self.cache: return copy.deepcopy(self.cache[(n, k)]) # k = 1 ์ผ ๋• 1~n ๊นŒ์ง€ ๋ชจ๋“  ์ˆ˜ ํ•˜๋‚˜๋งŒ ๊ฐ€์ง€๋Š” ๋ฆฌ์ŠคํŠธ์˜ ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜ if k == ...
2121479d28d584d32c6e9fab70eaff0b69f9e986
Cenibee/PYALG
/python/fromBook/chapter6/deque, ordered queue/27-merge-k-sorted-lists/27-m.py
1,045
3.890625
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next from typing import List import sys class Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: ''' lists์˜ ๊ธธ์ด๋Š” k ์ด๊ณ , ๋‚ด๋ถ€์˜ ์—ฐ๊ฒฐ ๋ฆฌ์ŠคํŠธ๋“ค์€ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌ ๋˜์–ด...
de2e70696f7fccae37062e3b07fdae331a072e75
Cenibee/PYALG
/python/fromBook/chapter6/sort/67-intersection-of-two-arrays/67-m.py
336
3.6875
4
from typing import List class Solution: def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]: m = set() for num in nums1: m.add(num) ans = [] for num in nums2: if num in m: ans.append(num) m.remove(num) ...
6e09464b4be5e75f8362bfec840e602b5f1ec27c
Cenibee/PYALG
/python/fromBook/chapter6/string/1_palindrome/1-m.py
1,067
3.78125
4
def isPalindrome(self, input: str) -> bool: def alnum_gen(input:str, index:int, to:int): i = index while True: if i < -1 or i >= len(input): return "end" if input[i].isalnum(): yield (i, input[i].lower()) i = i + to head = alnum...
49c4b86d7eed7eedaa37e8cb692607199e60740a
Cenibee/PYALG
/python/study/5. bfs, dfs/559. N-ary ํŠธ๋ฆฌ ์ตœ๋Œ€ ๊นŠ์ด/bfs.py
480
3.59375
4
from typing import Deque class Node: def __init__(self, val=None, children=None): self.val = val self.children = children class Solution: def maxDepth(self, root: 'Node') -> int: if not root: return 0 ans = 0 q = Deque([root]) while q: for _ in ran...
a540e0ab908d962dc8875d91aeb8bcc2a65d157b
Cenibee/PYALG
/python/fromBook/chapter6/graph/33-letter-combinations-of-a-phone-number/33-m.py
785
3.59375
4
from typing import List class Solution: def letterCombinations(self, digits: str) -> List[str]: if not digits: return [] alpha_dict = { '2': 'abc', '3': 'def', '4': 'ghi', '5': 'jkl', '6': 'mno', '7': 'pqrs', ...
5741b3c172d9e7425520ff54e87bdb20b5030baa
Cenibee/PYALG
/python/fromBook/chapter6/linked_list/13_palindrome_linked_list/13-m.py
2,265
3.90625
4
from typing import List class ListNode: def __init__(self, val=0, next=None, list=None): self.val = val self.next = next class Solution: def isPalindrome(self, head: ListNode) -> bool: ''' 1. ์‚ฌ์ด์ฆˆ ๊ฐ€์ ธ์˜ค๊ณ  2. ์ค‘์•™๊นŒ์ง€ ํฌ์ธํ„ฐ ๋ฐ˜์ „ํ•˜๊ณ  3. ์ค‘์•™์—์„œ๋ถ€ํ„ฐ ๋น„๊ต ''' # ๊ธธ์ด๊ฐ€ 0, 1...
40898a5f69c3ee460f446ac7828b5c2655c115cf
AmbatiSathwik/python
/leetcode/may_day20.py
888
3.625
4
# 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 height(self,root): if root is None: return 0 else : lDepth = sel...
9fab9cc5a1f1abc1134c17131299781f48ba5acf
momosang98/MATH6004
/HW4_1.py
834
3.546875
4
import numpy as np from math import * def power_method(mat,X0,tol): i = 0 x = [X0] error = 1 while error > tol: i += 1 y = np.dot(mat, x[i-1]) m = np.linalg.norm(y, ord=2) # m = np.linalg.norm(y,ord=np.inf) x.append(y / m) error = abs(np.linal...
f36eda832f1edb77b57a3e6ad249ee8d2d6fd519
rcmoura/aulas
/prg_peso.py
201
3.796875
4
h = float(input("Entre com a Altura: ")) s = input("Entre com o sexo M / F -> ") if s == 'M' or s == 'm': peso = 72.7 * h - 58 else : peso = 62.1 * h - 44.7 print ("Seu peso ideal รฉ: ", peso)
1b7c642fb2868581b823d695e0ddc364e3fa579d
rcmoura/aulas
/vetor5.py
111
3.65625
4
n = eval(input('Digite um numero: ')) lista = [] for i in range(2,n+1,2): lista = lista + [i] print (lista)
c18cc6e68b8af2a9827d14640b4a08044d969ce4
rcmoura/aulas
/mat4.py
197
3.953125
4
n = int(input('Digite a dimensรฃo n da matriz: ')) m = int(input('Digite a dimensรฃo m da matriz: ')) matriz = [] for i in range(n): matriz.append([0]*m) for i in range(n): print(matriz[i])
918151f25905ca560e0b422a22a8a967f5559bbc
rcmoura/aulas
/prg_exemplo_for_1.py
182
3.71875
4
# Estrutura de repetiรงรฃo for # # for VARIAVEL in (FAIXA-DE-VALORES): # INSTRUร‡รƒO # # OS VALORES PODEM SER LISTADOS EXPLICITAMENTE for x in (0,1,2,3,4,7,154,74): print(x)
e5af2d35a77c467c5f8772b8c323ad7c88e7cb45
rcmoura/aulas
/func5.py
301
3.546875
4
def primos(n): p = 1 yield 2 d = 3 b = 3 while p < n: if b % d == 0: if b == d: yield b p += 1 b += 2 elif d < b: d += 2 else: b += 2 for primo in primos(400): print(primo)
bc83c75e93d8be0d15d910a46dc2509f2ae28595
rcmoura/aulas
/prg_calculadora.py
1,125
4.28125
4
# programa calculadora print("+ para Somar") print("- para Subritair") print("* para Multiplicar") print("/ para Dividir") resp = input ("Digitar opรงรฃo: ") if resp == "+": a = float(input("Digite 1o numero: ")) b = float(input("Digite 2o numero: ")) soma = float(a + b) print ("Soma: ",soma) else: if...
df7841c1ba9a0cd1fb3c0f87fe72b4d031b03772
rcmoura/aulas
/vetor10.py
274
3.875
4
a = [] b = [] for i in range(0,5): a.append(float(input("Informe o {}ยบ Valor em graus Celsius no vetor A: ".format(i + 1)))) for i in range(0,5): b.append(a[i] * 1.8 + 32) for i in range(0,5): print('A[{}] = {}ยบC igual a B[{}] = {}ยบF'.format(i, a[i],i,b[i]))
fc3ed5ecaa9f872f3a5d39290b480040fb09c90d
ed1rac/Estrutura-de-Dados-com-Massanori
/Selection_Sort.py
1,546
3.75
4
import unittest from random import shuffle def selection_sort(seq): ''' Funรงรฃo tem como entrada uma lista de numeros e retorna a mesma lista organizada, faz iteraรงรฃo de n-1 em n vezes. Funรงรฃo tem tempo em O(n**2) e espaรงo O(1) :param seq: lista como numeros :return seq: retorna mesma l...
4871d9018ffebb749b6745c7d134e617af9ea6fe
team31153/test-repo
/Ryan/RyanChapter5HW/7barChart.py
2,158
4.15625
4
#!/usr/bin/env python3 import turtle def draw_bar(t, height): """ Get turtle t to draw one bar, of height. """ if height >= 200: t.color("blue", "red") t.begin_fill() # Added this line t.left(90) t.forward(height) t.write(" "+ str(height)) t.right(90...
07ec31f6253428e3e0566f579ce8ee356adb8d5d
team31153/test-repo
/Aaditya/C5P1.py
363
4.09375
4
#!/usr/bin/env python3 x = input("WHat is the day") x = int(x) def day(x): if x == 1: print("Sunday") if x == 2: print("Monday") if x == 3: print("Tuesday") if x == 4: print("Wednesday") if x == 5: print("Thursday") if x == 6: print("Friday") i...
3e33c1d625bc816039676822c9cccec0c07a3f94
team31153/test-repo
/Aaryan/Chapter4HW/C4Problem4.py
420
3.90625
4
#!/usr/bin/env python3 import turtle def draw_square(turtle, size): for i in range(4): turtle.forward(size) turtle.left(90) if __name__ == "__main__": wn = turtle.Screen() wn.bgcolor("lightgreen") alex = turtle.Turtle() alex.color("blue") alex.pensize(3) boxes = 20 for...
a11c473ba9cd68f232b3834eec3a35bbadde8aff
team31153/test-repo
/Ryan/RyanChapter4HW/drawPolygon.py
358
4.15625
4
#!/usr/bin/env python3 import turtle import time wn = turtle.Screen() pen = turtle.Turtle() pen.pensize(5) pen.speed(7) sides = 8 length = 50 def draw_poly(t, n, sz): exteriorAngle = 360 / n interiorAngle = 360 - exteriorAngle for i in range(n): t.forward(sz) t.right(interiorAngle) draw_p...
b7c38323d30a068390416e0e996415020dd3d537
team31153/test-repo
/Aaryan/Chapter5HW/C5Problem8.py
701
3.9375
4
#!/usr/bin/env python3 import turtle def drawBar(t, height): t.begin_fill() t.left(90) t.forward(height) t.write(str(height)) t.right(90) t.forward(40) t.right(90) t.forward(height) t.left(90) t.end_fill() t.right(10) def fillColor(t,height): if height >=200: ...
9180e8c037aed645ff53440ce02a25ef923d7cc7
dhirajberi/Hackerrank-Solutions
/set.py
273
3.9375
4
def average(array): sum=0 avg=0 s=set(array) for value in s: sum=sum+value avg=sum/len(s) return avg if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) result = average(arr) print(result)
c7b715daa27a90d0bdef62f5eba9cda5beb3d5d7
leemiracle/use-python
/taste_python/camelcase_to_underscore.py
3,712
3.921875
4
""" ๅฐ†jsonไธญ็š„้ฉผๅณฐๅ‘ฝๅ็š„ๅญ—็ฌฆไธฒ่ฝฌๆขๆˆpythonic code""" import re first_cap_re = re.compile('(.)([A-Z][a-z]+)') all_cap_re = re.compile('([a-z0-9])([A-Z])') def camelcase_to_underscore(name): """ ๅฐ†้ฉผๅณฐๅ‘ฝๅ่ฝฌๆขไธบpythonic :param name: :return: """ s1 = first_cap_re.sub(r'\1_\2', name) return all_cap_re.sub(r'\1_...
6de70d22238084479aee667739e598b67869eb5d
YFCbingyi/test_own
/python/learn/day03/keyWordParam.py
803
3.71875
4
#!/usr/bin/env python3 # coding=utf-8 def person(name,age,**kw): print('name : ',name,' age : ',age,' other ',kw) person('chenbingyi',12) person('chenbingyi',12,city='beijing',jiguan='shanxi') extra = {'city':'beijing','sex':'man'} person('cby',89,**extra) def persons(name,age,**extra): if 'city' in extra...
8951e81f8a11c82a9de539847d63817415d2d542
YFCbingyi/test_own
/python/learn/day04/qushouwei.py
208
3.859375
4
#!/usr/bin/env python3 # coding=utf-8 def qushouwei(s): a = 0; while s[a] == ' ': a = a+1 b = -1; while s[b] == ' ': b = b-1 return s[a:b+1] print(qushouwei(' hello '))
23318c7c0c985dc40f3178884cf8afaf49ff7f78
JameelHKhan/Hello-User-in-Python
/due_date.py
498
4.1875
4
# Module 1 Assignment - Part 2 print("Enter the date the first assignment is due below:") day = input("Day (enter 2-digit value): ") month = input("Month (enter 2-digit value): ") year = input("Year (enter 4-digit value): ") print("For the time, enter the 2-digit value for each line below:") timeHours = input...
1d101bb6253d58cfe19183b82fb49b71cbc5c9a6
ansonpak/code
/code/CheckDate.py
1,554
3.65625
4
y = int(input()) m = int(input()) d = int(input()) if m==1: if d>31: print("ๆ—ฅๆœŸ้Œฏ่ชค") else: print(str(y)+'/'+str(m)+'/'+str(d)) elif m==2: if(y%4==0 and y%100!=0) or (y%400==0 and y%4000!= 0): if d>29: print("ๆ—ฅๆœŸ้Œฏ่ชค") else: print(str(y)+'/'+str(m)+'/'+str(...
4985a76394c7a88189d8f9bcaaee8d41a83c2375
KITSKoushikChakrabarti/PythonJIRA
/FileDirectory.py
536
3.609375
4
import os from os import path filepath = os.getcwd() + "\\Reports" if(path.exists(filepath) == False): os.mkdir(filepath) print ("New folder created %s" % filepath) else: print ("Folder %s already exists" % filepath) # print ("The current working directory is %s" % path) # define the name of the direc...
9f15ec0fb4cd05689ac2dcbb71bdf2213eb1af79
anevolina/AmRuConverter
/make_constant_file.py
3,790
4.09375
4
""" There is a one-time running file, which takes all data from the file measurements.txt, read it line-by-line and compile JSON file with dictionary key = item, value = grams in 1 cup, separated by ':' symbol for multi-word items it should be the main initial item - for example, for 'Brown Sugar' we have to have singl...
aeed530ff055c7f0c3a07719454afb8c46167f9d
hotdl/EulerProject
/src/0034_Digit factorials.py
852
3.734375
4
#coding:utf8 # 145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. # # Find the sum of all numbers which are equal to the sum of the factorial of their digits. # # Note: as 1! = 1 and 2! = 2 are not sums they are not included. from common import costtime @costtime def main(): fact = lambda x: reduce(l...
a4cc185e126c37db2b859fcbe490c7f7d0cb38d0
hotdl/EulerProject
/src/0028_Number spiral diagonals.py
525
3.765625
4
#coding:utf8 # Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: # # 21 22 23 24 25 # 20 7 8 9 10 # 19 6 1 2 11 # 18 5 4 3 12 # 17 16 15 14 13 # # It can be verified that the sum of the numbers on the diagonals is 101. # # What is the sum of the ...
c3a9a30fbe2697e37020b8eff154d50e6b162b77
hotdl/EulerProject
/src/0031_Coin sums.py
830
3.59375
4
#coding:utf8 # In England the currency is made up of pound, ยฃ, and pence, p, and there are eight coins in general circulation: # # 1p, 2p, 5p, 10p, 20p, 50p, ยฃ1 (100p) and ยฃ2 (200p). # It is possible to make ยฃ2 in the following way: # # 1ร—ยฃ1 + 1ร—50p + 2ร—20p + 1ร—5p + 1ร—2p + 3ร—1p # How many different ways can ยฃ2 be made...
5ea7a3983b76f67c6b4e0b7f0196a66f0b0afa2a
hotdl/EulerProject
/src/common.py
1,003
3.65625
4
import math import time import functools def is_prime(num): if num < 2: return False if num == 2: return True if not num & 1: return False for x in range(3, int(math.sqrt(num))+1,2): if num % x == 0: return False return True def union_dict(dict1, dict2):...
29a27e70cca2407193a20470957ce4204aaad8df
nvalkishor/Guess-a-no
/program
375
4.03125
4
#!/user/local/bin/python import random x=random.randint(1,100) print("Guess a no betwee 1 to 100 ") Guess='False' while( Guess == 'false'): UG=raw_input("enter your guess>>") if x > UG : print("Your guess is low") else if x < UG: print("Your guess is high") else: print(You have guessed it ri...
0515ce9746184d5aefa75fd51e9a68b9da3ae8d3
sergey0222/SEC-Financial-Statement-Data-Sets-Tools
/datasets_lib.py
2,933
4.125
4
# Library of commonly used functions import csv def index_by_tree (string, dictionary, next_available_index): """ The function checks whether string is already present in a tree structure "dictionary". If yes, returns its index. If not, puts it to the structure and assigns it next_available_index. ...
ec1c97ad396056f9b81a01c97717f93c8935ca89
sharar-muhtasim/Python-Basics
/Swear Generator.py
346
3.9375
4
#computer insults the guy you hate from 3 choice insults import random def insult(name): swear = random.choice(['Fuck you', 'Tui ekta madarchod', 'Laura chush']) print(swear + ', ' + name) z = name return z print('Insert the name of someone you hate: ') guy_u_hate = input() x = insult(guy_u_h...
600861fe5b6fd054fc1064b38b33d4b1805d1c9c
DeSerg/mipt-solutions
/Term10/bioinformatics_tasks/problems/extern6.py
1,615
3.59375
4
from copy import copy def rawPermutationToList(raw_permutation): result = [] for element in raw_permutation: result.append(int(element)) return result def listPermutationToRaw(list_permutation): result = [] for element in list_permutation: if element < 0: result.appe...
f46054de736ca30426766c63955bc9b53f4d3eb9
satyamyesj/LeapYearCheck
/src/driver.py
273
4.09375
4
from leap_year import is_leap_year def main(): print("Enter year: ") input_year=int(input()) if is_leap_year(input_year): print("Entered year is leap year.") else: print("Entered year is not leap year.") if __name__=="__main__": main()
cc4fda08ef4179ac0ae221bec13695a6ce64a943
LCS2-IIITD/DiffQue-TIST
/Code/extras2/hypothesis_testing.py
2,158
3.984375
4
from scipy import stats import numpy as np from math import sqrt from scipy.stats import norm #each element of list would indicate how many times second question was more difficult than the first in the survey #sample list for 20 questions: #random_survey_results = [9,8,11,10,12] #proposed_survey_results = [18,15,16,1...
ff6daea362fefb0c549579c89aa0d1704a4b252d
18244088809/try
/tkinter/main.py
261
3.78125
4
import random num = random.randint(10,19) print(num) while True: result = int(input("่ฏท่พ“ๅ…ฅไธ€ไธชๆ•ฐๅญ—๏ผš")) if result>num: print("ๅคง") elif result<num: print("ๅฐ") else: print("ๅฏนไบ†") break
bdbd9375cc98b1b727d96ce876d2686bc9bb5134
dex-knows/ExEx-KET
/Clutz/GameState.py
9,441
3.953125
4
""" This class holds the game state of Clutz. Input for the map comes from a file specified when creating the GameState object. Input should be formatted as having the first line holding the values for the 'winning' and 'losing' rewards. The winning reward comes first, then the losing separated by a single spa...
98dae15e502ebf8b0582b75bbd7f704610ad6583
OleksiiKhatuntsev/BlackJackGame
/black_jack_class_library.py
3,376
3.703125
4
import enum import random class BlackJackConst(): """ Constants for BlackJack game LIMIT_POINT -> after this limit you lose the game ACE_DIFFERENCE -> Ace can be with value 1 and 11 DEALER_TURN_LIMIT -> after this limit dealer stop draw """ LIMIT_POINT = 21 ACE_DIFFERENC...
5dd4ffe261fb4224999086223d96968a79473813
AriosJentu/RoadMapping4A
/Scripts/Functions.py
2,645
4.0625
4
from . import BasicElements class Intersection: ''' Intersection - static class to intersect elements in 2d space ''' @staticmethod def intersect_line_line(line1: BasicElements.Line, line2: BasicElements.Line): '''Function to get intersection point of the lines, or detect there is no intersection, or say they ...
c9e08e19aaed3c5c7decaaf19412eb9726ced3e7
fiolisyafa/CS_ITP
/06-Classes/Lec_Toll Version2.py
2,638
3.5625
4
class Vehicle(): def __init__(self, category): self.category = category class Car(Vehicle): def __init__(self): super().__init__('car') class Bus(Vehicle): def __init__(self): super().__init__('bus') class Truck(Vehicle): def __init__(self): super().__init__('tru...
fed5a7c50c078d2a4a2c8cfd5a5bd76b6da46e52
fiolisyafa/CS_ITP
/06-Classes/LEC_Problem2_Search name.py
334
3.671875
4
#Data: #Rina Excell Sherlyn Farraz William Renato Ryan Fio Yoksan Nicholas #Find Renato data = ['Rina', 'Excel', 'Sherlyn', 'Farras', 'William', 'Renato', 'Ryan', 'Fio', 'Yoksan', 'Nicholas',] def search(name): for i in data: if i == name: print('Eureka') else: continue s...
286c5c9144f0fe95f9711ed13c1215022b06e430
fiolisyafa/CS_ITP
/04-Input and While Loops/7.8_Deli.py
262
3.546875
4
sandwich_orders = ['baloney', 'PBnJ', 'meatball', 'tuna', 'chicken',] finished_sandwiches = [] while sandwich_orders: sandwich_order = sandwich_orders.pop() print("I made your", sandwich_order, "sandwich.") finished_sandwiches.append(sandwich_order)
cd1362d84c94124e51b0b879c56f95b58c0959bc
fiolisyafa/CS_ITP
/07-UNO/main.py
1,632
3.875
4
from UNO import * print('LET\'S PLAY UNO\n') print('Basically this is a game of uno without any of the wildcards. HAVE FUN!\n') #Start by creating and shuffling all the cards main_deck = Cards() main_deck.standard_cards() #main_deck.wild() main_deck.shuffle() #distribute 7 cards to each player first_card = Start() m...
73af563d83868f0f2e1462b99cddf1996b20d6d1
fiolisyafa/CS_ITP
/02-If Statements/5.10_CheckingUsernames.py
372
3.703125
4
current_users = ['fiosvaio', 'cath_bro', 'notahero99', 'cocodraco', 'ntsyaad'] new_users = ['fiolisyafa', 'cath_bro', 'queen_ger', 'cocodraco', 'tea_coops'] for new_user in new_users: if new_user.lower() in current_users: print("This username has already been taken. Please choose a different username.") ...
75dde50f41a9bb58198eeed9e9af4e0737c5cc09
fiolisyafa/CS_ITP
/05-Functions/8.8_UserAlbums.py
379
4.03125
4
def make_album(name, title): """Return artist name and album name as a dictionary""" album = {name: title} return album while True: print("\nEnter a band and album. Press q to quit.") name = input('Band: ') if name == 'q': break title = input('Album: ') if title == 'q': ...
d8079f8cd7c2e342d5cda547fc51e5a1c4d79dd3
fiolisyafa/CS_ITP
/04-Input and While Loops/7.10_DreamVacation.py
479
3.890625
4
dream_vacation = {} polling_active = True while polling_active: name = input("What is your name? ") vacation = input("If you could visit one place in the world, where would you go? ") dream_vacation[name] = vacation question = input("Continue poll? ") if question == 'no': polling_active = Fa...
ebe2308eb73520a8749f1d9e8460373690f0858a
fiolisyafa/CS_ITP
/11-Quiz/F-HQ9+.py
172
3.734375
4
inp = input() if ("H" in inp or "Q" in inp or "9" in inp or "+" in inp) and 1 < len(inp) < 100: print("YES") else: print("NO") x = 5 y = 7 temp = x x = y y = temp
09454a8e13b3dbbf1a287fac21bf4dbcc9f77a99
fiolisyafa/CS_ITP
/01-Lists/4.11_MyPizzasYourPizzas.py
273
4.3125
4
pizza = ["cheese", "pepperoni", "hawaian"] friends_pizzas = pizza[:] pizza.append("marinara") friends_pizzas.append("NY style") print("My favorite pizzas are:") for i in pizza: print(i) print("\nMy friend's favourite pizzas are:") for i in friends_pizzas: print(i)
40da4bc652313afa5c169f94970415973cb46707
drizm-team/python-commons
/drizm_commons/utils/type.py
2,436
3.53125
4
""" Custom data-type implementations. ````python from drizm_commons.utils.type import * ```` """ from typing import TypeVar, Any, Mapping, Optional DictItem = TypeVar("DictItem") class AttrDict(dict): """ A dictionary whose keys can be accessed like attributes. Example: ````python obj =...
2db0b93dcd5624ea17f4bf2a2b8b07434308651c
saakshaat675/C102
/base.py
451
4.03125
4
# value=int(input("enter some number")) # if(value >100): # print("more than 100") # else: # print("less than 100") import random ch=10 number = random.randint(1, 9) print(number) while ch >5: guess=int(input("enter some number")) ch=ch-1 if(guess>number): print("your guess...
552de6dbe9a36170190f2817b94a19f57461cf69
ayushihasija03/Python-8-September-2018
/Introduction-to-Tkinter.py
442
3.84375
4
import tkinter from tkinter import * mainWindow = tkinter.Tk() mainWindow.title("Example Tkinter") headingLabel = tkinter.Label(mainWindow, text="Hello World") headingLabel.pack() userEntry = Entry(mainWindow) userEntry.pack() def fun(): # print("Hello") name = userEntry.get() print("Hello your name is:...
9fd45e513b53f36614a69be54764ee70a2908706
Young-Jo-Choi/data_analysis
/OOP/7_Inheritance.py
2,916
3.640625
4
""" [ํด๋ž˜์Šค ์ƒ์†] 1. ๋ถ€๋ชจ ํด๋ž˜์Šค๊ฐ€ ๊ฐ–๋Š” ๋ชจ๋“  ๋ฉ”์„œ๋“œ์™€ ์†์„ฑ์ด ์ž์‹ ํด๋ž˜์Šค์— ๊ทธ๋Œ€๋กœ ์ƒ์†๋œ๋‹ค. 2. ์ž์‹ ํด๋ž˜์Šค์—์„œ ๋ณ„๋„์˜ ๋ฉ”์„œ๋“œ๋‚˜ ์†์„ฑ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. 3. ๋ฉ”์„œ๋“œ ์˜ค๋ฒ„๋ผ์ด๋”ฉ 4. super() 5. Python์˜ ๋ชจ๋“  ํด๋ž˜์Šค๋Š” object ํด๋ž˜์Šค๋ฅผ ์ƒ์†ํ•œ๋‹ค. : ๋ชจ๋“  ๊ฒƒ์ด ๊ฐ์ฒด์ž„ MyClass.mro() --> ์ƒ์†๊ด€๊ณ„๋ฅผ ๋ณด์—ฌ์ค€๋‹ค. (์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ์ฃผ์„์— ๋ฒˆํ˜ธ๋ฅผ ๋งค๊ฒจ ์˜ˆ์‹œ๋ฅผ ์‚ผ์Œ) """ # ์ง€๋‚œ ๋ฒˆ๊ณผ ๊ฐ™์€ ํด๋ž˜์Šค(๋ถ€๋ชจ๊ฐ€ ๋จ) class Robot: """ __doc__์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ์ฃผ์„์ž„ ์ €์ž : ์ตœ ์ง...
1288f9b16cd2b5f67df4d47d7d92271a45868143
Young-Jo-Choi/data_analysis
/OOP/15_class_union_optional_final_type.py
1,853
4.28125
4
""" Class Type """ class Hello: def world(self) -> int: return 7 class World: pass # class์— ๋Œ€ํ•œ instance๋ฅผ ํƒ€์ดํ•‘ํ•  ๋•Œ ํด๋ž˜์Šค๋ช…์„ ์จ์ฃผ๋ฉด ๋œ๋‹ค. hello: Hello = Hello() # hello: "Hello" = Hello() ์—ญ์‹œ ๊ฐ€๋Šฅ world: World = World() def foo(ins: Hello) -> int: return ins.world() # ํžŒํŠธ๋ฅผ ์ฃผ๋ฉด .์ฐ์—ˆ์„๋•Œ ์ž๋™์™„์„ฑ ๊ฐ€๋Šฅ print(foo(hell...
f3d2c4fe607375bbedb64aaeddad026ce05607bc
WOdia/binary-search-lab
/binarySearch.py
2,334
3.75
4
class binarySearch(list): """Boiler plate for binary search class""" def __init__(self,size,step): self.size = size self.step = step #Generate list based on size supplied if self.size in self.toTwenty(): self.number_list = self.toTwenty() elif self.size in self.toFor...
febe4ab7e3ddabf04934a6b1a52ae026c089b5d7
GreedyKomodoDragon/pass-gen-rest-api
/functions/pass_gen.py
1,552
4.3125
4
import random def pass_gen(length: int, has_symbols: bool) -> str: """ A function for generating a password Args: length: int, denotes length of string returned has_symbols: bool, determines if symbols are included in the password Returns: A string of length: {length} with sy...
aaaf82ff94d295c19a42bfaea7841b3e77d061cd
gemo-yk/Leet_Code
/7_nums_revers/num_revers.py
1,176
3.5625
4
""" @project: Leet_Code @author: gemoy @file: num_revers.py Create on 2020/5/10 22:44 Contact author by e-mail: gemo-yk@outlook.com """ # class Solution(object): # def isPalindrome(self, x): # """ # :type x: int # :rtype: bool # """ # if x < 0: # return Fals...
966517ca08208dc6aa87497beb8291114e90645b
prabodhanm/Assignments
/Python/variabledemo.py
196
4
4
number = 10 x = "Welcome to python programming" print(number) print(x) y = 4.5 print("Value of Y is " + str(y)) name = input("Enter your name") print("Welcome" + name + " To python world")
0ada4da1901c2d69d77b0125c25641d17bdc562b
a233894432/learn_python
/learn_think_python_2e/ๅ…ƒ็ป„.py
536
3.90625
4
t1 = 'a', t2 = ('a') print(type(t1)) # <class 'tuple'> print(type(t2)) # <class 'str'> # ๅˆ—่กจๅ’Œๅ…ƒ็ป„ s = 'abc' t = [0, 1, 2] zip(s, t) for pair in zip(s, t): print(pair) # ๅฆ‚ๆžœ้œ€่ฆ้ๅކไธ€ไธชๅบๅˆ—็š„ๅ…ƒ็ด ไปฅๅŠๅ…ถ็ดขๅผ•ๅท๏ผŒๆ‚จๅฏไปฅไฝฟ็”จๅ†…ๅปบๅ‡ฝๆ•ฐ enumerate ๏ผš for index, element in enumerate('abc'): print(index, element) # ๅญ—ๅ…ธๅ’Œๅ…ƒ็ป„ d = {'a': 0, 'b': 1, 'c': ...
2b80818adfa30132ba69be3ef7478693e43d48cc
a233894432/learn_python
/cookbook/ๅญ—ๅ…ธ็š„่ฟ็ฎ—.py
447
3.671875
4
prices = { 'ACME': 45.23, 'AAPL': 612.78, 'IBM': 205.55, 'HPQ': 37.20, 'FB': 10.75 } min_price = min(zip(prices.values(), prices.keys())) # min_price is (10.75, 'FB') print(min_price) max_price = max(zip(prices.values(), prices.keys())) # max_price is (612.78, 'AAPL') print(max_price) prices_sorte...
705b1d1d5de3b3284140247287793f0a6646b54d
a233894432/learn_python
/learn_think_python_2e/ex4.py
1,782
4.15625
4
fruit = 'banana' print(len(fruit)) prefixes = 'JKLMNOPQ' suffix = 'ack' # for letter in prefixes: # print(letter + suffix) fruit = 'banana' print(fruit[3:]) # ๅ–ๅŽ3ไธชitem print(fruit[:3]) # ๅ–ๅ‰3็š„item print(fruit[:]) # ๅ–ๅ…จๅ€ผ # ่ฎก็ฎ—ๅญ—ๆฏaๅœจๅญ—็ฌฆไธฒไธญๅ‡บ็Žฐ็š„ๆฌกๆ•ฐ๏ผš word = 'banana' count = 0 for letter in word: if letter == 'a': ...