blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
302da1ed10202f3d7c8a421b47b0639b8d103745
Brainchildtech/codes
/primenumber.py
90
3.65625
4
n=int(input("num")) for i in range(1,n+1): while n>0: if i%2!=0: print i
ba2e73fedd48f3cb0ccb0bd376899bda371833b6
Oizys18/Algo
/preset/Python/BinarySearch.py
1,365
3.828125
4
# >> Most Generalized Binary Search # Suppose we have a search space. It could be an array, a range, etc. Usually it's sorted in ascending order. For most tasks, we can transform the requirement into the following generalized form: # Minimize k , s.t. condition(k) is True # The following code is the most generalized ...
28b99716f6d12fa73379f684fcebf4e0ed96214b
pierpaolo28/Algorithms
/Sorting/bubble_sort.py
261
3.6875
4
def bubble_sort(inp): for i in range(len(inp)): for j in range(len(inp)-i-1): if inp[j] > inp[j+1]: inp[j], inp[j+1] = inp[j+1], inp[j] return inp arr = [33, 55, 2, 7, 1, 1, 6778] print(arr) print(bubble_sort(arr))
5ae34e3821c1d3dd8476ad6bc319fefbd94aa08a
shiva-marupakula/Student-Management-System
/src/main/webapp/python/unit1/billpay.py
444
3.953125
4
# to calculate bill amount for item. a=input("enter item name") b=float(input("enter the quantity")) p=float(input('enter price of item')) d=float(input('enter the discount')) tp=(b*p) dis=tp*(d/100) g=tp-dis print ("*******************BILL**********************") print ("item name\tquantity\tprice\tdiscount") print ("...
78081d048f66e57d2119cde2f81fd62b726a1c8a
gundam1996/pyWebCheck
/simple_client.py
816
3.796875
4
#/usr/lib/python2.7 from BeautifulSoup import BeautifulSoup import re import urllib, urllib2 str1 = raw_input("Please enter the network address: ") if "https://" in str1: try: response = urllib2.urlopen(str(str1)) except URLError: print "Cannot open website!" response = None elif "http://" in str1: try: ...
1658d3f9ad7cb1ebb888c2cf415b08a85fe836f5
bakliwalvaibhav1/Python-HackerRank
/01) Introduction/if_else.py
266
3.71875
4
""" TITLE: Python If-Else INPUT: 12 OUTPUT: Weird """ if __name__ == '__main__': n = int(input().strip()) if(n%2 != 0): print("Weird") else: if(n>=6 and n<= 20): print("Weird") else: print("Not Weird")
7ea0a0c2eb86a91dc2cad331b1594baf67268300
01bui/Finding-Hidden-Messages-in-DNA
/patternCount.py
671
3.578125
4
import pdb def patternCount(Text, Pattern): count = 0 textList = list(Text) patternList = list(Pattern) print len(textList) print len(patternList) for i in range(0,len(textList)-len(patternList)+1,1): if textList[i:i+len(patternList)] == patternList: count += 1 return co...
75756eccac53bc1ac240762265ae5247e8b1df17
pjp/KeyboardReader
/skid_steering/InputHandler.py
17,060
4
4
__author__ = 'Paul Pearce' ################################################################ # Logical input values to translate to motor speed and direction # # Use these so they logically match the numbers on the numeric keypad STOP = 5 LEFT = 4 RIGHT = 6 FORWARD = 8 BACK = 2 import math import log...
cfac6a4cfa53ab57b0c46ffed668eeba9a690c5d
yj846272692/python-study
/Day1/year.py
370
4
4
# 输入年份,如果是闰年输出True,否则输出False def is_leap_year(): year = int(input('请输入年份:')) # 如果代码太长写成一行不便于阅读,可以使用 “\” 对代码进行折行 is_leap = (year % 4 == 0 and year % 100 != 0) or \ year % 400 == 0 print(is_leap) if __name__ == '__main__': is_leap_year()
61d63fbbd1eec1a5e783c5dfa4ce7dd9b31dd4ae
Par1Na/Twowaits
/day4-1.py
380
3.875
4
# Twowaits Twowaits Problem # Program to count the number of times an element # Present in the list # Count function is used def Count(tup, en): return tup.count(en) # Driver Code tup = (10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2) enq = 4 enq1 = 10 enq2 = 8 print(Count(tup, enq), "times") print(Cou...
1a524616a16c0aa619bff003c9fda9b0f84f0f67
Harini-Pavithra/GFG-11-Week-DSA-Workshop
/Week 4/Hash/Problems/Top K Frequent Elements in Array.py
1,961
4.0625
4
Top K Frequent Elements in Array - | Given a non-empty array of integers, find the top K elements which have the highest frequency in the array. If two numbers have the same frequency then the larger number should be given preference. Example 1: Input: N = 6 A[] = {1,1,1,2,2,3} K = 2 Output: 1 2 Example...
71118ba4f37754502c3e0b8124febf5bbeeb339d
tracietung/Python3
/ex03_02pay.py
578
4.09375
4
# Exercise 3.2 hours = input('Enter Hours: ') try: h = int(hours) except: h = -1 if h == -1: print('Error, please enter numeric input') else: rate = input('Enter Rate: ') try: r = int(rate) except: r = -1 if r == -1: print('Error, please enter numeric input') e...
dfa70c585b7dd60f8076cd5656bec1efeb9485f4
jyu197/comp_sci_101
/apt7/GreenIndexes.py
307
3.625
4
''' Created on Nov 4, 2015 @author: Jonathan ''' def green(pixels): greens = [] for pixel in pixels: values = pixel.split(",") if int(values[1]) > int(values[0]) + int(values[2]): greens.append(pixels.index(pixel)) return greens if __name__ == '__main__': pass
05a5bdf37911bccbb0b7bea498f090be24618c15
prashanthr11/Leetcode
/practice/Trees/Balance a Binary Search Tree.py
892
3.75
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: # Time: O(N) # Space: O(N) def balanceBST(self, root): def inorder(root): ...
2ba7dafa404a7d8f8bc71e004953cde395ce618c
zhenglaizhang/da-quest
/survey.py
1,509
3.625
4
import csv import pprint data_path = "./survey.csv" def run(): male_set = {'male', 'm'} female_set = {'female', 'f'} # value is list with 2 elements, 1st element is result of female, 2nd element is the result of male's result = {} with open(data_path, newline='') as csv_file: ...
079a9367fade3832a6a4f7046de7a50881992ee2
apalat12/turtle_project
/turtle_race_multiple_instance.py
1,352
4.09375
4
from turtle import Turtle, Screen from random import randint t1 = Turtle() t2 = Turtle() t3 = Turtle() t4 = Turtle() t5 = Turtle() t6= Turtle() t6.penup() t6.hideturtle() t1.shape('turtle') t2.shape('turtle') t3.shape('turtle') t4.shape('turtle') t5.shape('turtle') t1.color('red') t2.color('green') t3.color('blue') t4...
23e02b22fe457cd3111ed0e558aba6c2e5709ae4
shindeswapnil/46-Exercise
/39.py
1,216
4
4
''' Write a program able to play the "Guess the number"-game, where the number to be guessed is randomly chosen between 1 and 20. (Source: http://inventwithpython.com) This is how it should work when run in a terminal: ''' ''' >> import guess_number Hello! What is your name? Torbjörn Well, Torbjörn, I am thinking of a ...
d708b25adf102330ad54dfc7081fd1f9e5ceaf57
gladydennyson/Artificial-Intelligence-CS411
/15puzzlebfs.py
4,421
3.734375
4
from collections import deque import timeit import os import psutil from func_timeout import func_timeout, FunctionTimedOut # Creating a node class to hold the state, corresponding action and its parent class Node: def __init__(self, state , action, parent): self.state = state self.action = action self.paren...
2f20dd5873e30307eb8a848ab5bf14132b639546
malea/hunt-the-wumpus
/grubbm_hw3.py
12,598
3.546875
4
import sys from collections import namedtuple, defaultdict from json import dump GameState = namedtuple('GameState', ['board', 'location', 'orientation', 'arrow', 'alive', 'won', 'wumpus_dead']) Point = namedtuple('Point', ['row', 'col']) danger_map = { 'S': 'Wumpus', 'B': 'Pit', } def parse_board(string): ...
a12b403af3c586ad62e1b143018206b420f32719
nemac/fswms
/msconfig/ColorMap.py
1,640
3.734375
4
### ### ColorMap class for loading color maps from CSV files ### and accessing their values. ### ### Mark Phillips <mphillip@unca.edu> ### Fri Sep 17 16:07:05 2010 ### class ColorMap: ### ### Create a new ColorMap object by loading it from a CSV file ### def __init__(self, filename): f = open(fi...
0e078facda216da6b577e2298297edca074268fc
harshgujrati1/TOC
/stringEndingWith101.py
92
3.90625
4
string = str(input()) if string.endswith("101"): print('true') else: print("false")
5897cdbdd3da6a8d56c64c88e6a3ffd80ea5e338
carlos1500/Curso_Full-Stack_Blue
/Modulo 1/Exercícios de Aula/exercícios Aula 13.py
313
3.6875
4
def area(l1,l2): resultado = l1 * l2 print(f"a área do seu retângulo é: {resultado}") calculo = print("Insira o cumprimento dos lados do seu retângulo") lado1 = int(input("Digite o primeiro lado ")) lado2 = int(input("Digite o segundo lado ")) resultado = area(lado1, lado2) print(resultado)
c5167aaf0b17bc6b744043c389924270e3e235fe
nguyenlien1999/fundamental
/Session05/homework/exercise3.py
408
4.625
5
# 3 Write a Python function that draws a square, named draw_square, takes 2 arguments: length and color, # where length is the length of its side and color is the color of its bound (line color) import turtle def draw_square(size,colors): f = turtle.Pen() f.color(colors) # f.color(color) for i in range(3): ...
ae5b8b7b55c6e078a69a93dd39628a3596b84f9d
jdleo/Leetcode-Solutions
/solutions/429/main.py
1,038
3.859375
4
from collections import deque # Definition for a Node. class Node: def __init__(self, val=None, children=None): self.val = val self.children = children class Solution: def levelOrder(self, root: Node) -> list[list[int]]: if not root: return [] # level by level array, and queu...
b074fc975311a742c1dd01ad2544a6dc430bbbfe
PraghadeshManivannan/Python
/condition/even or odd using conditional operator.py
92
4.21875
4
a = int(input("Enter the number:")) print(a,"is even") if a%2 == 0 else print(a,"is odd")
d20de2cc0f4edd230b3adb0ca062349bcdd9c91e
nahaza/pythonTraining
/ua/univer/HW04/ch08ProgTrain04.py
1,056
4.3125
4
# 4. Morse Code Converter # Morse code is a code where each letter of the English alphabet, each digit, and various # punctuation characters are represented by a series of dots and dashes. Table 8-4 shows part # of the code. # Write a program that asks the user to enter a string, then converts that string to Morse code...
9a8c830d61d68a6725118f73446e2208c75fbcd5
Gabogg07/Tarea2-1211091-1310625
/Billetera.py
1,754
3.515625
4
''' Created on Feb 1, 2017 @author: Gabriel Gutierrez 13-10625 @author: Alessandra Marrero 12-11091 ''' import datetime class Registro: def __init__(self, monto, fecha, idEstablecimiento): self.monto = monto self.fecha = fecha self.idEstablecimiento = idEstablecimiento def devMont...
514c495bb7f9848b728518f4b0bd8de912c00d00
MaoningGuan/LeetCode
/字节跳动测试开发工程师面试准备/decorator_test_3.py
722
3.609375
4
# -*- coding: utf-8 -*- """ python装饰器实现函数运行时间统计 """ import time from functools import wraps import random # 装饰器函数 def print_info(func): @wraps(func) def wrapper(*args, **kwargs): start_time = time.time() result = func(*args, **kwargs) end_time = time.time() duration_time = end_...
3c2bbc3cf649d71fc0f2ebf6e311cfd9d2a5a05e
baichuan/Leetcode
/invert_binary_tree.py
769
3.96875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def invertTree(self, root): """ :type root: TreeNode :rtype: TreeNode """ # ...
cf8143123960eafc82e51df9a3c70a03cb31f422
dgpshiva/PythonScripts
/Array_GroupAnagrams.py
570
3.890625
4
from collections import defaultdict def groupAnagrams(input): sortedWordAnagrams = defaultdict(list) for item in input: itemList = list(item) itemList.sort() key = ''.join(itemList) sortedWordAnagrams[key].append(item) output = [] for valuesList in sortedWordAnagrams.i...
5760f09c016f910d32b4dc97b20e7697d9f77184
Philip-Cant-Reid/Bright-Network-Tech-Internship-Experience-google-coding-challenge-
/src/video_player.py
12,385
3.59375
4
"""A video player class.""" from .video_library import VideoLibrary import random import sys class VideoPlayer: """A class used to represent a Video Player.""" def __init__(self): self._video_library = VideoLibrary() self.playing = None self.paused = False self.playlists_names...
d26f03915c8e997b86a648f57868065071ba92c1
kiansweeney11/ca117-programming2
/If statements
115
3.71875
4
#!/usr/bin/env python x = input() y = input() if x == y print "square" else: print "rectangle"
25b47a125fe670f4c329cf77819dc852b4ff585d
alex-carvalho-data/hadoopFrankKane
/s04-spark/032-exercise-filterLowestRatedMovies10Times/LowestRatedMoviesRDD.py
2,222
3.5
4
from pyspark import SparkConf, SparkContext # Run it in cluster with spark-submit # spark-submit LowestRatedMoviesRDD.py # This function just creates a Python "dictionary" we can later use to convert # movie Id's to movie names while printing out the final results. def load_movie_names(): movie_names = {} wit...
a8ee2f667b95ed2391c8d61f14c98055c75bbd24
iasminastana/PyLearn
/functii2.py
1,340
3.90625
4
# 1func: # citim de la tastatura si returnam int # 2func: # 2 nr, le comparam # daca n1 >= n2 => true daca nu false # return, # 3func: # daca e true atunci cerem de la tastatura altul # 4func # daca e false # sa il printui pe primul nr impar mai mic decat el def cit_tast(): numarul = input('alege num...
7c332a012a4fc5112396a0d382388d02372bae3e
pcwu/leetcode
/047-permutations-ii/permuteUnique.py
892
3.578125
4
class Solution(object): def permuteUnique(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ def permuteIt(nums, current, results): for i in range(len(nums)): if len(nums) == 1: results.append(current + nums) ...
ae50b51b71ad1e2a2202324f407e44190581f251
jhonangelmireles/openERP
/funcionVerificarUltimoDigito.py
1,747
3.671875
4
#Esta funcion aparentemente sirve para verificar que el ultimo digito del RIF es el correcto o no lo es def calculoUltimoDigitoRif(RIF): lista = RIF.split('-') #posicion 0 Letra - pos 1 num_intermedio- pos 3 numero final #rellena con 0 a la izq por ejemplo 123 -> 00000123 num_intermedio_rif = lista [1].rjust(8...
ff23fc5933d57b4ff1d7f595a724a609f43933e7
davecrob2/BallerBot
/player_scraper.py
1,858
3.59375
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 27 16:12:13 2017 @author: davecrob2 """ import requests from bs4 import BeautifulSoup #Function to scrape an individual basketball reference page and combine all player names and player ids into a dictionary. #Accepts the url to the page as an argument def bb_scrape(link...
7b07e6601854da0360a3199deb459e73ac1528ea
sicknick21/cmpt120siconolfi
/tictactoe.py
5,458
4.15625
4
# CMPT 120 Intro to Programming # Lab #6 – Lists and Error Handling # Author: Nicholas Siconolfi # Created: 2018-10-23 import random def printBoard(board): # This function prints out the board and the rows. # print the top border # for each row in the board... # print the row # print...
df8cb1d8b7a6bab9e17bb64bd70ac59f0959f1a1
rvsingh011/NitK_Assignments
/Sem1/Algorithm/closest_pair.py
1,082
3.703125
4
# with user Input from math import sqrt import time def brute_force(points, n): least = 100000 pos1, pos2 = 0, 0 for x in range(0, n): x1, y1 = int(points[x][0]), int(points[x][1]) for y in range(0, n): if x == y: pass else: x2, y2 = ...
30d218417f115c77c08976801924d44e3b294a29
VPoshelyuk/Python_DS_and_Algo
/Chapter1/C120.py
250
3.53125
4
import random def shuffle(data): for i in range(len(data)): choice = random.randint(0, len(data)-1-i) data[i], data[len(data)-1-choice] = data[len(data)-1-choice], data[i] return data print(shuffle([12,4,54,-3,14,12,76,22]))
c0a6fb43da9259f457474ba7b396defed67101b9
kunalsanwalka/bapsf_test_files
/wave_amplitude_lineplot.py
5,970
3.59375
4
""" @author: kunalsanwalka This program plots the wave amplitude as a function of the z position """ ############################################################################### #############################User defined variables############################ #################################################...
57ccce190fb2daff6e2e6145c0e27df9ad5da6f1
adibsxion19/CS1114
/Labs/lab3Pr5.py
1,585
3.84375
4
# Aadiba Haque # CS - UY 1114 # 14 February 2020 #Lab 3 Problem 5 import turtle import math base_side = 100 base_angle = 72 side_triangle = (base_side / 2) / math.cos(math.radians(base_angle)) angle_star = 144 # Part 1 # turtle.forward(side_triangle) # turtle.penup() # turtle.forward(base_side) # ...
082d0e72957b748415f4e2f5fa1060b1852628eb
dieg00/pong_game_python
/scoreboard.py
772
3.796875
4
from turtle import Turtle SEPARATION = 230 class Scoreboard(Turtle): def __init__(self): super(Scoreboard, self).__init__() self.penup() self.hideturtle() self.sety(280) self.color("white") self.score = 0 def write_score(self): self.write(arg=f"{self.sco...
be138a7cfc8f055f46a93612114193ca84788b41
emrehaskilic/tekrar
/introduction/lesson3/kararYapilari1.py
791
3.921875
4
# KARAR YAPILARI # Karsilastirma operatorleri # == (esittir) sagdaki degerin soldaki degere esit olma durumu # 1 == 1 => true - ıf # 1 == 2 => false - else # != (esit degildir) soldaki degerin sagdaki degere esit olmama durumu # 1 != 1 => false - else # 2 != 1 => true - if # > (buyuktur) # < (kucuktur) # >= (buyuk...
b473e2eb316979e04483c26ebf34c3051c744e6e
daudras/Projet-Info-modelisation-d-une-file-d-automobiles
/IHM_new_code.py
3,768
3.890625
4
#!/usr/bin/python # -*-coding:UTF-8 -* #Circulation automobile d'une file de voiture #Il est question de creer 10 cellules ayant chacune en elle trois fenetres, avec possibilite de modifier individuellement les couleurs des fenetres et cellules en faisant appel aux fonctions selon le besoin : couleur_fenetre, tte(),...
2f720b6ede73e45103b04923f989774e3e609b6c
Lepajewski/PythonStudia
/Easy/comparetwonumbers.py
251
3.953125
4
t = int(input()) for i in range(t): m, n = input().split() m = int(m) n = int(n) if m > n: print(m, " is greater than ", n) elif m < n: print(m, " is smaller than ", n) else: print("n is equal m: ", m)
5d7143b6e27936fbb44d65ef0fb511ccf8afc2f7
Henry-Aybar/oop
/Users_with_bank_accounts/Users_with_bank_accounts.py
2,289
4.21875
4
class BankAccount: bank_name = "First National Dojo" all_accounts =[] def __init__(self, int_rate, balance): self.int_rate = int_rate self.balance = balance BankAccount.all_accounts.append(self) def deposit(self, amount): self.balance += amount # print(f"{self.n...
5d2f9463451116bd3c0f8523dbf023d22d338cf3
iffishells/Data-stucture-
/Assignment-solutions/Assignment_Number07
2,254
3.828125
4
class Person: def __init__(self,men,Age,queue_Number): self.Men=men self.Age=Age self.queue_Number=queue_Number def get_priority(self): if self.Age>=40: priority=100-self.queue_Number return priority+100 else: priority=100-self.queue_N...
e22b3122cb0f76d6f36f65a57b67575e61b9dba9
JeongYeonUk/Problem
/PS_Python/다음_큰_숫자.py
385
3.75
4
def int_to_bit(n): n_bit = [] while n: n_bit.append(n % 2) n = n // 2 return n_bit.count(1) def solution(n): n_bit_count = int_to_bit(n) n = n + 1 while True: next_bit_count = int_to_bit(n) if next_bit_count == n_bit_count: break n = n + 1 ...
49a6bdf834002fbaf455b1317bd6e44f0f0f1890
Gokulraj210/python
/bubble sort using fun.py
431
3.984375
4
def bubble_sort(alist): for i in range(len(alist)-1,0,-1): no_swap=True for j in range(0,i): if alist[j+1] <alist[j]: alist[j], alist[j + 1] = alist[j + 1],alist[j] no_swap=False if no_swap: return alist=input('enter the list of numbe...
d9303728563354d0b86ebb464a5a2981cf190df4
lamasumas/Machine_Learning
/ImageClassification/ImageClassificationLinearKernel.py
2,367
3.546875
4
import numpy as np import matplotlib.pyplot as plt from PIL import Image ## Read the data data_train = np.loadtxt("data_train1.txt") label_train = np.loadtxt("labels_train1.txt") data_test = np.loadtxt("data_test1.txt") label_test = np.loadtxt("labels_test1.txt") """ ## Testing the characters plt.figure(figsize=...
8f9a94aa8fd30c8123d8989665471fd8a86ea3c6
fulcorno/Settimane
/Settimana06/bisezione.py
1,791
4.09375
4
''' Sia data una funzione reale di variabile reale y = f ( x ). Si vuole trovare uno zero della funzione f nell'intervallo x ⋲ [a, b] usando il metodo di bisezione (valido se f() è continua e f(a)f(b)<0) ''' import math EPSILON = 0.0000001 def main(): print("Inserisci gli estremi dell'intervallo [a, b]") x1...
c0e9a88eb60a9e0f54d0f0313147a2ef2355c5f8
statistics-exercises/t-tests-10
/main.py
1,275
3.78125
4
import matplotlib.pyplot as plt import numpy as np def sample_variance( data ) : # Your code to compute the sample variance goes here def common_variance( data1, data2 ) : # Your code to compute the common variance using the formula in the # description on the left goes here # This code generates the...
2ba18d4ca6bf2547477ffa4d2a28037dc81a2596
sunnyyeti/Leetcode-solutions
/221 Maximal Square.py
1,868
3.515625
4
# Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. # Example 1: # Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] # Output: 4 # Example 2: # Input: matrix = [["0","1"],["1","0"]] # Out...
c9dc46c39b7968e91a4d2bd847f44e32ebc9a335
LimFangYong/DPL5211Tri2110
/LAB 2.4.py
688
3.96875
4
# Student ID : 1201201544 # Student Name : LIM FANG YONG BANANA = 1.5 GRAPES = 5.6 print("Invoice for fruits Purchase") print("---------------------------------") banana = int(input("Enter the quantity (comb) of bananas bought : ")) grapes = float(input("Enter the amount (kg) of grapes bought : ")) bana...
4d29ae324cec62811f08964cf62f0d1b2af1e156
IamAamerAli/DataBaseConnectivity
/FirstProgram.py
1,467
3.625
4
import sqlite3 # Global Variable for Table Name to avoid mistakes in string TABLE_STORE = "tbl_store" COL_ITEM = "item" COL_QUNTITY = "quantity" COL_PRICE = "price" def create_table(): conn = sqlite3.connect("lite.db") cursor = conn.cursor() cursor.execute( "CREATE TABLE IF NOT EXISTS {} ({} TEXT...
cd11702159d48bb1c0c683544c7d8cd4416bbed3
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_2/itprov/pancakes.py
1,381
3.71875
4
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 import re happy_sides_first_pattern = re.compile(r"^(\++)-+") # Pancakes starting with 1 or more +'s followed by at least 1 - blank_sides_first_pattern = re.compile(r"^(-+)\++") # Pancakes starting with 1 or more -'s followed by at least 1 + t = int(inpu...
ec4a9c95aabd204c737f214a61e11ce8e4441aaa
Rakeshmr1995/completed_task
/python/python_functions_2/ReverseList.py
184
3.90625
4
list1 = [100, 200, 300, 400, 500] #list1 = list1[::-1] #print(list1) """def Reverse(list1): list1.reverse() return list1 print(Reverse(list1))""" list1.reverse() print(list1)
81c88b8e71cdc7f57da4970ba99d676f3836bb18
RichaPrajapati1/HW06
/HW06_ex09_02.py
988
4.125
4
#!/usr/bin/env python # HW06_ex09_02.py # (1) # Write a function called has_no_e that returns True if the given word doesn't # have the letter "e" in it. # - write has_no_e # (2) # Modify your program from 9.1 to print only the words that have no "e" and # compute the percentage of the words in the list have no "e."...
16ca117f07b6fb2576af2a4e74544ad64ce5c812
aliyevmirzakhan/ABBTech-SWE-T1
/problem1.py
495
3.734375
4
def carParkingRoof(cars, k): cars.sort() # print(cars) covers = [] for slice in range(0, len(cars)): covers.append(cars[slice: slice + k]) if len(cars[slice: slice + k]) == k else None differentials = [(cover[-1] - cover[0]) + 1 for cover in covers] print(f"[Roof Length Canditates]: {differentials}") retu...
8dab1cc403846956c1bf10383a64f27406cd2250
AnonymousRandomPerson/TreeSearch
/data.py
3,145
3.828125
4
# coding: utf-8 import csv pokemonFile = 'pokemonSS.csv' trainersFile = 'trainersSS.csv' class Data: """Stores data about Battle Tree Pokémon.""" def __init__(self): """Initializes the data storage.""" self.sets = {} with open(pokemonFile, 'r') as csvFile: pokemonReader ...
e473e8e278a9505f977dced813612e0186d4b32a
lucmichea/leetcode
/Challenge_April_30_days_leetcoding_challenge-/day01.py
1,042
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 1 14:51:20 2020 @author: Jinling Xing & Luc Michea """ ''' Problem : Given a non-empty array of integers, every element appears twice except for one. Find that single one. Example 1:S Input: [2,2,1] Output: 1 Example 2: Input: [4,1,...
f41202d29d4c5ef5978208749e483c15f65ffce5
QR10/PokemonChallenge
/pokemon.py
4,775
3.765625
4
def get_grid_size(ash_movement_sequence): """ Returns the maximum used X and Y axis sizes for a movement sequence as 2 integers. Expects: A string with a sequence of movements Modifies: Nothing Returns: Two integers, X-axis value and Y-axis value """ list_of_ash_movements = lis...
9f6f65f0881047b13f79b91028d23f90405d7f33
DawnEve/learngit
/Python3/pythonCodeGit/day6-OOP/op3_student.py
1,060
4.0625
4
#定义类 #class Student(object): #不写(object),直接(),也没有异常 class Student(): #不写(object),直接(),也没有异常 def __init__(self, name, score): self.name = name self.score = score #和普通的函数相比,在类中定义的函数只有一点不同,就是第一个参数永远是实例变量self,并且,调用时,不用传递该参数。 def print_score(self): print('%s: %s' % (self.name, self.score)) ...
57786ce68d50d8d8eb4339935865a62f22b7caef
Niranjan-10/DSA-Practice
/array/sub_array_with_0_sum.py
351
3.78125
4
def subArraaySum(arr): n_sum = 0 s = set() for i in arr: n_sum += i if n_sum == 0 or n_sum in s: return True s.add(n_sum) return False arr = [-3, 2, 3, 1, 6] n = len(arr) if subArraaySum(arr, n) == True: print("Found a sunbarray with 0 sum") else: pr...
34317985a0d4b16d93a8e4a7c6325dbeedf365c8
SoundNandu/Stack-1
/DialyTemperature.py
1,273
4.28125
4
Daily Temperatures Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the list of temperatures T = [73, 74, 75, 71, ...
30ade5d55a0168ee25b23da64f726bbb7d0bee07
porrametict/learningSpace
/PythonWithChulalondkorn/set_demo1.py
453
3.625
4
def demo(): skills = {"Python","C","JAVA"} print(skills) print(type(skills)) a = {} # dict b = set() # set print(type(a)) print(type(b)) xy = {(5,2),(5,5)} print(xy) # # demo() def basic_op(): a = {"mango", "banana", "coconut", "mango", "apple"} b = {"cherry", "mango", "app...
332f5cb57b123409ee56890fe44bc7bc7e9e3e88
polinavolos/programming_practice
/week02/hw1/task4.py
375
3.765625
4
def where_is_Vasya(speed, hours): if speed > 0: distance = (speed * hours) % 109 return distance v = int(input()) t = int(input()) vasyas_location = where_is_Vasya(v, t) print(vasyas_location) #я понимаю, что можно было в три строчки решить, но мне очень нравится составлять функции:)
598ff3f4b63a05ec01f9d45ed1923c32034ff371
YBrady/pands-project
/dataInNumbers.py
5,952
3.671875
4
# -------------------------------------------------------------- # Fischers Iris Dataset # # Written by Yvonne Brady # GMIT ID: G00376355 # # This python program looks after the data analysis / review # of the actual numbers. #--------------------------------------------------------------- # Import pandas library ...
da7ff972317c6ecbb86f34bb4d58ffb47e736e9e
pyav/labs
/src/python/class.py
397
3.578125
4
#!/usr/bin/env python3 ''' __author__ = pyav Output ------ first Inside class C, first ''' class A: def first(self): return "first" class B: def second(self): print(A().first()) B().second() class C(): def __init__(self): self.objA = A() def third(self): print('Ins...
3c105810de690287ed4bad50f8a6d655da43898f
npstar/HackBulgaria
/week0/1/biggest_difference.py
223
3.78125
4
def biggest_difference(arr): min = arr[0] max = arr[0] for i in arr: if i < min: min = i if i > max: max = i return min - max print(biggest_difference([-10, -9, -1]))
7888cc1754014efe56907fd6a9cb5d81ca78e302
PhebeJ/Knowledge-Engineering
/Sum first n num.py
152
3.890625
4
import sys n=int(input("Enter the limit:")) if(n < 0): print("Enter a positive number!") else: i=0 while (i < n): print("",i) i = i + 1
6303711f20643e40bdb08e370a826f827abe700e
youthpasses/leetcode_python
/001_TwoSum.py
1,001
3.875
4
# coding:utf-8 # @sinner # 16/6/4 ''' Total Accepted: 239594 Total Submissions: 1001231 Difficulty: Easy Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given nums = [2, 7, 11, 15], targ...
60f0fbdb28fe2716c9e79774e0c033ff6207b820
friedlich/python
/19年7月/7.15/实例063:画椭圆.py
398
4.03125
4
# 题目 画椭圆。 # 程序分析 使用 tkinter if __name__ == '__main__': import tkinter x = 360 y = 160 top = y - 30 bottom = y - 30 canvas = tkinter.Canvas(width=400,height=600,bg='white') for i in range(20): canvas.create_oval(250-top,250-bottom, 250+top,250+bottom) top-=5 bo...
b6037d21e5b6bea90bb12453f0d78fc053221028
padamcs36/Introduction_to_Python_By_Daniel
/Chapter 4 Selections/Ex_18_CurrencyExchangeUStoChineseViceVersa.py
755
4.09375
4
#Program to covert Chinese RMB into the US Dollar and vice Versa #When user enter 0 then covert dollar into the yuan #when user enter 1 then convert RMB into the dollar conversion = eval(input("Enter the exchange rate from dollars to RMB: ")) checkCondition = eval(input("Enter 0 to convert dollars to RMB and 1 ...
8d7d8e151df6bc6636dae8d669f627fe8b93624b
tomobones/hort
/Code_Kinder/antonio_01.py
214
3.671875
4
import turtle colors = ['red', 'blue'] t=turtle.Pen() turtle.bgcolor('black') for x in range(400): t.pencolor(colors[x%2]) t.width(x/100+1) t.forward(x) t.left(90) turtle.Screen().exitonclick()
82d3a6f1f904b5210d50779205639d0c77c3f55a
JWiryo/LearnAlgorithms
/MatrixTraversal.py
3,402
3.671875
4
class MatrixTraversal: # Up, Right, Down, Left directions = [[-1,0], \ [0,1], \ [1,0], \ [0,-1] ] # Udemy Implementation of BFS def arrBFS(self, matrix): rows = len(matrix) cols = len(matrix[0]) # Setup visited and result list ...
81d71a9e4215977acde658c90afc4ad529216dad
dorajam/Algorithms
/permutation.py
651
3.859375
4
# Dora Jambor, dorajambor@gmail.com # January 2016 ''' Implements a function that returns all permutations of string s ''' result = [] # check if string is already in the list def isIn(string1, string2): if string1 in string2: return True return False def permutation(s): global result if len...
c81e61375b4a9a184137de5711a17dd649e519dc
H9574/python_test
/ProblemSolving.py
3,345
4.1875
4
#Räisänen Sanna 2.12.2016 klo 13:03 # Problem solving # Create a function that solves the most suitable (with most power) link station # for a device at given point [x,y]. Use any programming language of your choice. # # This problem can be solved in 2-dimensional space. Link stations have reach # and power. #...
8f8db0fbe948c83e8b1167108ae33492e55e601a
yeml1/test
/day01.py
638
4.15625
4
# print 'helle word!!' # print 输出 print('hello word!!!') # 定义变量--python中直接定义,不需要表明是什么类型 # 定义变量:见名知意,尽量不要中文 name = 'yeml' age ='26' #字符串里面有单引号,则外面的用双引号 new_name1 ="let's go " #字符串里面有双引号,则外面的用单引号 new_name2 ='小白,"好帅 "' #字符串里面有双引号和单因哈,则外面的用三单引号 new_name3 =''''小白,"好帅",let's go ''' # 多行注释功能''' ''' ''' sdfsdfs erwerwer dsfsd...
0c945a3b034eb4d53b26d500ab152c962684d919
abhinav318/Python-ProjectX
/EDX/Intro to python/Classes.py
24,967
4.03125
4
############################################################################################################# # 5.1.8 # Write a class called "Burrito". A Burrito should have the # following attributes (instance variables): # # - meat # - to_go # - rice # - beans # - extra_meat (default: False) # - guacamole (default:...
81f23f2664a5deddc6c5ad3b2fa1b4c1821308e8
kinzakasher/code-literacy
/Week2/story-sample.py
1,673
4.34375
4
# let the user know what's going on print ("A Trip To The Beach!") print ("Answer the questions below to play.") print ("-----------------------------------") # variables containing all of your story info name1 = raw_input("Enter your name: ") name2 = raw_input("Enter your friend's name: ") adjective1 = raw_input("Ent...
35fdca75d02c9fdf8e26751a1364599a88c700ff
muratcavus/anagrams
/anagram_process.py
1,576
4.0625
4
def get_word_list_from_file(): input_file = open('sample.txt', 'r') word_list = input_file.read().splitlines() input_file.close() return word_list def is_anagram(len_of_word1, sorted_word1, word2): return len_of_word1 == len(word2) and sorted_word1 == sorted(word2) def end_of(word_list): re...
1e515107948be336a0332085be6629fcd672403a
LogankumarR/Logankumar
/OOPS/matrix.py
578
3.609375
4
class matrix(): def __init__(self,row,col): self.row = m1 self.col = l1 self.matrix = [] def buildmatrix(self): for col_idx in range(0,self.col): temp_row = [] for row_idx in range (0,self.row): ele = eval(input("enter a number in matrix ...
0689eabb1ac0a00025ad1c4071e34db8c1295109
MrHamdulay/csc3-capstone
/examples/data/Assignment_4/dsrkir001/boxes.py
846
3.765625
4
def print_square(): for i in range(5): for j in range(5): if (i==0 or i==4 or j==0 or j==4): print("*",end='') else: print(" ",end='') print() def print_rectangle(wide,height): for i in range(height): for j in range(...
79c5cde4d08b3daf27e7e29b02150f828d07da9e
ayeshamujtaba/ICTPRG-Python
/stringwithinnotin.py
415
3.953125
4
string1 = 'one two three four five' if 'four' in string1: print("Found" + " four" + " in " + string1) else: print("The string four was not found") print() s1 = "123" #Is it a digit print(s1.isdigit()) #Is it a alpha numeric print (s1.isalnum()) #Does it have space print (s1.isspace()) #Is it uppe...
91779ce7a83aae2f4da7e70bd6efbca664dd5833
cmh1027/jugallersimulation
/matgoscore.py
2,189
4.09375
4
""" Calculate the player and computer's Score. And also when the game ends, it calcuates magnification """ # Calculate the player and computer's Score. And also when the game ends, it calcuates magnification class Score: def __init__(self, obj): self.__obj=obj def result(self): score=0 if len(self.__obj.godori...
d524f0efa90923ab587e554bfec88e5cbb2e4733
daedalus/math
/sqrttest.py
831
4.03125
4
#!/usr/bin/env python # # Author Dario Clavijo 2015 # GPLv3 # implementation acording to whikipedia: https://es.wikipedia.org/wiki/C%C3%A1lculo_de_la_ra%C3%ADz_cuadrada def sqrt(x): r = x t = 0 while t != r: t = r r = 0.5 * (x / r + r) return r # given the x**2-2=0 condition we brut...
95366c674ffe0a032a7c947d4c4f59b11a8d883f
vitorsergiota/Python
/ex7.py
123
3.921875
4
# Nome e apelido nome = str(input("Coloque seu nome: ")) apel = str(input("Coloque seu apelido ")) print (nome ,",", apel)
790958df3834bbd45218d3a8fa0f8ea633c3be0a
ZhangJiaQ/everything
/Python/Algorithm/LintCode/32. Minimum Window Substring.py
1,942
3.890625
4
""" 32. 最小子串覆盖 中文English 给定一个字符串source和一个目标字符串target,在字符串source中找到包括所有目标字符串字母的最短子串。 Example 例1: 输入: "" "" 输出: "" 例2: 输入: "ADOBECODEBANC" "ABC" 输出: "BANC" Challenge 要求时间复杂度为O(n) Clarification 在答案的子串中的字母在目标字符串中是否需要具有相同的顺序? ——不需要。 Noti """ class Solution: """ @param source : A string @param target: A s...
fa213d63095ea5678d591b3a5974bcd79321af37
seema-sathyanarayana/Machine-Learning-Projects
/Lead_Scoring/Lead_Scoring_Case_Study.py
30,176
3.984375
4
#!/usr/bin/env python # coding: utf-8 # # Lead Scoring Case Study # ### Submitted By - Seema S B # Problem Statement: # 1. To build a model to find out the leads that are most likely to convert into paying customers. # 2. To find the conversion rate of customers based on scoring of the leads. # Solution Approach: #...
7f612182ffb946c0ba196a5b71394e0d44d4d37c
blhwong/algos_py
/grokking_dp/unbounded_knapsack/minimum_coin_change/main.py
1,240
4
4
""" Introduction Given an infinite supply of ‘n’ coin denominations and a total money amount, we are asked to find the minimum number of coins needed to make up that amount. Example 1: Denominations: {1,2,3} Total amount: 5 Output: 2 Explanation: We need a minimum of two coins {2,3} to make a total of '5' Example 2: ...
9606f47a5a851699269c6b07e423cf97e736856b
yinhuax/leet_code
/datastructure/trie_tree/ReplaceWords.py
3,106
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Mike # @Contact : 597290963@qq.com # @Time : 2021/2/12 13:40 # @File : ReplaceWords.py from typing import List """ 在英语中,我们有一个叫做 词根(root)的概念,它可以跟着其他一些词组成另一个较长的单词——我们称这个词为 继承词(successor)。例如,词根an,跟随着单词 other(其他),可以形成新的单词 another(另一个)。 现在,给定一个由许多词根组成的词典和一个句...
63aa7376b684f17444a69772845c9e26677205e1
vijaykm2/Tic-Tac-Toe
/Problems/Cat cafés/main.py
315
3.984375
4
inpt = "" catCafes = [] while inpt != "MEOW": inpt = input() if inpt != "MEOW": catCafes.append(inpt) largest = '' largestNum = -1 for cafe in catCafes: cafeNum = int(cafe.split()[1]) if(cafeNum > largestNum): largest = cafe.split()[0] largestNum = cafeNum print(largest)
79842a6278b9deddbbe9dcdd9efac467ff6cd753
msadoghi/165a-winter-2021
/template/index.py
974
3.96875
4
""" A data strucutre holding indices for various columns of a table. Key column should be indexd by default, other columns can be indexed through this object. Indices are usually B-Trees, but other data structures can be used as well. """ class Index: def __init__(self, table): # One index for each table....
2f31599a28c3bab0a12b3ab603c8e1fdd088747a
zhangbiqiong/hello-world
/d.py
610
3.625
4
# python notebook for Make Your Own Neural Network # working with the MNIST data set # # (c) Tariq Rashid, 2016 # license is GPLv2 import numpy import matplotlib.pyplot data_file = open("mnist_train_100.csv", 'r') data_list = data_file.readlines() data_file.close() print (len(data_list)) print (data_list[1]) # ta...
9e9ef72b4d4e394fba2a6090cae7e1fcceeefe49
Selshy/Selshy
/NewPythonProject2/src/Kattis/Speedlimit.py
259
3.515625
4
for _ in range (10): n = int(input()) if n == -1: break result = 0 c = 0 for _ in range(n): a, b = input().split() a = int(a) b = int(b) result += (a * (b-c)) c = b print(result, "miles")
ad3ee3f326184e57e4a70c7283170f7675693d36
skshahriarahmedraka/DataStructurePractice-Python
/DFS.py
3,489
3.921875
4
class node: def __init__(self,data): self.visit=True self.parentnode=None self.nodedata=data self.leftnode=None self.rightnode=None class binarytree: def __init__(self): self.root=None def insert(self,data,extranode=None): if extranode is No...
9480a5c0f2878843bb6111a09339bebf302127cd
gusar/advsec
/caesar.py
2,071
3.59375
4
def caesar(s, k, decrypt_flag=False): if decrypt_flag: k = 26 - k r = "" for i in s: if 65 <= ord(i) <= 90: r += chr((ord(i) - 65 + k) % 26 + 65) elif 97 <= ord(i) <= 122: r += chr((ord(i) - 97 + k) % 26 + 97) else: r += i re...
2f4200453a55ec87867427345327c7a217879bb3
tigerhub/Event-Simulator-Python
/code/System1.py
11,413
3.578125
4
from SimPy.Simulation import * from numpy.random import seed, uniform, exponential, poisson import numpy as np import random import argparse import matplotlib.pyplot as plt from itertools import chain # First Name: Dan # Last Name: Brown # BU ID: U63795118 #You can add any extra helper methods to thes...