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
f99950453b8b6acbb3e153099408f9ed724e8d7e
legendgp7/pd_drawing
/aug.py
618
3.625
4
import copy import numpy as np def data_augment(x_train, y_train,size): num_train = x_train.shape[0] x = x_train.reshape((num_train, size, size)) x_f = np.fliplr(x) x = np.concatenate((x, x_f), axis=0) y = np.concatenate((y_train, y_train), axis=0) x_out = copy.deepcopy(x) y_out = copy....
56900efa62b6e7764e8992c93c6ced9227f84ae0
leanny01/password-checker-py
/passwordChecker.test.py
1,298
3.515625
4
import unittest import passwordChecker class TestPasswordChecker(unittest.TestCase): def test_missing_number(self): '''Should check if number is missing''' test_missing_number_params = 'sDnded@_' result = passwordChecker.checkPassword( test_missing_number_params, test_missing_...
c49420a3a66cbbc64882aa861b81069213052094
ccwu0918/Zerojudge-answer
/f041.py
658
3.6875
4
""" f041: Problem A - 記得交作業! 小b 是個常常忘記交作業的學生,為此,小b 希望你能幫他個小忙:已知 小b 的每一份作業都是在作業公佈的 五天後 要交,那請問禮拜 x 公佈的作業是禮拜幾要交呢? 輸入只有一個正整數 x(1≤x≤7),代表作業是禮拜 x 公佈的。(1 代表禮拜一、2 代表禮拜二、3 代表禮拜三、4 代表禮拜四、5 代表禮拜五、6 代表禮拜六、7 代表禮拜天) 輸出一個正整數,代表 小b 的作業需要在禮拜幾交(格式跟輸入一樣)。 """ a = int(input()) a = (a + 5) % 8 + 1 if a > 2 else a + 5 print(a)
8008d37d2f7ae1743aad0756d66bb65f1804e1e2
ccwu0918/Zerojudge-answer
/Note/for loop.py
230
3.71875
4
n = 10 # for i in 清單: # pass print(range(n)) print(list(range(n))) print(len(range(n))) a = [4, 2, 23, 7, 3, 5] #依序Print出來 #法一 # for i in a: # print(i) #法二 # for i in range(len(a)): # print(a[i])
916138e29c8d34b42cfefdeba8caefec7adbbd58
ccwu0918/Zerojudge-answer
/d827.py
100
3.734375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- n = int(input()) print((n // 12 * 50) + n % 12 * 5)
3ce6d57c9a06622e7cae3f1bc2fa2baa1946be36
Nikhil-Xavier-DS/Sort-Search-Algorithms
/bubble_sort.py
467
4.28125
4
""" Implementation of Bubble Sort. """ # Author: Nikhil Xavier <nikhilxavier@yahoo.com> # License: BSD 3 clause def Bubble_sort(arr): """Function to perform Bubble sort in ascending order. TIME COMPLEXITY: Best:O(n), Average:O(n^2), Worst:O(n^2) SPACE COMPLEXITY: Worst: O(1) """ for outer in ra...
73156cfb9b375a58c00dbe0bd7ff29bf3bd5f6f3
saulogp/Exercicios_CV_Python
/exe_013.py
224
3.625
4
salario = float(input("Qual o salario do funcionario: ")) reajuste = 15 salario_atual =salario +(salario * reajuste / 100) print("O salario de R${}, teve {}% de reajuste: R${:.2f}.".format(salario, reajuste, salario_atual))
107f3b70420036ba003d9c82b964c0aedc809ff4
saulogp/Exercicios_CV_Python
/exe_012.py
211
3.59375
4
'''Desconto de 5%''' prod = float(input("Preço do produto: R$")) preco_final = prod - (prod * 5 / 100) print("O produto que custava R${}, com 5% de desconto passa a valer R${:.2f}.".format(prod, preco_final))
d6bfff61086be89f2f0d63f859a26176872c540a
erikwaskiewicz/RunlogDB
/scripts/parse_samplesheet.py
5,923
3.890625
4
import csv import itertools import os.path def get_variables(run_folder): """--- Get SampleSheet path --- Takes the run folder and looks for Samplesheet.csv in that folder. If found then sets the samplesheet path to the file, otherwise returns an error. """ global samplesheet_path samplesheet_...
a20b1e1fd927ce2b3c8d822e5dfd2e9475ca6713
Ajay7545/PythonPrc
/example.py
725
4.03125
4
def display(): print("hello world ") #display() def area(r): a=3.14*r**2 print(f"cirle area:{a}") #area(5) #for i in range(3): # area(i) def pattern(sy,si): for i in range(si): print(sy*i) #pattern('*',8) #pattern('$',5) #wapto replace all consonent with o usinga fun...
d347d7e484f9efb8fcd4b19c0d5022f578e24a32
NareshMarri/Devopsgit
/sample.py
425
3.859375
4
#!/usr/bin/python class myclass: def __init__(self,name,age,company,location): self.age=age self.name=name self.company=company self.location=location print("Name of the candidate="+name) print("Age of the candidate="+age) print("Company of the candidate="+com...
955debc98a01baa52a63a66d399ea6d885746519
njohnsoncpe-zz/thirdEye
/object_detection/dev_testers/json_tester.py
1,131
3.625
4
import json from collections import defaultdict class NestedDefaultDict(defaultdict): def __init__(self, depth, default=int, _root=True): self.root = _root self.depth = depth if depth > 1: def cur_default(): return NestedDefaultDict(depth - 1, ...
62ca5ffb9beca42bf6b5a450844ddaafe126981f
Surmalumi/Homework6
/work1.py
504
3.921875
4
# Создать класс TrafficLight (светофор) и определить у него один атрибут color (цвет) и метод running (запуск). import time class TrafficLight: __traffic_light_color = "traffic_light" def running(self): while True: print("Red light") time.sleep(7) print("Yellow lig...
40488850b09d4682d9c58a249e6c5309567f7c3d
progclub-iitm/Bridge_Bot
/bridge-v1.py
5,966
3.609375
4
import random #module used for shuffle functionality suit_vals = {'NT':4,'S':3,'H':2,'D':1,'C':0} directions = ['North','East','South','West'] rank = {'A':13,'K':12,'Q':11,'J':10,'10':9,'9':8,'8':7,'7':6,'6':5,'5':4,'4':3,'3':2,'2':1} def arrange(hand): #Arranges a hand first by suit and then by rank ...
20749c800a632a0f308a18d2a90a793081c59ae6
Sahil12S/DataCompass
/Python/underscore.py
1,475
3.578125
4
class Underscore: def map(self, iterable, callback): for i in range(len(iterable)): iterable[i] = callback(iterable[i]) return iterable def find(self, iterable, callback): for i in range(len(iterable)): if callback(iterable[i]): return iterable[i]...
53fb6f4ae3628d89297df69c68c60e67af44b3b6
sekosolares/exercises
/Python/exercise2.py
4,806
4.21875
4
# -*- encoding: iso-8859-1 -*- import os def mayor_menor(n1, n2) -> str: """ :rtype: str """ # Validaciones if type(n1) is not int or type(n2) is not int: return "Tipo invalido en alguno de los argumentos" # Variables frase = "El nmero (M) es mayor que (m) por (r)." # Proceso...
e2fa8b96551cd6be8ab0f406091c6e64148372e2
DebanjanaKar/Predict_the_price
/linear_regression.py
2,989
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Feb 8 18:29:41 2018 @author: debanjana """ import pandas as pd import numpy as np import matplotlib.pyplot as plt import random alpha=0.05 epoch=100 #reg=0.5 def grad_Descent_train(alpha,theta,given,X,reg): predicted=np.sum(X*theta,axis=1) #the...
2778f17cce1a3f0d0fe36133ae5a36dc6bebb523
kassiokiarelly/cs50x-2020
/pset6/mario/mario.py
304
4.03125
4
from cs50 import get_int height = 0 while True: height = get_int("Height: ") if height > 0 and height <= 8: break for i in range(1, height+1): for j in range(height, 0, -1): if j <= i: print("#", end="") else: print(" ", end="") print()
f7f96e1efcd8a6def3c8b7cd07a4aca9fd1306eb
dimitrez/python-learning
/deposit.py
161
3.578125
4
def bank(a, years): arr = [] b=years while b : arr.append(b) b=b-1 for i in arr: a+=a/100*3 print(a) bank(4000,10)
d3324ae737e0ce72731efac0dc5ecd0154abaf96
vams3041/MyWork
/Exercise/rps.py
1,994
3.859375
4
import random class Game: def __init__(self, newPlayerName): self.playerName = newPlayerName self.playerHand = "NA" self.botHand = "NA" self.winner = "No Winner Yet" print("New instance of game class for " + self.playerName) def runGame(self, x, y): if x in rang...
f1e315e2a44ec23ac1624e73cae2ad1c5daa3c33
pankaj7621/PythonBasics
/run.py
745
3.59375
4
from question import Question question_prompts = [ "What is the color of banana?\n(a) Red\n(b) Yellow\n\n", "What is the color of sky?\n(a) Blue\n(b) Green\n\n", "What is 1+1?\n(a) 2\n(b) 4\n\n", "How many zeroes are there in a thousand?\n(a) 2\n(b) 3\n\n" ] questions = [Question(question_prompts[0], ...
8023346d27730e9a6043172b6cfa6c67c635571e
mindgitrwx/pyrobot3
/plugins/brains/NNWander.py
3,350
3.546875
4
# A Neural Network Brain # D.S. Blank from pyrobot.brain import Brain from pyrobot.brain.conx import * from pyrobot.gui.plot.scatter import * from pyrobot.gui.plot.hinton import * class NNBrain(Brain): """ This is an example brain controlled by a neural network. This simple example loads the range sensor dat...
204d69c7ca5b1167c33deee84a89a7ea8d4a13ab
mindgitrwx/pyrobot3
/geometry/__init__.py
6,280
3.8125
4
# # this is the geometry code. It is all R^3. # # All vectors/points are lists w/ 3 elements [x,y,z] # # Affine vectors are tuples like: ([x,y,z],[i,j,k]) # # # - stephen - # import math TOLERANCE = .0001 PIOVER180 = math.pi / 180.0 PITIMES180 = math.pi * 180.0 DEG90RADS = 0.5 * math.pi COSDEG90RADS = math.cos(DEG90RA...
90accae47354ad6048fd064c7a2f135175a89568
kombat1/shaitan_machina
/shaitan_mashina.py
5,416
3.75
4
def nod(a, b): # нахождения НОД while a != b: if a > b: a = a - b else: b = b - a return a def power(a, n): # возведение в степень if n == 0: return 1 if n % 2 == 0: return power(a, n/2)**2 else: return a*power(a, n-1) def diffi_helman(p,g,a,b): # P...
121cedc24b25fd658fd5fbb34ab81155aec00c68
feng-hui/python_books_examples
/fluent_python/chapter_19/ch19_bulkfood_v2.py
765
3.765625
4
#!/usr/bin/python3 # -*- coding:utf-8 -*- # @author FH # @email: capricorn1203@126.com # @time: 2019/3/17 9:14 class LineItem: """ 使用特性(@property)验证属性weight是否大于0 """ def __init__(self, description, weight, price): self.description = description self.weight = weight self.price...
285c7c3066a5f4e76eeff981a0cb4b4bee60dd8e
feng-hui/python_books_examples
/fluent_python/sorting_algorithm/quick_sort.py
1,299
3.859375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @time : 18-2-26 下午9:06 # @author : Feng_Hui # @email : capricorn1203@126.com def partition(v, left, right): """ 获取经过一轮排序后基准值的位置 快排原理介绍:假设序列为[6, 8, 1, 4, 3, 9] 默认基准数为6,从右向左进行扫描,找到第一个比6小的数字为3,交换6和3的位置; 然后从左向右进行扫描,找到第一个比6大的数字为8,然后交换6和8的位置,然后返回最后基准数停留的位...
5f713a00bbc46175c4d0f6e16449e62871c139b4
feng-hui/python_books_examples
/fluent_python/chapter_12/ch12_subclass_of_collections.py
401
3.5625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @time : 18-3-4 下午9:53 # @author : Feng_Hui # @email : capricorn1203@126.com import collections class DoppelDict2(collections.UserDict): def __setitem__(self, key, value): super().__setitem__(key, [value] * 2) if __name__ == "__main__": dd = DoppelDict2...
f8ce4d402caf89bc950f2ef2a05b0ea186f8aa0c
feng-hui/python_books_examples
/fluent_python/chapter_19/ch19_bulkfood_prop.py
837
3.734375
4
#!/usr/bin/python3 # -*- coding:utf-8 -*- # @author FH # @email: capricorn1203@126.com # @time: 2019/3/17 9:52 def quantity(storage_name): def qty_getter(instance): return instance.__dict__[storage_name] def qty_setter(instance, value): if value > 0: instance.__dict__[storage_na...
3afbaa0ac13b58925806d3fe49cc8c3f5599a695
niveeshwar/niveeshwar
/python2.py
237
3.75
4
y=str(input("")) vow=["a","e","i","o","u"] cons=["b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","u","v","w","x","y","z"] if(y in cons): print("Consonant") elif(y in vow): print("Vowel") else: print("Invalid")
52de9bd795f57d80f77410cf0aaf0cf5ce30e8fc
SreeramSP/Python-Programs-S1
/Area-and-perimeter-of-circle.py
152
4.25
4
r=float(input("Enter the radius of Circle= ")) area=3.14*r*r perimeter=2*3.14*r print("Area of Circle: ",area) print("Perimeter of Circle: ",perimeter)
b8d279107217bfbf7174bb4dd054b254a5e90a7c
SreeramSP/Python-Programs-S1
/factorial.py
235
4.1875
4
n=int(input("Enter the number=")) factorial=1 if n<0: print("No negative Numbers") elif n==0: print("The factorial of 0 is 1") else: for i in range(1,n+1): factorial=factorial*i print("Factorial=",factorial)
f9ba5e379f23e1dadcdb1388a7e65bafcdb59cc7
richartzCoffee/aulasUdemy
/templates2/listasAlinhadas.py
100
3.609375
4
lista = [[1,2,3],[4,5,6],[7,8,9]] print(lista) [[print(u, end= "->") for u in i] for i in lista]
7d1fdc3c58c2d816f25dfb88f332d52b3084f3ae
richartzCoffee/aulasUdemy
/templates2/modosAberturas.py
328
3.828125
4
""" Modos de leituras r -> ab qre para a leitura w -> abre para a escrita x -> abre para a esscrita somente se o arquivo não exixtir caso exista gera falha a -> adiciona linhas no final do arquivo """ with open('texto.txt','r+') as file: print(file.read()) file.write("daniel no iaaaaaaaanwwicio\ndo\narquivo\...
19d17745e0d2aee9ab3b65763076772ba449c6f9
richartzCoffee/aulasUdemy
/templates2/sorted.py
359
4.125
4
""" sorted com qualquer interavel """ numero = [1,2,3,56,41,5] print(numero) print(tuple(sorted(numero))) print(sorted(numero,reverse=True)) usuarios =[ {"usarname":"daniel","tw":["oi"]}, {"usarname": "daaniaaaaaaael", "tw": [],"cor":"amarelo"}, {"usarname":"daniaael","tw":["oi"]} ] print(sorted(usuarios,ke...
dc269f7ff75721ee3fa9baaf4a38af7af6123f8d
0202okmai/trabajo
/trabajo.py
2,238
3.515625
4
def hacer_diccionario(lista_diccionario): region_dicion={} for diccionario in lista_diccionario: for i in diccionario: if i not in region_dicion: region_dicion[i] =[] region_dicion[i].append(diccionario[i]) return region_dicion def hacer_lista_diccionario(lis...
4f7855dfd09e050516919c63c7fd66d77c9c790c
sharpedges/ik_gen
/praht_ik_gen/tre.py
488
3.5625
4
import csv bus_numbers = ['101', '102', '36', '40'] bus_names = ['NUC_A', 'NUC_B', 'CATDOG', 'HYDRO_A'] voltage = [.99, 1.02, 1.01, 1.00] # open a file for writing. csv_out = open('mycsv.csv', 'w') # create the csv writer object. mywriter = csv.writer(csv_out) # writerow - one row of data at a time. for row in zip...
bf9e1ad0ea5c44db6a90fe83a0b821b1b751b64a
sharpedges/ik_gen
/isikukood_gen.py
2,582
3.75
4
import random first_nr = random.randint(1,8) month = format(random.randint(1,12), '02') ## http://stackoverflow.com/questions/16645844/python-generate-random-string-in-range-01-12 last_nr_1 = format(random.randint(0,999), '03') day = format(random.randint(1,31), '02') first_nr = str(first_nr) #sex = random.randint(1,...
b6f73dc87b3d8e06350383f2f10412b9fd494799
RFenolio/ProjectEuler
/Problem007.py
329
4.0625
4
def isPrime(number): isPrime = True for num in range(2, number/2): if number % num: isPrime = False return isPrime def findPrime(x): primeNums = [2, 3, 5] i = 6 while len(primeNums) < x: if isPrime(i): primeNums.append(i) i += 1 return primeN...
7714599ca061d762b8131f36074dd1b3cb756068
Ayse-Erduran/MITx-6.00.1x
/ProblemSet_1/PS 1.3
1,089
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Sep 12 12:24:56 2019 @author: ayse """ # Assume s is a string of lower case characters. # Write a program that prints the longest substring of s in which #the letters occur in alphabetical order. #For example, if s = 'azcbobobegghakl', then your prog...
283112adcd03688236d72a9748711469976a4976
standrewscollege2018/2021-year-11-classwork-SamEdwards2006
/Paracetamol.py
662
4.125
4
#sets the constants AGE_LIMIT = 12 WEIGHT_LIMIT = 0 on = 1 #finds the users age while(on > 0): age = int(input("How old are you: ")) #tests if the age is more than 12, #if not, it will go to the else. if age >= AGE_LIMIT: print("Recommend two 500 mg paracetamol tablets") elif age >= 0: ...
dc2e845ceb8f6466400b6e5b05cabba52903264a
standrewscollege2018/2021-year-11-classwork-SamEdwards2006
/Speeders.py
2,042
4.03125
4
#sets the arrest warrants warrants = ["John Smith", "Helga Norman", "Zach Conroy"] fine_total = 0 ask_count = 0 keep_asking = True fine = 0 while keep_asking == True: #takes the name name = str(input("NAME: ")) #if the name is in the warrants list, it will print this if name in warrants: print("A...
9db1c855aab5a12524aa27e6643450bd7944673f
standrewscollege2018/2021-year-11-classwork-SamEdwards2006
/Input.py
174
4.28125
4
#this program allows the user to enter their name and age name = input("What is your name") age = input("How old are you") print("Hello", name, "the", age, "year old human")
46d2b8bed6fde5bd9fa04a10c66f8b7267d84f49
wingerlang/Eulerproject
/Python/Euler38.py
190
3.921875
4
def isPandigital(s): return True def pandigital(n, upTo = 3): s = "" for i in range(1, upTo +1, 1): s += str(n * i) return s #print(pandigital(192)) #print(isPandigital(192384576))
b3694a180fa2ee0867d086c907bfce1a5a7ba089
drgarcia1986/coding
/the-coding-interview-bootcamp/stringreversal.py
687
4
4
""" >>> reverse('apple') 'elppa' >>> reverse('hello') 'olleh' >>> reverse('Greetings!') '!sgniteerG' >>> reverse(' abcd') 'dcba ' """ def reverse(s): """ - Pythonic way return s[::-1] or return ''.join(reversed(s)) -------------- - O(n) rev = '' for c in s: rev = c + rev ...
a12b958efd7931308deda259817f41ed85589084
abasuofficial/TicTacToe
/TicTacToe.py
5,555
3.96875
4
TicTacToeBoard = {'1':' ' , '2':' ' , '3':' ', '4':' ' , '5':' ' , '6':' ', '7':' ' , '8':' ' , '9':' '} player1 = input("Enter Your Name[Player 1]: ") player2 = input("Enter Your Name[Player 2]: ") player = 1 turns = 0 def declareSymbol(): print("--------------------...
1f83cd3ebdebb4a493c028d3ab17bca0342c4ac2
mjs375/CS50AI
/1/minesweeper/minesweeper.py
12,964
4.1875
4
import itertools import random from copy import deepcopy class Minesweeper(): """ Minesweeper game representation. Handles gameplay. """ def __init__(self, height=8, width=8, mines=8): # Set initial width, height, and number of mines self.height = height # X (i, ) self.width...
d979d18086c9100525088cd497bc8ccb1d7ad2e0
mjs375/CS50AI
/1/Lecture/harry.py
1,486
3.90625
4
from logic import * # Create new classes, each having a name, or a symbol, representing each proposition. rain = Symbol("rain") # It is raining. hagrid = Symbol("hagrid") # Harry visited Hagrid dumbledore = Symbol("dumbledore") # Harry visited Dumbledore sentence = And(rain, hagrid) print(sentence.formula()) # => ...
0fc446b5e918c498196234b43acec2758c60c2f1
shivamdattapurkayastha99/extra-python-programs
/currencyconverter.py
444
3.71875
4
with open('currency.txt','r') as f: lines=f.readlines() # print(lines) currencyDict={} for line in lines: parsed=line.split("=") currencyDict[parsed[0]]=parsed[1] # print(currencyDict) print(f"The available options are {currencyDict.keys()}") amount=int(input("Enter the amount to be converted")) currency=i...
6a005d811212f7b14e8f6e922576c5b2e76c1ee1
H4rliquinn/Algorithm-Solutions
/HackerRank/Arrays/minimum_swaps_2.py
574
3.703125
4
#!/bin/python3 import math import os import random import re import sys # Complete the minimumSwaps function below. def minimumSwaps(arr): swaps=0 for x in range(len(arr)): #Too Slow # if arr[x]!=x+1: # loc=arr.index(x+1) # arr[x],arr[loc]=arr[loc],arr[x] # ...
0b4e2eee5d16dabef23bb2094cffec74c65db92e
H4rliquinn/Algorithm-Solutions
/LeetCode/sum-of-nodes-with-even-valued-grandparent.py
1,543
3.84375
4
'''Given a binary tree, return the sum of values of nodes with even-valued grandparent. (A grandparent of a node is the parent of its parent, if it exists.) If there are no nodes with an even-valued grandparent, return 0. Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5] Output: 18 Explanation: The red nodes ...
60b7b1333d1336fbc2cafcf35ead22602ce91448
H4rliquinn/Algorithm-Solutions
/LeetCode/deepest-leaves-sum.py
1,192
3.796875
4
'''Given a binary tree, return the sum of values of its deepest leaves. Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8] Output: 15''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # se...
7eb87adb72bf943425b3977475d9b1e791737e7e
AK6263/Sierpinski-s-Triangle
/sierpinskis_triangle_turtle.py
2,318
4.03125
4
# -*- coding: utf-8 -*- """ Created on Fri Dec 20 20:32:39 2019 @author: Abhay Kshirsagar """ from turtle import * from math import * def find_leaf(t,xc,yc,l): # To find the coordinates of children nodes x_new = [] y_new = [] t.goto(xc,yc) k = l/sqrt(3) for i in range(3): ...
e41ced466b2a3bb852f80260c712d9814c4ad4b1
huwenhan-create/mlp-proj2
/Code/predata/association_analysis.py
1,321
3.78125
4
import numpy as np import pandas as pd # Define the function to analysis the association between features and `is_canceled` def association_analysis(target: str, plot:bool, data, axes, log=False): """This function is used to do some univ_analysis: If we grouped by the target variables, We can calculate the fre...
9145b99e656be2600e31340f7acd7c4c9450cb1a
CassioMaciel/Scripts-Python
/Exercicio#009-Tabuada.py
858
3.953125
4
base=int(input('Digite um numero para ver sua tabuada ')) print("-"*12) secnum=int(1) print('{}x{:2}={}'.format(base,int(secnum),int(base*secnum))) secnum=int(2) print('{}x{:2}={}'.format(base,int(secnum),int(base*secnum))) secnum=int(3) print('{}x{:2}={}'.format(base,int(secnum),int(base*secnum))) secnum=int(4) p...
2918cbe64fe2cce6f75edc10625a5bdaa2a1ab1f
SmoothCrimminal/Jet-Brains-Academy-Projects-Python
/tic tac toe.py
7,109
3.828125
4
def print_playground(x): print("---------") print("| {0} {1} {2} |".format(x[0], x[1], x[2])) print("| {0} {1} {2} |".format(x[3], x[4], x[5])) print("| {0} {1} {2} |".format(x[6], x[7], x[8])) print("---------") def win_conditions(x): win0 = x[0] + x[1] + x[2] win1 = x[3] + x[4] + x[5] ...
7aedbc99deb09461fc3e9ba693ab996f0ed879e2
SandipVyara/Skillsanta-Center
/swap.py
193
3.84375
4
list1= [56,89,12,3,4,2,84] def swaplist(list1): first= list1.pop(0) last= list1.pop(-1) list1.insert(0,last) list1.append(first) return list1 print(swaplist(list1))
cc655ce16a23b2b9e92dff829393d73af34e6339
rafa761/leetcode-coding-challenges
/biweekly contest 33/5479 - thousand separator.py
601
3.8125
4
""" 5479. Thousand Separator Given an integer n, add a dot (".") as the thousands separator and return it in string format. Example 1: Input: n = 987 Output: "987" Example 2: Input: n = 1234 Output: "1.234" Example 3: Input: n = 123456789 Output: "123.456.789" Example 4: Input: n = 0 Output: "0" """ class Solut...
78a556658eea5d03ebbdd76ecf3e7d2888f3860c
rafa761/leetcode-coding-challenges
/2020 - august/008 - non-overlapping intervals.py
1,500
4.40625
4
""" Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Example 1: Input: [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: [1,3] can be removed and the rest of intervals are non-overlapping. Example 2: Input: [[1,2],[1,2],[1,2]] ...
b208df286341b6a62eb0c62bcdde7affb800c5da
Olga-geek/first-quarter
/lesson1/hw1.py
189
4.03125
4
a = 52 b = "Hi my friend" print (a, b) a = int(input("Сколько тебе лет:")) print("Тебе уже исполнилось", a) b = input("What's your name?") print("Hi my friend",b)
cb1b53ab61f31af5de999af293342c769428766f
pmfs-alves/ProjetoDataMining
/teste.py
1,423
3.765625
4
## # Create a figure space matrix consisting of 3 columns and 2 rows # # Here is a useful template to use for working with subplots. # ################################################################## variaveis=[variaveis] clusters = nº clusters fig, ax = plt.subplots(figsize=(10,5), ncols=2, nrows=len(variaveis)) le...
da5d4bb0bc85ae6b1cf18c7e62f442a811f0f67a
Shinji94/python_programming_coursework
/slides/week6/Week 6/exercises_1_2.py
299
4
4
num = int(input("Please input a number:(Should be greater than 1)")) square_num = int(num ** 0.5) for i in range(2, (square_num+1)): if (num % i) == 0: print('%d is NOT prime.' % num) print("%d = %d * %d" % (num, i, num / i)) break else: print("%d is prime." % num)
d434bdf3a1a81c9a1742259d0c683d373bdba1a4
Shinji94/python_programming_coursework
/slides/Week 7/Point.py
545
4.28125
4
class Point: """ Point class represents and manipulates x,y coords. """ def __init__(self, x=0, y=0): """ Create a new point at x, y """ self.x = x self.y = y def distance_from_origin(self): """ Compute my distance from the origin """ return ((self.x ** 2) + (self.y...
81ab9c117f71d7e5489331a7228f45a96a94158b
mihai37/MyPython
/is_int.py
125
4.03125
4
def is_int(x): x=raw_input("number") print (x) if x is int: return True else: return False
44db97373b7159dbc977c4c71a22a556f97f81fb
eperich/project_euler
/module_4.py
1,103
3.84375
4
import math print('(1)') x = 1 for x in range(1, 6): print(x) x += 1 print() print('(2)') print(3 + 4) print() print('(3)') print(math.pi + math.sqrt(2)) print() print('(4)') print(math.sin(math.pi / 6) + math.cos(math.pi / 6)) print() print('(5)') x = input('Enter first value: ') y = input('Enter second va...
7891e1022369dcb7214ac254df192c8be665f39f
eperich/project_euler
/problem3.py
219
3.921875
4
import sympy as sym num = int(input("Enter a number:")) i = 2 while i < num: if num % i == 0: factor = int(num / i) if sym.isprime(factor): print(factor) break i += 1
93078621bba9b1f5c81675e5c5b0e6b6e8323c32
cpucortexm/iot_copy
/python-components/src/main/python/programmingtheiot/cda/system/BaseSystemUtilTask.py
1,043
3.515625
4
##### # # This class is part of the Programming the Internet of Things project. # # It is provided as a simple shell to guide the student and assist with # implementation for the Programming the Internet of Things exercises, # and designed to be modified by the student as needed. # import programmingtheiot.common.Co...
639d46221310fc2deadaf8e67700712c4560c18c
abigcleverdog/udacity-python-movie-trailer-proj
/media.py
329
3.796875
4
class Movie(): '''movie class defines instance variables such as the title, box art, and movie trailer of a movie''' # constructor of Movie def __init__(self, title, art_url, trailer_url): self.title = title self.poster_image_url = art_url self.trailer_youtube_url = tra...
dda5981778d12f044a1de95d4aa908a2f991814f
arielf212/badassembly
/exceptions.py
1,137
3.578125
4
class OutofBoundsError(Exception): '''this exception is raised when trying to get to a node that odes not exist on a stack''' def __init__(self,placement): self.placement = placement class NonIntegerIntoStack(Exception): '''this exception is raised when trying to put a non-integer onto the stack'''...
e23766485e263cfbfdc17b45309fda778aaedb22
shivekkhurana/learning
/python/euler/prime_factors.py
1,159
3.984375
4
def primeNumbers(n): # Found this example on Wikipedia: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes # Create a candidate list within which non-primes will be # marked as None; only candidates below sqrt(n) need be checked. candidates = list(range(n+1)) # Square root of n fin ...
702776200dc409917fceeec2c1a417c8e14747bd
shivekkhurana/learning
/python/network-security/xor.py
2,090
3.53125
4
import binascii class XorManager: def __init__(self, payload): self.payload = payload def _string_to_binary_string(self, string): return ''.join('{:08b}'.format(ord(x)) for x in string) def _bin_to_string(self, binary): return binary def encrypt(self, key): payl...
1fa13bb4d0f21ea615f01d9f625f652eec8d3e01
itallmakesense/ETL-Example
/etl.py
530
3.671875
4
import sys import csv import sqlite3 file = sys.argv[1] fieldnames = ("Job Title", "Category", "Status", "Location") connection = sqlite3.connect('jobs.db') cursor = connection.cursor() cursor.execute("CREATE TABLE jobs (%s text, %s text, %s text, %s text)" % fieldnames) with open(file, newline='') as ...
ffb8fedaa5d94053f7e1e8f0092bdb1e0f0b435e
Jason-Yonghan-Park/Python_Study
/Ch04/ch04_while01.py
1,286
3.734375
4
### while 문 cnt = 1 while cnt <= 10: print(cnt, end=" ") cnt += 1 else: print("정상실행") ## 컴프리헨션 comprehension ## 이터레이터 iterator (반복가능한 객체)로 부터 자료구조를 만들어주는 함축적 방법 L = [] for i in range(10): L.append(i) print(L) # 리스트 컴프리헨션 LH = [i*2 for i in range(10)] print(LH) LH2 = [i for i in range(1, 11) if i % 2 ...
ddb32984a362cc45bd3c224ec64ea3a332108ac9
albemlee/BreastCancerClassifier
/script.py
2,748
3.8125
4
# Load Requirements from sklearn.datasets import load_breast_cancer from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier import matplotlib.pyplot as plt # Explore the data ## 1 breast_cancer_data = load_breast_cancer() ## 2 print(breast_cancer_data.data[0]) print(br...
c04e9efe58050c4a526ec8d7810aef628b2a3418
ZerryChu/time-series
/dataProcessing.py
3,313
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Aug 11 01:21:04 2019 @author: ray zhu """ import numpy as np import pandas as pd # The raw data comes from the Berkeley Earth data page: # http://berkeleyearth.org/data/ # #{ # "name": "GlobalLandTemperaturesByCountry.csv", # "descr": "it is a...
e4457183e083108943253ccf9a70f46a4485b59d
DianaKuzmenko/double_string
/double_string.py
230
3.953125
4
def double_str(s): s1 = '*' + s result = s1 + ' --> ' while len(s1) < (2*len(s)+1): s1 = s1.replace('*a','aa*') result += s1 + ' --> ' s1 = s1.replace('*','') print(result+s1) double_str('aaa')
b22887cedeb04fb7b3d17ab8571c6d9e628b0fd2
lunaticb7/coding-for-office-workers
/week01-python/03-data-type-2.py
939
4.09375
4
#목록 list, tuple #사전 dict - dictionary #집합 set #list [] print("list") list_a=[1,2,3] print(list_a) #print(type([1,2,3])) #index는 0부터 시작합니다. print(list_a[0]) print(list_a[1]) print(list_a[2]) #slice 는 마지막 index를 포함하지 않음 print(list_a[0:1]) list_a.append(4) print(list_a) list_a.remove(2) print(list_a) list_a.clear() pri...
95d169701957040d4dc7bce372d989b3677f3b8d
lunaticb7/coding-for-office-workers
/week01-python/08-classes.py
1,513
3.5
4
# 클래스 class ##### Article variables title1="개발" author1="마르코" content1="개발은 쉬워요" view_count1=0 title2="코칭" author2="마르코" content2="코칭은 쉬워요" view_count2=0 title3="창업" author3="마르코" content3="창업은 쉬워요" view_count3=0 # view_vount1=1 # view_vount1=2 # view_vount1=3 #####Article clasee # class Article: # title="개발" ...
a8021181a239fae762500dfdeef2defbfc19d0b5
azhar2ds/DataZone
/Even_number.py
187
3.734375
4
print("this is 4 table") count = 0 for number in range(4, 44): if number % 4 == 0: count += 1 print(number) print(f" this is {count}") print("Helloworld")
303fccff37b6134b30d02e5bf94b53271a360e59
bvsbrk/Algos
/src/Codeforces/adhoc_300/fancy_fence.py
188
3.75
4
if __name__ == '__main__': for _ in range(int(input().strip())): angle = int(input().strip()) print("YES" if int(360 / (180 - angle)) == 360 / (180 - angle) else "NO")
3a271b5b022086344cb8fc7cdadf8bebe33d8de6
bvsbrk/Algos
/src/Practice/Algorithms/Recursion/recursive_digit_sum.py
389
3.65625
4
def digit_sum(n): s = 0 while n != 0: s += n % 10 n //= 10 return s def super_digit(n): if len(str(n)) == 1: return n else: return super_digit(digit_sum(n)) if __name__ == '__main__': n, k = input().strip().split(" ") k = int(k) temp = n for i in r...
13ff4e1850c4c422259ba1ff6e3d0f1dfdc7d2c6
bvsbrk/Algos
/src/Hackerrank/week_of_code_37/A.py
395
3.75
4
from math import ceil def roundUp(n, d=2): d = int('1' + ('0' * d)) return ceil(n * d) / d if __name__ == '__main__': su, co = 0, 0 for _ in range(int(input().strip())): cur = int(input().strip()) if cur >= 90: su += cur co += 1 if co == 0: print("...
7f6e610322e0ead7f39998ead2cbcfa1b4539d0c
bvsbrk/Algos
/src/transtutors/id_1579196/print_histogram.py
764
3.984375
4
# collecting space separated input from user and the length can be of any number # Then converting that input string to array and then to int array inp = [int(x) for x in input().strip().split()] # sorting the input for making calculations easy inp.sort() # recent is used for traversing the input elements recent = 0 fo...
96148ba805144120b0c6876df831f9b10e1617ef
bvsbrk/Algos
/src/Codeforces/adhoc_300/hulk.py
306
3.84375
4
if __name__ == '__main__': n = int(input().strip()) ans = "" for i in range(n - 1): if i % 2 == 0: ans += "I hate that " else: ans += "I love that " if n % 2 == 0: ans += "I love it" else: ans += "I hate it" print(ans.strip())
787144b8ef44108b3ea8946fd27ef87892aa17d7
bvsbrk/Algos
/src/Practice/Project_Euler/6_sum_square_difference.py
264
3.75
4
if __name__ == '__main__': tc = int(input()) for i_tc in range(tc): n = int(input()) sum_of_squares = (n * (n + 1) * ((2 * n) + 1)) // 6 square_of_sum = ((n * (n + 1)) / 2) ** 2 print(int(abs(sum_of_squares-square_of_sum)))
1577b2de7d337dfe0b04cf2ec3d569501482ece6
bvsbrk/Algos
/src/Practice/Datastructures/Trees/binary_trees/reverse_level_order.py
1,518
3.671875
4
import math from collections import deque from sample_tree import get_tree_root class Pair: left = None right = None def __init__(self, left_data=None, right_data=None): self.left = left_data self.right = right_data def get_queue(root): que1 = deque([]) que2 = deque([]) que...
ec259b070121c89623b55026f68561a1f59f81cd
bvsbrk/Algos
/src/Practice/Algorithms/Searching/hackerrank/sherlock_and_array.py
641
3.609375
4
if __name__ == '__main__': tc = int(input().strip()) for i_tc in range(tc): input() arr = [int(i) for i in input().strip().split(" ")] prefix_sum = [0] suffix_sum = [0 for i in range(len(arr))] for i in range(1, len(arr)): prefix_sum.append(prefix_sum[i - 1] +...
0f05b11eca5103b0c706631d421ee83117a86290
Caio-Batista/coding-marathon-problems
/hackerrank/staircase.py
351
3.859375
4
def staircase(n): staircase_ans = [] last_line = ['#' for j in range(n)] for i in range(1, n): temp = [' '] * (n-i) temp2 = ['#'] * i staircase_ans.append(temp + temp2) staircase_ans.append(last_line) for e in staircase_ans: print(''.join(e), end='\n') if __name__ =...
36eb68583c606396d3bcdc407ddc5944207fcb72
Caio-Batista/coding-marathon-problems
/hackerrank/apple_orange.py
522
3.578125
4
def apple_orange(s, t, a, b, apples, oranges): def isInRange(s,t,k): if s<=k<=t: return True else: return False apples_amount = 0 oranges_amount = 0 for apple in apples: if isInRange(s,t,apple + a): apples_amount += 1 for orange in orange...
85b1c544c8a21fe1252cd241a89ae09b0d2ee402
Caio-Batista/coding-marathon-problems
/hackerrank/counting_valleys.py
455
3.984375
4
def counting_valleys(path): valleys = 0 is_above_sea = True ref = 0 for e in path: if e == 'U': if not is_above_sea and ref == -1: is_above_sea = True ref += 1 else: if is_above_sea and ref == 0: is_above_sea = False ...
a80ba74546a66dd579c1051f3594535dcc02ea42
NadiaGhrib/MNIST
/DataCNN.py
1,454
3.59375
4
import pandas as pd import numpy as np from sklearn.model_selection import train_test_split #Lecture des données def Train() : train = pd.read_csv("/Users/nadiaghrib/Desktop/ML/train.csv") return train def Test() : test = pd.read_csv("/Users/nadiaghrib/Desktop/ML/test.csv") return test train= Train(...
00e59b2fb8a7861ca1e4318e8a6fc6370fde0812
usamapervaiz/Eng_assignment
/Heart_flow.py
26,839
3.515625
4
#!/usr/bin/env python # coding: utf-8 # # Understanding the Problem (Clustering of N-Intersecting lines) # # 1) We are given N lines that can be intersecting at k points. In other words, it is the multiple line segment challenge. <br> <br> # 2) Intital (wrong) thoughts were perhaps to attemp a computer-vision/blob d...
0c4e754032669f8fc75184a5cdfe9ae0e23bf904
vismayatk002/PythonAssignment
/Algorithm Programs/BubbleSort.py
592
4.3125
4
""" @Author : Vismaya @Date : 2021-10-20 07:36 @Last Modified by : Vismaya @Last Modified time : 2021-10-20 07:47 @Title : Bubble Sort """ arr = [] def bubble_sort(): n = len(arr) for i in range(n - 1): for j in range(0, n - i - 1): if arr[j] > arr[j + 1]: ...
2442c3261cc4d4280d0a46878a3e10d250298b4a
vismayatk002/PythonAssignment
/BasicCorePrograms/PrimeFactors.py
542
4.3125
4
""" @Author : Vismaya @Date : 2021-10-18 11:39 @Last Modified by : Vismaya @Last Modified time : 2021-10-18 12:52 @Title : Prime factors of a number """ def is_prime(num): flag = 0 for j in range(2, num): if num % j == 0: flag = 1 break j += 1 ...
e9d257d0fa29de4739a3f85eabe0bf2a30e21a6e
vismayatk002/PythonAssignment
/Data Structure Programs/PrimeIn2DArray.py
660
3.890625
4
""" @Author : Vismaya @Date : 2021-10-20 12:46 @Last Modified by : Vismaya @Last Modified time : 2021-10-20 01:24 @Title : Store Prime numbers in a 2D array """ class Prime: def is_prime(self, min, max): prime_arr = [] for i in range(min, max): flag = 1 ...
00d0b218ced4485ba16a92dd45dafda2e43197ad
DimaBelyakovich/MMF_Labs
/Python /Lab3/1.py
256
3.90625
4
import numpy def decorate_matrix(N): if N<1: return None matrix=numpy.zeros((N,N)) matrix[:]=1 if N>2: matrix[1:-1, 1:-1]=0 return matrix N = int(input("Enter matrix size: ")) matrix = decorate_matrix(N) print(matrix)
ecbb94c6205c808695edc875524e4c4a2250b910
GabrielEncarnacion/learn-arcade-work
/Lab 06 - Text Adventure/Lab6.py
2,882
4.09375
4
class Room: def __init__(self, description, north, east, south, west): self.description = description self.north = north self.east = east self.south = south self.west = west def main(): room_list: [] # Room Descriptions 0-9 room = Room(" You are ...
3120dd816153f44fcf6c07d38b343f087158de6f
elmarl/Python-CSV-parser-and-downloader
/downloader.py
2,503
3.9375
4
import csv #CSV file reading tools import urllib.request #Download file import re #Regular expressions import tkinter as tk #Open file dialog from tkinter.filedialog import askopenfile # from tkinter import ...
7e1dfa18934056630b5a84dfd0464481439b1a28
Hiroki0613/blackjack_Hiroki
/blackjack.py
4,052
3.703125
4
# -*- coding: utf-8 -*- # プログラミング的思考 # TODO(deck) トランプを作る: 得点を数えられるように数字 # TODO(deal) トランプを2枚配る: 絵札(J,Q,K)で表示させる # TODO(hand) プレイヤーに配られたカードを記録する # TODO(hit) ヒットの場合handを追加する # TODO(game) 実際にプレーする # TODO(total) プレイヤーの合計を求める # TODO(result) 勝ち負けを表記する # TODO(play_again) もう一度プレイするか確認する import random deck = [1, 2, 3, 4, 5, ...
e60932fcb89c6a978c39574bba242e3f8770486a
mallimuondu/employer-employee
/main.py
2,551
3.984375
4
print("hello") a = input("Are you are an employer or employee: ") if a == "employer": print("welcome employer") print("do you have a client request") def yn(): b = input("yes(y) or no(n): ") if b == "y": def proposal(): c = input("Have you written a proposal ...
43c70d4de5d90b0c69de1b931cbae28c2575241a
mstites/computationalArt
/recursive_art.py
11,570
3.921875
4
""" 2/13/2019 @author: Griffith Stites """ import random import math from PIL import Image def get_function(start = 1, end = 6): """Get a random function. Uses a dictionary as a switch to chose a random function to return. The following doctest were added to make sure each item in the dictionary co...