blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2d1e21297e6979ffea4906c6edd3e78f269eab20
Creohex/advent-of-code-2018
/day06/chronal-coordinates.py
2,571
3.5
4
import collections, re def read_input(): return list(map(tuple, map(lambda _: (int(m[0]) for m in re.finditer(r"\d+", _)), open('input.txt')))) def get_bounds(coords): """ returns: (left, right, bottom, top) """ return min(x for x, y in coords), max(x for x, y in coords), min(y for x, y in coords), max(y...
184f075be3aeef65e30a3736766545552f9a10f7
eyesfocus/mi-hsrm-cg
/blatt10/bezierTemplate.py
3,277
3.84375
4
from Tkinter import * from Canvas import * import sys WIDTH = 400 # width of canvas HEIGHT = 400 # height of canvas HPSIZE = 2 # half of point size (must be integer) CCOLOR = "#0000FF" # blue (color of control-points and polygon) BCOLOR = "#000000" # black (color of bezier curve) BWIDTH = 2 # width of bezier curve ...
eb2d809a7c2c1d98b8512b58ee1be6aef8300bbe
chenyanqa/example_tests_one
/test_98.py
314
3.53125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- #题目:从键盘输入一个字符串,将小写字母全部转换成大写字母,然后输出到一个磁盘文件"test"中保存。 fp = open('test.txt','w+') s = input('请输入字符串:') fp.write(s.upper()) fp.seek(0) print (fp.read()) fp.close()
fa4bea2aadb8fcd66c9fb518b2d4140a6fc2dad8
Obaolatunde/Pythonclasswork
/day3.py
100
3.578125
4
varx=0 while varx==0: print("Y") #terminating condition absent varx+=1 #same as varx=varx+1
e8c8c96b2489b9b855d3453b904cfe5177c717d6
martin-sne/py
/test.py
2,238
3.875
4
#!/usr/bin/python import re from collections import Counter global file file = "employer.txt" def all(): for line in open(file): print(line.strip()) def tech(): for line in open(file): if re.match(".*Technology.*", line): print(line.strip()) def part(): with open(file) as textFile: lines = [li...
498ad847b586e3f59424ff4cd03c8bc9dec01c92
GuilhermeEsdras/Mamba-3
/Exercícios Resolvidos/The Huxley/1078 - Situação de um aluno.py
403
3.9375
4
Nota1 = float(input()) Nota2 = float(input()) Nota3 = float(input()) Media = (Nota1 + Nota2 + Nota3) /3 if Media < 0: print("Media invalida") elif Media >= 0: print("A media do aluno foi {:.2f} e ele foi ".format(Media), end='') if Media >= 70 and Media <= 100: print("APROVADO") elif Media >= 0 and Media...
1230fc0e4ba938020ecae685fa51a959f1c38f0c
SunnyRaj94/Basic-Python-And-Data-Structures
/Basic/09_string_concadinate.py
345
3.828125
4
""" Created on 11/12/2019 @author: Sunny Raj """ """ Problem Statement: Write a Python program to concatenate all elements in a list into a string and return it. """ # creating a list value_list =[1,2,3,4,5,6,3] # making an empty string concat ="" # using for loop to concadinate for i in value_list: concat= conc...
3e3ffeb0d314182c7613cb5c7be42a420ebffaec
BB8-2020/EmpathicRobot
/src/models/baseline_model/baseline_model.py
5,664
3.515625
4
"""Baseline model using tensorflow. Consists of 3 layers and should only recognize if someone is happy or not.""" from tensorflow.keras import layers, utils import json import numpy as np from typing import Tuple import tensorflow as tf from tensorflow import keras def read_data(path: str) -> dict: """ Read a...
23d7e3b59be61f3be90b45a8d48f8e0230cb1296
ishauchuk/crash_course
/greet_users.py
285
3.5
4
def greet_users(names): """Вывод проостого приветствия для каждого юзера""" for name in names: msg = f"Hello, {name.title()}!" print(msg) usernames = ['john', 'darie', 'alexandro'] greet_users(usernames) print(usernames)
cca8ba38e5848131c1346c855ea5678248ac0e01
arsalybek/WebBackEnd
/Week8/informatics1.3.1/H.py
127
3.65625
4
a = int(input()) for x in range(a + 1): if x == 0: continue if a % x == 0: print(str(x) + " ", end='')
72823db699fa2777ac27483d2a55c886ee8608f4
repinnick/teachmeskills
/day4/ex4_matrix.py
759
3.875
4
import random def generate_two_matrix(): data = [] # первая матрица data2 = [] # вторая матрица for i in range(3): pstr = [] for j in range(3): number = random.randrange(1, 10) pstr.append(number) data.append(pstr) for i in range(3): pstr2 = [] ...
bde60794f84a326df79b460b56b1593cb4631c63
ecen/data-science-intro
/Assignment8/Assignment8.py
3,078
3.75
4
#%% md # # Assignment 8 # ## Students: - Davíð Freyr Björnsson - Eric Guldbrand Total hours spent: 8 # ### 1) The branching factor d of a directed graph is the maximum number of children (outer degree) of a node in the graph. Suppose that the shortest path between the initial state and a goal is of length r. # ### a)...
3b7707eafdabde7d9a7da54608fc82ffd8b1e1b6
Gasheezy/Python
/lambda_funct.py
465
3.90625
4
# Initialize `fahrenheit` dictionary fahrenheit = {'t1':-30, 't2':-20, 't3':-10, 't4':0} celsius = list(map(lambda x: (float(5)/9) * (x-32), fahrenheit.values())) celsius_dict = dict(zip(fahrenheit.keys(), celsius)) print (celsius_dict) #-------------------solve the same problem using dictionary comprehension-------...
2ed0634f6909467bf1614060011c69e318335737
95subodh/Leetcode
/062. Unique Paths.py
624
3.984375
4
#A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). # #The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). # #How many possible unique paths are there? cl...
28161a125724ae7a6d6a32abee6a07124e44549e
HotsauceLee/Leetcode
/2020/R_261.Graph_Valid_Tree.py
2,788
4.1875
4
""" Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree. Example 1: Input: n = 5, and edges = [[0,1], [0,2], [0,3], [1,4]] Output: true Example 2: Input: n = 5, and edges = [[0,1], [1,2], [2,3], [1,3], [...
046575967d28c3f7afab757ee8cab9fac66eedd1
summercake/Python_Jose
/43.Advanced List.py
270
3.9375
4
l = [1, 2, 3] l.append(4) print(l) print(l.count(10)) print(l.count(1)) x = [1, 2, 3] x.append([4, 5]) print(x) x = [1, 2, 3] x.extend([4, 5]) print(x) print(l.index(2)) l.insert(2, 'inserted') print(l) print(l.pop(0)) l.remove('inserted') print(l) l.reverse() print(l)
7da62c4124c30ec7c04c02ea8c5539a4df604d0d
ElizabethMarais/Python-programming
/tennis_info.py
2,733
4.21875
4
#www.coursera.org: Python Data structures, course 2 print "FUNCTION: Reading a data file, build lists, different ways of displaying data." print "When prompted, please enter 'tennis data.txt' as data file." name_file = raw_input("Enter the file name with the tennis tournaments information: ") if len(name_file)...
b92288074a0c26674b9a979746f58f5739841171
elismarina05/edX-Home-PageMITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python
/ExerciseGcdIter.py
604
3.71875
4
''' Write an iterative function, gcdIter(a, b), that implements this idea. One easy way to do this is to begin with a test value equal to the smaller of the two input arguments, and iteratively reduce this test value by 1 until you either reach a case where the test divides both a and b without remainder, or you reach...
cc61337eed46f3087012349cbf0b9dfbfa755790
engom/formation_lycee_2020
/TP_premiere/MAZOUZ_Amine.py
418
3.6875
4
from math import * print("soit ax**2+bx+c une fontion de degré 2 avec") a=int(input("a ")) b=int(input("b ")) c=int(input("c ")) delta=int(b*b-(4*a*c)) print("delta vaut",delta) if delta==0: x=-b/2*a print("x vaut",x) elif delta>0: x1=(-b-(sqrt(delta)))/2*a x2=(-b+(sqrt(delta)))/...
1c21f0f97706e7e1ac03e1aa847cd4281b8a2fdd
humuhimi/mathPython
/mathPython/Chapter3/practice3_8.py
912
4.03125
4
import csv import matplotlib.pyplot as plt from Chapter3.practice3_5 import find_corr_x_y def scatter_plot(x,y): plt.scatter(x,y) plt.xlabel('summer') plt.ylabel('swimming-lesson_correlation') plt.show() def read_csv(filename): with open(filename) as f: reader = csv.reader(f) n...
68f80623442eb0b3bbcc6062710f1e7c2d7c6515
AndreiNepsha/shen_book_problems
/1_1_30.py
781
4.1875
4
# 1.1.30. Даны натуральные числа n и k, n > 1. # Напечатайте k десятичных знаков числа 1/n. # (При наличии двух десятичных разложений выбирается то из них, # которое не содержит девятки в периоде.) # Программа должна использовать только целые переменные. def printDecimalPlaces(n, k): print("0,", end="") div...
adf1a36026e1f68807eb265411377d17c831ce99
n1lux/python_coding_studies
/poo/static_class_methods.py
926
3.703125
4
class Data: def __init__(self, dia, mes, ano): self.dia = dia self.mes = mes self.ano = ano def __repr__(self): return "{}/{}/{}".format(self.dia, self.mes, self.ano) @classmethod def de_string(cls, data_string): #10-10-2016 ''' Receive the class as...
4d0ea21a9b67eac996834a7392d66c0f8fcc55c9
jayadams011/data-structures-and-algorithms
/challenges/left_join/left_join.py
902
3.578125
4
from hash_table import HashTable from linked_list import LinkedList def left_join(hmap1, hmap2): """Define left join.""" num = 0 for item in hmap2.buckets: if type(item) == dict: num += 1 print(num) if num > 0: end = [] for item in hmap1.buckets: if...
abe417afca8ba6355e3cf945b61da850a8964423
ThreeTwoFive/PythonScripts
/jsonToCsv/jsonParser.py
2,058
3.828125
4
import sys import json #PARSES FLAT JSON IN FILE TO CSV FORMAT def parse_json(): if(len(sys.argv) == 3): input_file = sys.argv[1] output_file = sys.argv[2] parse_file(input_file, output_file) else: print("Need to provide two arguments: 'input file name' and 'output file name'") #PARSES FILE #@PARAM input_fi...
9fb5bfa8e558319a1cb95968395578bf1651b0ce
mupastir/battle_outcome
/factories/unit_factories.py
710
3.625
4
from abc import ABC, abstractmethod from models.units import Soldier, Vehicle class UnitCreator(ABC): @abstractmethod def create(self): pass class SoldierFactory(UnitCreator): def __init__(self, recharge=100): self.recharge = recharge def create(self) -> Soldier: return S...
f2adb3497b689552c5ac45b93830a27d1d901c3d
MaunikQ/Sample
/monthAndCity.py
279
3.78125
4
d = {'Mumbai':'Maharashtra', 'Pune' : 'Maharashtra', 'Delhi' : 'Delhi UT', 'Chennai': 'Tamil Nadu', 'Kolkata': 'West Bengal', 'Surat' : 'Gujarat'} city = raw_input('Enter either of mumbai, pune, delhi, chennai, kolkata or surat: ') print 'The city is in the state: ', d[city]
dacf7b151ca32f9a035f75421867fa6690f44c6a
DanJ210/Python
/Assignments/Assignment 2/Assignment 2.py
1,254
3.609375
4
from tkinter import * master = Tk() Canvas = Canvas(master, width=600, height=600) Canvas.pack() Canvas.create_rectangle(150,150,450,500, outline="red") #Drawing the house structure Canvas.create_rectangle(350,200,400,250, fill="yellow") #Creating Windows Canvas.create_rectangle(300,200,350,250, fill="yellow") Canva...
7d689163e9bc2f7b43fb335a9cf13e45703d9d51
Hellofafar/Leetcode
/Easy/687.py
2,014
4.125
4
# ------------------------------ # 687. Longest Univalue Path # # Description: # Given a binary tree, find the length of the longest path where each node in the path has the same value. # This path may or may not pass through the root. # # Note: The length of path between two nodes is represented by the number of ed...
2fed755d008d371aa7ecfd4a0859865558eccd2e
AdamZhouSE/pythonHomework
/Code/CodeRecords/2451/60599/233605.py
305
3.53125
4
s=input() arr=[] num=int(input()) for i in range(len(s)): arr=list(map(int, s.split(','))) if(arr[0]>num): print(0) exit() for i in range(len(arr)-1): if(arr[i]==num): print(i) exit() elif(arr[i]<num and num<arr[i+1]): print(i+1) exit() print(len(arr))
7b20411b348f5c4d3a0297e7f3e02cbb232da5ec
estherica/wonderland
/Lessons/targil7.py
609
4.09375
4
##For loops for x in range(1,11): print(x) print("wow\n") list_esther=["banana","apple","mango"] for x in range(len(list_esther)): print(list_esther[x]) for x in range (1,11,2): print(x) print("wow\n") print("Now we will get all the details about your class!") for i in range(1,4): name=input...
51f1e3fdda085c69a8a3cee826f14f2901e48efc
abhishekatujjain/OpenCV2
/contours.py
1,263
4.03125
4
import numpy as np import cv2 '''Contours are useful for shape analysis, object detection For better accuracy we are using binary files Before finding contours we are applying threshold or cannygradient''' def drawContour(): img = cv2.imread('opencv-logo-white.png') imgray = cv2.cvtColor(img, cv2.COLOR...
c899acddb25ccb47532919c05aac1300340a0fab
buketsahin/GlobalAIHubPythonHomework
/BuketHW2.py
351
4.125
4
Name=input("Please,enter your name:") Surname=input("Please,enter your surname:") Age=int(input("Please,enter your age:")) Birthyear=input("Please,enter your birth year:") x=[Name,Surname,Age,Birthyear] for i in x: print(i) if Age<18: print("You can't go out because it's too dangerous.") else: pri...
651eca57e2131f84b24fea039a607f0f1672467c
Danilo-Xaxa/python_curso_em_video
/Desafio 54 (Sete maioridades).py
261
3.953125
4
from datetime import date menores = 0 for x in range(1, 8): pessoa = int(input(f'Digite o ano de nascimento da {x}ª pessoa: ')) if date.today().year - pessoa < 21: menores += 1 print(f'{7 - menores} são maiores e {menores} são menores.')
c85ce045b69ec14dd5c39b7a599f9f31cc24d47b
NeopoloJIND/Programacion
/Ejercicio 43.py
1,060
4.03125
4
# Ejercicio 43 # Es común que las imágenes de los líderes anteriores de un país, u otras personas de importancia histórica, aparezcan en su dinero. # Las personas que aparecen en los billetes en los Estados Unidos son las siguientes. # Escriba un programa que comience leyendo la denominación de un billete del usuar...
c918b383fe249a5acd96de69716b7e71fd07269e
aldsouza4/Important-Questions
/Apna Col/LinkedLists.py
5,450
3.921875
4
class Node: def __init__(self, data): self.data = data self.next = None def insertTail(root: Node, data): if root is None or root.data is None: return Node(data) current = root while current.next: current = current.next current.next = Node(data) def insertHead(...
47f4cc5510d5ef11babd687cb5fc61b4195c80f2
rjsilvestre/python-sundry
/intro-comp-prog-guttag/fex-p102.py
355
3.984375
4
def sum_digits(s): """Assumes s is a string. Returns the sum of the secimal digis in s. For example , if s is 'a2b3c' it returns 5. """ result = 0 for e in s: try: result += int(e) except ValueError: pass return result # Test cases print(sum_digits('a...
06fbfc81853100d5dc80f2b5a9e80c84164bbc68
hugo-wsu/python-hafb
/Day2/my_iterables_part2.py
1,690
4
4
#!/usr/bin/env python3 """ Author : hvalle <me@wsu.com> Date : 8/10/2021 Purpose: Continue Comprehensions and iterables """ # -------------------------------------------------- def main(): """Make your noise here""" # List Comprehensions: [expr(item) for item in iterable] # Set Comprehensions: {expr(...
434154ee1c4209691e11f22e6b55328f5a02aab0
Blychro/Computer-Programming-1-Lab
/circle.py
910
3.625
4
# name 1 - Thomas Marshall # name 2 - Kasper Dugaw # name 3 - Clare Cleaver from point import Point import math class Circle: def __init__(self,xVal,yVal,radius): self.center = Point() self.center.setX(xVal) self.center.setY(yVal) self.radius = radius def getCent...
16f41388a26ba13cd86a011bf346a95a0cfe30db
sonypasokan/leetcode_python
/problem 100-199/124/124.py
997
3.8125
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 __init__(self): self.max_sum = float('-inf') def maxPathSum(self, root: TreeNode) -> int: ...
b6399ba63b561e71e8cf4689d70189abf24e780f
andrabogildea/cci
/ch3/5.py
744
3.953125
4
class Queue: def __init__(self, iterable=None): if iterable is None: iterable = [] self.input = [] self.output = [] self.size = 0 for i in iterable: self.put(i) def put(self, val): self.input.append(val) self.size += 1 def rem...
b72901a0d1a9d8144664f270023224376b6eb0a8
rstojan/Learning_Python
/Section8/task9.py
249
3.828125
4
# Complete the function to print the specified hourly rate with two decimals def displayHourlyRate(rate): # Student code goes here # expected output: $34.79 displayHourlyRate(34.789123) # expected output: $24.12 displayHourlyRate(24.123456)
44eacbfa282ec563dcbbca100782014785eb22f5
Sophy8281/b-refresh
/tuples.py
838
4.5625
5
# Creating a Tuple this_tuple = ("apple", "banana", "cherry") print("A simple tuple") print(this_tuple) # Returns ('apple', 'banana', 'cherry') print("------------------------------------") # Getting the item in position 1 this_tuple = ("apple", "banana", "cherry") print("Getting the item in position 1") print(this_t...
59eb5bbb1c49db1807c4889a9fe61ed85c0e9da4
jacobdenobel/adventofcode
/2022/day4.py
941
3.625
4
def get_range(e: str) -> range: source, target = map(int, e.split("-")) return range(source, target) def full_overlap(e1: range, e2: range) -> bool: if e1.start >= e2.start and e1.stop <= e2.stop: return True if e2.start >= e1.start and e2.stop <= e1.stop: return True return False ...
0cd1e3a66d54b37aefee9a8b013868a2c0c8335a
greenfox-zerda-lasers/bednayb
/week-05/day-04/view_elevator.py
1,212
3.828125
4
# Create a class the displays the Elevator art and navigation (list of commands) ### PICTURE ### class View: def __init__(self,all_levels,current_level,people): self.current_level = current_level self.all_levels = all_levels self.people = people def Picture(self,all_levels,current_l...
3bab0b34dd98718fbe4caac6350fb5e53f8f3e0b
spnow/labs
/13-14/timing-attack/skelattack.py
946
3.65625
4
#!/usr/bin/env python import time import urllib import urllib2 def timerequest(url, data=None): # start a primitive timer start = time.time() # data is assumed to be a python dictionary payload = urllib.urlencode(data) # make our http request, if data is provided we will send # a POST request...
46e0e38efc77d85b794452675d4fbc81f5d6d4f7
Gulmira93/Gulmira93
/strings.py
2,433
4.53125
5
# 03/04/2021 String(str) # string is a sentence, character, number, a word as a character that # represents character ! fullname= 'jon doe' msg="we are looking at string functions in python." #print (fullname) #print (fullname.upper()) #print(msg.lower()) #print(fullname.title()) #print(msg.replace('.', '!!!!!!!').ti...
edfb5e26c338b2fdfb3b71c33deaa37e3a371ea5
dtalluri/Python-Learning
/basics/seq.py
331
3.640625
4
# python list x = [10, 2, 3, 4] for i in range(0, 4): print("x[", i, "] = ", x[i]) y = [2, 7, 0, 3] z = [5]*4 print(z) for i in range(0, 4): z[i] = x[i]+y[i] print(z) total = 0 for i in range(0, 4): total += z[i] print(total) print(sum(z)) # total = 0 # total = total + z[0] # total = total + z[1] # tot...
936ae2dc8503f3af96fbfeddc2f1834d9041af6f
Sanngeeta/function11
/question 4_sum.py
484
3.8125
4
def add_numbers(number1,number2): print(number1+number2) add_numbers(56,12) def add_numbers(number1,number2): i=0 sum=0 while i<len(number1): a=0 while a<len(number2): sum=number1[i]+number2[i] a=a+1 print(sum) i=i+1 add_numbers...
59171ebcc9e21b792a20755f3c4e6382bf1adee5
MasterOdin/Projects
/Text/vowel_count.py
294
3.65625
4
# last update: 11/1/2013 # python version: 2.7.5 import sys if __name__ == "__main__": if len(sys.argv) != 2: print "Usage: vowel_count.py string" sys.exit(0) vowels = "aeiou" string = sys.argv[1] for v in vowels: print "%s: %d" % (v,string.count(v))
1c20a3c70116740153b4f82e63bb95a9e011626b
jadhavamit1444/Python-
/Assignments/assignment 2/assignment_2.5.py
335
4.0625
4
def prime(): print("Enter the Number"); a=int(input()); if a > 1: for i in range(2, a): if (a % i) == 0: print(a, "it is not a prime number") break else: print(a, "it is a prime number"); else: print(a, "it is not a prime number...
cf7cdcfcc19bd0d973b8068a753402c016331699
jtveals1/my-python-software
/snowman.py
2,212
4.09375
4
#Jason Veals #6-25-2016 #Snowman - Fun with Graphics #This program uses Python graphics to draw a snowman from turtle import * def main(): reset() drawFace() drawBody() drawArms() drawHat() ht() # turn off the turtle return "Done!" def draw_circle(x, y, radiu...
69d71baa5d4885998248225f51fe08f1ac8425e8
gschen/sctu-ds-2020
/1906101043-尹志强/讲解.py
852
3.984375
4
a='hi' b='s' print(a+b) #重复字符 c='hi' print(c*3) str1='abcde' print(str1[0]) print(str1[-1]) print(str1[0:4]) print(str1[::-1]) print('b' in str1) print('v' not in str1) #格式化输出 print('我叫%s'%('ST-one')) print('我叫{}'.format('ST-one')) print('我今年%d'%(20)) ...
04c8c9881e914298ba8ad3675a94c25e0afe48dd
vedant-kakde/Py-Projects
/1-word counter/word-counter.py
491
4.0625
4
# WORD COUNTER # We want a program which can count the words from each text file automatically # First we need a sample text file !wget https://filesamples.com/samples/document/txt/sample1.txt # Opening a file using read mode f = open("/content/sample1.txt", "r") # Empty List c=[] # Splitting all the words inside ...
52e9bd008f7f89444d34b573e9056b8daea6c556
psf/black
/tests/data/simple_cases/bracketmatch.py
333
3.59375
4
for ((x in {}) or {})['a'] in x: pass pem_spam = lambda l, spam = { "x": 3 }: not spam.get(l.strip()) lambda x=lambda y={1: 3}: y['x':lambda y: {1: 2}]: x # output for ((x in {}) or {})["a"] in x: pass pem_spam = lambda l, spam={"x": 3}: not spam.get(l.strip()) lambda x=lambda y={1: 3}: y["x" : lambda y...
4ea260c3799ae5281c0ae2db5155802e5da1e8bc
cxc1357/PythonBasic
/levelOrder.py
1,102
3.515625
4
# day53:二叉树层序遍历 # 按照根-左-右顺序入队 from listToBinarytree import listToBinarytree from collections import deque class TreeNode: def __init__(self,x): self.val = x self.left = None self.right = None class Solution(object): def levelOrder(self,root): if not root: return []...
d3649efd79cb9432be49caca6ced2062d703b588
Shaunwei/ProjectEuler
/problem15.py
1,106
3.984375
4
#!/usr/bin/python #! -*- coding: utf-8 -*- __author__ = 'shaunwei' """ Lattice paths Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 grid? solution thinking: to finis...
f61cee8ee81a159ddc51218cefd46d734d162bc1
Tadele01/Competitive-Programming
/week-01/Day-02/mark_and_toys.py
1,367
3.859375
4
def maximumToys(prices, k): ''' the thought i have right now is can we remove first all the toys mark can't buy which is the toy with price greater than marks budget why do we want to remove all these values ? for optimizing our sorting a little bit for practice purpose ...
03b6ad3879a7054ff86b8afa9117041f6f5329b2
LeoneVeneroni/python
/exercicios/Aula6/aula6_exercicio6.py
370
3.8125
4
import turtle le = turtle.Screen() le.bgcolor("green") le.title("Loucura, "*3) jaja = turtle.Turtle() jaja.color("lavender") jaja.pensize(5) def square(t): for i in range(4): t.forward(120) t.left(90) square(jaja) jaja.penup() jaja.forward(80) jaja.pendown() def square(bob): for i in range(4): bob.forward(...
8213f2065fe8dd5b01b7c05dbd1a06d4fc98dcb1
ms12334/text_merge
/merge_files.py
1,083
3.5
4
# This script merges multiple text based files into one log file. # The log file can includes file names and directory informations, too. # Place files you want to merge under the root directory. Then, run this script. # Root directory: rootdir = 'C:\\Projects' # Output file: fileContentLog = 'fileContent.log' ...
1cb21d714142320b8d310dadbcd6a30bb5fabd13
piyus22/AlphaBionix
/Basic_code/Bio_pyt_basic.py
359
3.796875
4
#By- Piyus Mohanty #Download Biopython to execute this from Bio.Seq import Seq #create a sequence object x=input("Enter DNA sequence") my_seq = Seq(x) #print out some details about it print ("seq %s is %i bases long" % (my_seq, len(my_seq))) print ("reverse complement is %s" % my_seq.reverse_complement()) print ("pro...
f547d8b79421083fc303c45ffaeb028f485367aa
Nuwisha/nuwisha_hackerrank
/python/01_introduction/loops.py
403
4.125
4
a = int(input()) for i in range(a): print(i*i) task = """ Task Read an integer . For all non-negative integers , print . See the sample for details. Input Format The first and only line contains the integer, . Constraints Output Format Print lines, one corresponding to each . Sample Input 5 Sample O...
991a39f5e33efdedab569f41e9a78ac24df7f145
Junyang-chen/PythonLearning
/Graph.py
906
3.515625
4
input1 = [3, [[1,3],[2,3]]] output1 = 2 input2 = [3, [[1,2],[2,3],[3,1]]] output2 = -1 def minimumSemesters(N, relations): from collections import defaultdict from queue import Queue graph = defaultdict(set) inCount = [0]*(N+1) for relation in relations: graph[relation[0]].add(relation[1...
a3a7cf29864dbf6c90c72897c127fbf702343988
oanapanduru/python-exercises
/OOP_6.py
963
3.921875
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 5 22:50:30 2020 @author: oanap """ class Fruit: def __init__(self, name, price): self.name = name self.price = price def get_name(self): return self.name def get_price(self): return self.price def again_function(grocery_list...
92649a8c536efe91b944c7257ae0b09f9188e723
Khrystynka/LeetCodeProblems
/150_evaluate-reverse-polish-notation.py
1,105
3.578125
4
# Problem Title: Evaluate Reverse Polish Notation class Solution(object): def evalRPN(self, tokens): """ :type tokens: List[str] :rtype: int """ stack = [] op = set(['+', '-', '*', '/']) def calc(op, op1, op2): op1 = int(op1) op2 = int...
ce4ac48fdeb0b10ef7f5691264999876065fa2a8
nian8203/python
/pruebas/operaciones.py
4,352
3.8125
4
def sumaLista(lista): num = 0 suma = 0 for num in lista: suma+=num return suma def suma(num1, num2): res=num1+num2 return res def resta(num1, num2): res=num1-num2 return res def multi(num1, num2): res=num1*num2 return res def div(num1, num2): res=num1/num2 ...
1e02a6af06f8339adcc38ac17c28c4172dc1ffa4
shivam-arora742/python_hackerRank
/Python-hackerRank/loops.py
72
3.625
4
n = input("enter no:") n=int(n) i=0 while(i<n): print(i*i) i=i+1
d376a387deb50e2fc8b100b186831f94f9f9630b
NicsonMartinez/The-Tech-Academy-Basic-Python-Projects
/Object Oriented Programming - Learning/OOP1.py
282
3.9375
4
#Writing the class class Game: variable1 = 'Hello' variable2 = 'World!' if __name__ == "__main__": x = Game() #instantiating that class, giving it instance 'x' print("{} {}".format(x.variable1,x.variable2)) #giving that instance it's attributes and values
53d35c5281eb475b20fdd05c7557c149d984db02
Fo12cE/git_tutorial
/test01.py
2,284
3.5
4
import tkinter as tk from tkinter import * from tkinter import messagebox def write_file(data): with open('customer.txt', 'a', encoding='utf8') as f: f.write(data + '\n') def submitButton(): messagebox.showinfo(title='แสดงข้อความ', message='เพิ่มข้อมูลเรียบร้อย') list_data = ','.join([name_title...
0fa42f48c24e673e23f7c0907bdc46ff2686019b
Malavshah999/MyCapPython
/PositiveIntegers.py
278
3.96875
4
#Checking Positive Integers in given series list1 = [10, -21, 4, -45, 66 ] for num in list1: if num >= 0: print("List1 :[" , num , "]") list2 = [1, -11, 40, -4, 8 ] for num in list2: if num >= 0: print("List2 :[" , num , "]" )
4a6b237f887304e6b1d6ee9eb4cb9163e96ba3cc
rodrikmenezes/PythonCursoUSP
/PyCursoUSP - Parte 1/semana 5/maior_primo.py
746
3.671875
4
def maior_primo(x): ''' A função maior_primo que recebe um número inteiro maior ou igual a 2 como parâmetro e devolve o maior número primo menor ou igual ao número passado à função ''' divisores_primos = [] # este laço percorre todos os valores de 1 a x for i in range(1, x + 1): # es...
dbd4dcca9e5b6f0e7624f89578e47bcaab3e2761
iBelieve/adventofcode
/2017/04.py
2,038
4.0625
4
#! /usr/bin/env python3 from util import expect, solution, input # A new system policy has been put in place that requires all accounts to use a # passphrase instead of simply a password. A passphrase consists of a series of # words (lowercase letters) separated by spaces. # # To ensure security, a valid passphrase ...
b0a78406b54210005bc49b7ccbf126902d949fda
rransom96/game-of-sticks
/game_of_sticks.py
1,234
3.90625
4
class Player: def __init__(self): self.pick_up = 0 def how_many(self): pick_up = input("How many sticks do you take (1-3)? ") if 1 <= int(pick_up) <= 3: self.pick_up = pick_up class Game: player1 = "" player2 = "" def __init__(self): self.starting_amou...
532e9658da501a00dcd622077d68ce4f3a0e0c9c
xinwang26/leetcodeprac
/search_rotated_sorted_array.py
1,379
3.625
4
#the sampled faster solution is not really faster class Solution: def search(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ if len(nums) ==0 or (len(nums)==1 and nums[0]!=target): return -1 if len(nums) == 1 and n...
09a53fb7c22d190586e0de3d43a443e2aef58f3a
kalvatn/advent-of-code
/2016/03/solve.py
1,436
3.953125
4
#!/usr/bin/env python def main(lines): possible = 0 for line in lines: sides = [int(x) for x in line.strip().split()] largest = sides.pop(sides.index(max(sides))) sum_smaller = sum(sides) if sum_smaller > largest: possible += 1 print possible def part_two(lines)...
ab561763d6c1329ad0e09d9957393a26e2732b1a
ElijahMcKay/Algorithms
/stock_prices/stock_prices.py
965
3.84375
4
#!/usr/bin/python import argparse stocks = [1050, 270, 1540, 3800, 2] def find_max_profit(prices): # defining a variable to contain our max profit so far. Find a more elegant solution for this max_profit = -10000 for i in range(len(prices)): # looping through each value after the current (we can't compare to v...
060a8cc93a77909c728f4955c37e826d2541d988
jbsribas/Programacao_de_Computadores
/aula 10/exemplo6.py
513
4.28125
4
# exemplo 6 - calcular media e fatorial por função #definir as funções def media(a,b): return((a+b)/2) def fatorial(n): prod = 1 for j in range(1,n+1): prod = prod *j return prod # chamada das funções / metodos no código x = float(input("Digite o 1° valor: ")) y =...
ca14925a81bf587570f1de8cf2559ea58697dfea
ShinjiKatoA16/azuma-python2
/for4-03.py
285
3.8125
4
# Python-2 P34 for4-03 column = int(input('column number =>')) row = int(input('row number =>')) if column <= 0 or row <= 0: print('invalid!') else: for r in range(row): out_s = '' for c in range(column): out_s = out_s + '◇' print(out_s)
6aa871efacd5815644ddc05eb2b7cde7517df018
eronekogin/leetcode
/2021/minimum_cost_to_hire_k_workers.py
917
3.53125
4
""" https://leetcode.com/problems/minimum-cost-to-hire-k-workers/ """ from heapq import heappush, heappop class Solution: def mincostToHireWorkers( self, quality: list[int], wage: list[int], K: int) -> float: """ 1. Sort the ratio from w / q based on the quality and wage. 2. F...
7598e053f94c54d8c0d04a38937f0298ec145ff5
hedgepodge/exercise
/introduction_2020.06/baseball_game.py
4,970
3.75
4
### Version 1 ### from random import randint numbers = [] while len(numbers) < 3: new_number = randint(0, 9) while new_number in numbers: new_number = randint(0, 9) numbers.append(new_number) print("0과 9 사이의 서로 다른 세 숫자를 랜덤한 순서로 뽑았습니다.\n") print("세 수를 하나씩 차례대로 입력하세요.") strike, tries = 0, 0 whil...
bb662da9a3e0d9c62e43a592f123ca8ede7dd857
olorules/NiDUC-projekt
/controler_cable.py
631
3.53125
4
def read_controler_cable(): file = open('Kontroler sprzętowy+kabel.txt') lines = [] dictionary = dict() for line in file: line = line[:-1] lines.append(line) file.close() lines_count = len(lines) i = 0 while i < lines_count: dictionary[lines[i]] = lines[i+1] ...
53287d4bde000d89f42ebe7d871962c2bed5a2f7
thezephyrus/Codewars
/Python/Sort and star.py
292
3.640625
4
def two_sort(lst): return '***'.join(min(lst)) def two_sort(array): array.sort() return str.join('***',array[0]) def two_sort(a): a = sorted(a) result = a[0] result = result.replace("", "***") return result [3:-3] two_sort = lambda a: "***".join(sorted(a)[0])
b407e4970199edcbec889584b5b0100cb3b98099
Quidmye/Okten-python
/hm/hm3.py
5,411
4.28125
4
# Создать класс Rectangle: # -конструктор принимает две стороны x,y # -описать арифметические методы: # + сума площадей двух экземпляров класса # - разница площадей # == или площади равны # != не равны # >, < меньше или больше # при вызове метода len() подсчитывать сумму сторон class Rectangle: x = 0 ...
652ac8ecb46f02dcf7df1b755a5649ce539afb43
Corri3141/F2Depine
/Ejemplo pulso rectangular.py
308
3.578125
4
from F2Depine import soga def F(x): if x <= 10/3: return 0 elif x>= 10/3 and x <= 20/3: return 3 else: return 0 pulso_rectangular = soga.CondicionesIniciales("cerrado", 10, 60, F, range(100)) #10 es el largo de la soga , 60 es v_f anim = pulso_rectangular.animate(1000)
33506c2f67b07f484c5b4b920e209d2051546f17
ankitdbst/Utilities
/ciphers/affine.py
1,673
3.984375
4
#!/usr/bin/env python from cipher import * class AffineCipher(Cipher): """A Class to encrypt or decrpyt a affine cipher""" a = 0 b = 0 message = "" def init(self): """ Initialize data structures """ print 'enter the message to encrypt/decrypt :', self.message = raw_input()...
600c5be3cf8d589afafbff073f6b66338e7aea7d
nbaak/Snake
/src/lib/point_to_direction.py
432
3.59375
4
from lib.Direction import Direction def point_to_direction(current_position,next_position): dir_x = next_position[0] - current_position[0] dir_y = next_position[1] - current_position[1] if dir_x > 0: return Direction.RIGHT if dir_x < 0: return Direction.LEFT if dir_y > 0:...
228cf9ee430c2f729a193dfddac3e0c181b1dca1
bjisa/project-euler
/problem-003/problem3.py
589
3.609375
4
# Project Euler # Problem 3 def nextPrime(n): keepChecking = True while keepChecking: keepChecking = False n += 1 for x in range(2,n): if (n % x == 0): keepChecking = True return n def primeFactorization(n): factors = [] count = 0 divisor = ...
4733c156ab6b57a4144413b663d013a4de2d2ec4
bomtall/remote-quote
/knapsack.py
1,119
3.796875
4
# 0/1 Knapsack optimisation algorithm implemented using Python. def optimal_knapsack(capacity, values, costs): # adding 0th column to values/costs on the y axis values = [0] + values costs = [0] + costs # initialising matrix kj k = [] # adding 0th column to capacity on x axis list_budget_...
c1363de1117841015e67fe8901a259b61006d7bc
tnakaicode/jburkardt-python
/polpak/chebyshev_discrete.py
2,822
3.59375
4
#! /usr/bin/env python # def chebyshev_discrete ( n, m, x ): #*****************************************************************************80 # ## CHEBYSHEV_DISCRETE evaluates discrete Chebyshev polynomials at a point. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 19...
20faf8787d3dc5268803b46f979956b3b1a99c27
DanilaLabydin/python_tasks
/pythonProject7/nb_verses.py
1,594
4.40625
4
## # create a program that display the lyrics of "The Twelve Days of Christmas" song # using the int2ordinal function, the user entered the number of verse and the program should # display the right verse of the song # from int2ordinal import int2ordinal NB_OF_VERSES = 12 # create a function that display the verse of ...
793b92c1fc1550825ee434f09d4b493cd198561c
R-MONISHA/python-programming
/beginner level/palindrome or not using stack or list.py
144
3.84375
4
def reverse(s): return s[::-1] def isPalindrome(s): rev = reverse(s) if (s == rev): print yes else: print no
295efb4af4711b7cff0b60949eb32329879503f6
imsreyas7/Artificial-Intelligence
/8 Puzzle/8Puzzle.py
3,290
3.59375
4
import copy from collections import deque from queue import PriorityQueue import heapq state=[] # -1 denotes a blank space initial=[[7,2,4],[5,-1,6],[8,3,1]] goal=[[-1,1,2],[3,4,5],[6,7,8]] #explored=[] #discovered=[] mydict = {} def gen_states(state): next_states = [] for i in range(3):...
0da2bf90f866af3c2978408291f85cf3273fc7a0
partho-maple/coding-interview-gym
/algoexpert.io/python/Boggle_Board.py
1,524
3.78125
4
def boggleBoard(board, words): trie = Trie() for word in words: trie.add(word) finalWords = {} visited = [[False for lettern in row] for row in board] for i in range(len(board)): for j in range(len(board[i])): explore(i, j, board, trie.root, visited, finalWords) retur...
505571fba99ebd3fd0262b57d4256edbcb6ca78e
binarypearl/Tower-of-Hanoi-Blender
/tower_of_hanoi.py
29,454
3.96875
4
import bpy import time import sys # This script moves the disks in our Tower of Hanoi animation. # The basic setup is this: # There are 3 towers, with all 3 discs at rest on the left most tower. # After running this script: # The 3 discs will have moved to the middle tower per a recursive algorithm # Key f...
17f1c848ade52460ef5f5cca21904369db9c7e56
pulsztercsaba69/csabi
/csabi2.py
152
3.65625
4
#1 adat = input() tort = float(adat) egesz = int(tort) if tort >= 0.0 and tort == egesz: print('természetes szám!') else: ('nem természetes!')
b83e6017a00b205f6d4ddfeb7133c351efe4899f
Arehandoro/setp02
/es_palindroma.py
1,001
4.375
4
#UNIVERIDAD DE SANTIAGO DE CHILE #Carrera: Licenciatura en Ciencias de la Computación. #Asignatura: Lenguaje y Técnicas de Programación. #Profesor: Igor Caracci. #Ayudante: Andrés Caro Q. #Autor del Programa: Alejandro Alberto Sánchez Iturriaga. #Problema 02 - Palíndroma: def es_palindroma(cadena): #Función qu...
c76fadc5d54bc2b0849a0f87a10be5cdf1aebd98
imamol555/Python-Workshop
/list.py
299
4.21875
4
newlist = [1,2, ["a",'b','c'], [4, ["x",'y','z'] ] ] def print_list(mylist): for item in mylist: if isinstance(item,list): print_list(item) else: print(item) print_list(newlist)
8a3605bcb6d0e161b69efbf8b343755304f1b6b0
FBarto/WorkSpace-AED-1-Irems-
/Principal.py
931
3.796875
4
import Funciones def menu(): print("1: Numeoro mayor a 10") print("2: Suma igual al tercero") print("3: Dividir el cuadrado") print("4: Obtener Grados celcius") opc = int(input(" Ingrese la opcion deseada:")) if( opc == 1): Funciones.mayorA10() elif( opc == 2): primernum = ...
3033a8c3d9b36e56b10857375bdafe0fa406d15b
kathuman/Python3_Essential_Training
/11 Functions/functions-arbitaryargs.py
1,594
4.40625
4
#!/usr/bin/python3 # functions.py by Bill Weinman [http://bw.org/] # This is an exercise file from Python 3 Essential Training on lynda.com # Copyright 2010 The BearHeart Group, LLC ## use one star argument, *arg, and two star variable(keyword argument) for passing arbitrary arguments to function # *arg, pass as all ...
509e51fa20badfe4de16a8e26309a3a4f8f47c55
szaveri99/PYTHON_CODES
/cst/assignment-3/ques-4.py
375
3.5
4
n=input("Enter a No. : ") n=" ".join(n) l=list(map(int,n.split(" "))) while len(str(sum(l))) > 1: n=str(sum(l)) n=" ".join(n) l=[] l=list(map(int,n.split(" "))) if sum(l) == 1: print("Its a magic Nunber with sum ",sum(l)) break else : print("Not a magic number..")...
a594d949a2369a28680035a598f03422c03cb052
daniel-reich/ubiquitous-fiesta
/7jcWz9Kmr4rTSwdjK_20.py
428
3.890625
4
def is_prime(x): for i in range(2,x-1): if x % i == 0: return False return True ​ def prime_factorize(num): temp = num factor_list = [] counter = 2 while counter <= num: if num % counter == 0 and is_prime(counter): factor_list.append(counter) ...