blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2c3c3570f0db743116c5038b98c522a91bd5b466
nishantranaa/Python_Uni_Projects
/Prac_3/word_generator.py
561
4.03125
4
# # #Random word generator - based on format of words # # #Another way to get just consonants would be to use string.ascii_lowercase # #(all letters) and remove the vowels. # # import random # # VOWELS = "aeiou" # CONSONANTS = "bcdfghjklmnpqrstvwxyz" # # word_format = "ccvcvvc" # word = "" # for kind in word_format: # ...
7fc366c7e1b00ff616988c4423818785218782ac
kbase/execution_engine2
/lib/execution_engine2/authorization/basestrategy.py
1,555
3.59375
4
import abc from typing import List, Dict WS_AUTH_STRAT = "kbaseworkspace" class AuthStrategy(abc.ABC): """ An AuthStrategy is a class that determines how to judge whether a user has access to view/write to a job. Note that this is intended only for users - admins can do most things with jobs and don...
93346dd860dc657241d57a2bf0710729592fe41e
KylerAKA/LinearSystems
/matrix.py
1,435
3.953125
4
#!/usr/bin/python3 class Matrix(object): def __init__(self,initial_matrix): m = max([len(row) for row in initial_matrix]) if any([len(row)!=m for row in initial_matrix]): raise ValueError("Not a valid matrix") self.num_cols = m self.num_rows = len(initial_matrix) self.matrix = {} for row in ...
9b76abf45febf74e1886e31c6bf76230e39ab707
allenanswerzq/baskets
/baskets/csv_utils.py
1,698
4.0625
4
"""Utilities for reading and writing CSV files. """ __copyright__ = "Copyright (C) 2018 Martin Blais" __license__ = "GNU GPLv2" def csv_split_sections(rows): """Given rows, split them in at empty lines. This is useful for structured CSV files with multiple sections. Args: rows: A list of rows, whi...
f7176ef3df20edf569a839d95e20dadec35c8753
mangeshii/A-GUI-Calculator-Using-Tkinter
/calculator.py
4,753
4.1875
4
import tkinter as tk from tkinter import * import math root = tk.Tk() root.title('Simple Calculator') e = tk.Entry(root, width=30, borderwidth=3) e.grid(row=0, column=0, columnspan=3, padx=10, pady=10) def button_click(number): current = e.get() e.delete(0, END) e.insert(0, str(current) + str(number)) ...
6d43116542b674341fb27766993960279c0bcf40
kyj0701/my1-1
/Find2.py
688
3.703125
4
def __print_result(): import os os.system('cat result.txt') def find_all_count(filename,key): infile = open("article.txt", "r") outfile = open("result.txt", "w") text = infile.read() pos = text.find(key) count = 0 if pos == -1: outfile.write(key + " is not found.\n") count = 0 outfile.write(str(count)) ...
2cbe7da38f1a98673c7d484da4c467298fbb2635
czx94/Algorithms-Collection
/Python/JianzhiOffer/question24_1.py
849
3.84375
4
''' Reverse linkedlist leetcode 206 leetcode 92 leetcode 25 ''' import copy # stupid def solution1(head): if not head: return head temp = [] pointer1 = copy.copy(head) while pointer1: temp.append(pointer1.val) pointer1 = pointer1.next head.val = temp.pop() pointer2 = ...
418fb2602dabccb3f77a5caa8c6e09cceb471141
Leesyuwei/Singular_Practice
/python/pycode/BMIcaculator0816.py
212
3.8125
4
height=float(input('height(m):')) wieght=float(input('wieght(kg):')) BMI=float(wieght/(height**2)) print('BMI=',BMI) if BMI <= 18.5: print('light') elif BMI >= 24: print('heavy') else: print('normal')
3b2679dffdceffebe1227177c21976074c4da12e
Vipheak/Reprogramando
/Jesus_Alberto_Castro_Carcano/Hambre.py
320
3.796875
4
heDesayunado = True; heAlmorzado = False; heComido = True; if heDesayunado and heAlmorzado and heComido: print("No tengo hambre"); elif (heDesayunado and heAlmorzado) or (heAlmorzado and heComido): print("Tengo poca hambre"); elif heDesayunado and heComido: print("Tengo mucha hambre"); else: print("Muero de hambre");
f8fb5bd87fb2e7ae07ca0505a1d319bf0ae73237
tayyabmalik4/pandas_in_python
/13_Interpolate_pandas_practical_12.py
1,960
3.890625
4
# *********************************Interpolate function using pandas using pythom*********************** # //////////Interpolate is very powerful function. # Basically Interpolate is use to fill the data by guassing the previous or next data # -------------discuss about-----------------(method,axis,limit,inplace,limit...
d36c0dfceb5f41511ce0ff285a461d067ea2c122
agusth24/fga-digitalent-bigdata
/sesi 11/contoh 5.py
639
3.5625
4
# -*- coding: utf-8 -*- """ Created on Wed Jul 17 10:27:26 2019 @author: ROG-GL553VD """ from urllib.request import urlopen from bs4 import BeautifulSoup # fetch html file response = urlopen("https://www.tutorialspoint.com/python/python_overview.htm") html_doc = response.read() # parse the html file soup = Beautifu...
c385878f616382a38828c0749b8cc62d932e09c0
freebz/Learning-Python
/ch07/ex7-14.py
540
3.71875
4
# 다른 문자열 메서드 line = "The knights who say Ni!\n" line.rstrip() # 'The knights who say Ni!' line.upper() # 'THE KNIGHTS WHO SAY NI!\n' line.isalpha() # False line.endswith('Ni!\n') # True line.startswith('The') # True line # 'The knights who say Ni!\n' line.find('Ni') != -1 # 메서드 호출이나 표현식을 통한 검색 # True 'Ni'...
dbcdddf25c524980e97c42f32a73a0477660b06c
gorigo/Programaci-n
/Práctica 5/ejercicio 6.py
1,097
4.1875
4
"""Sergio Rigo Garca - DAW1 - PRCTICA 5 - EJERCICIO 6: Escriu un programa que demani primer dos nombres (mxim i mnim) i que desprs te demani 2 nombres situats entre ells. Per a terminar d'escriure nombres, escriu un nombre que no sigui comprs entre els dos valors inicials. El programa termina escribint la llista de n...
964f730e8933fe27ef761d2fd3d6d5900c2d1f7a
turikino/lesson2
/lesson2_exception1.py
764
3.609375
4
answers = { "Как дела?": "Хорошо", "Что делаешь?" : "Программирую", "Какие новости?": "Да ничего особенного", "Яйцо или курица?" : "В этом году ты точно знаешь!" } def ask_user(dct): try: while True: user_say = input("Пользователь: \n") ...
d24b43c5ad70c7d7f8d45f07cd72d62ae37c4d38
RafaelGoncalves8/MIT_6.00sc_problem_sets
/ps06/ps6.py
11,576
3.984375
4
# Problem Set 6: Simulating robots # Name: # Collaborators: # Time: 15:23 - 20:29 (~5h) import math import random import ps6_visualize import pylab # === Provided classes class Position(object): """ A Position represents a location in a two-dimensional room. """ def __init__(self, x, y): """...
e0713c0a5aa8f2379207aa84ba0d0b7f98b9824e
Jadams29/Coding_Problems
/Regular_Expressions/More_Adv_RegEX/RegEx_Advanced_WordBoundaries.py
356
3.53125
4
import re randStr = "ape at the apex" # No boundary # This will return ape from randStr as well as 'ape' from 'apex' regex = re.compile(r"ape") matches = re.findall(regex,randStr) for i in matches: print(i) print() # Boundary regex_Bound = re.compile(r"\bape\b") matches_Bound = re.findall(regex_Bound, randStr) ...
797ef8d41a181c1310fc31ed335917a46d8a6a58
shubhamyedage/pycharm-codebase
/Test/apps/test_inheritance/test_1.py
558
3.953125
4
class FemaleGrandParent: def __init__(self): self.grandma_name = "Grandma" class MaleGrandParent: def __init__(self, grandpa): self.grandpa_name = grandpa class Parent(MaleGrandParent, FemaleGrandParent): def __init__(self, grandpa): MaleGrandParent.__init__(self, grandpa) ...
24d2cb81e8397c9710dc28ee9a2beb3b65a41d38
michellezzz/Leetcode_Python
/049_Anagrams.py
1,149
3.546875
4
class Solution: # @param {string[]} strs # @return {string[]} def anagrams(self, strs): # its better to get pattern by just sorting the word pattern_dict = {} for word in strs: letter_dict = {} for letter in word: if letter in letter_dict: ...
fc61c786b68fb7e5e48c90d180b52b65b24ce27c
cstarcher/collection-processing
/lab_make_directories_1.1.py
1,864
3.890625
4
#!/usr/bin/env python3 """ Create a directory structure for new or existing collections. Create a new directory structure based on the following structure: collection_folder item_folder content archive display raw The collection_folder should ...
d4a13b477e72baf0a3ca0bdfc25276e8b46572a1
melissafear/CodingNomads_Labs_Onsite
/week_01/04_strings/07_caesar_cypher.py
1,640
4.40625
4
# A Caesar cypher is a weak form of encryption that involves “rotating” # each letter by a fixed number of places. To rotate a letter means to # shift it through the alphabet, wrapping around to the beginning if # necessary, so ’A’ rotated by 3 is ’D’ and ’Z’ rotated by 1 is ’A’. # # To rotate a word, rotate each lett...
c2f2be25bbbb2dda86f0cea9b8b07c532638aba6
darshanbangera/aps-2020
/Code Library/euclids_gcd.py
88
3.703125
4
a = 84 b = 72 def gcd(a,b): if b == 0: return a return gcd(b,a%b) print(gcd(a,b))
2accb9cf4132e936ebc8ba1d7c51dca88a49cec3
spongebob03/Playground
/baekjoon/Bronze/baekjoon01.py
216
3.6875
4
#백준에서는 한줄에 두 수를 입력받기때문에 #파이썬에서는 문자열로 받은 두 수를 나눠서 저장 num=input() num_split=num.split() a=int(num_split[0]) b=int(num_split[1]) print(a/b)
9611d0b89d91166cdb607f6692de77cc2d44a2ae
RolfHaakon/PythonExercises
/Exercises/SimpleNeuralNetwork.py
1,150
4.21875
4
""" https://www.kode24.no/guider/the-best-way-to-learn-deep-learning/71003527 Simple neural network """ def simple_neural_netowrk(input, weight, goal_prediction, train): for i in range(train): prediction = input * weight """ Squared root error is used to always get a positive number to ...
e78c7f037b1860e607dc3c08dbf037f56b2f664e
yhu9/TrashClassification_capstone
/source/cnn3/test2.py
482
3.515625
4
import os from multiprocessing import Process from multiprocessing import Pool nums = [] def doubler(number): """ A doubling function that can be used by a process """ result = number * 2 proc = os.getpid() print('{0} doubled to {1} by process id: {2}'.format( number, result, proc)) ...
c1c5b79e82071d5bc185ec9f13bb0fb5ecd6e00c
milenafbn/python.Exercises
/ex027.py
153
3.78125
4
name = str(input('Digite seu nome completo: ')) n = name.split() print('seu primeiro nome é: ', n[0]) print('Seu último nome é: ', n[len(n)-1])
3ba42f477fc29dcae4408aa4aa47fa378020739b
monkrobot/Indicator_of_Scientific_Performance_Compiler
/functions/score_calc.py
322
3.5
4
#import #max_score = 30 #coauthors = [] #while True: # author = input('coauthors ') # if author == '': # break # else: # coauthors.append(author) def score_calc(coauthors, max_score): return max_score / (len(coauthors)+1) if __name__ == '__main__': print(score_calc(coauthors,max_score)...
10a0887208403e08408f9d00a7b9f2cca4dd344c
rafaelgama/Curso_Python
/CursoEmVideo/Mundo3/Aulas/aula19a.py
1,130
4.46875
4
# Nessa aula, vamos aprender o que são DICIONÁRIOS e como utilizar dicionários em Python. # Os dicionários são variáveis compostas que permitem armazenar vários valores em uma mesma estrutura, acessíveis por chaves literais. print(f'{"Listas com dicionários":=^40}') bra = list() estado1 = {'uf':'Rio de Janeiro', 'sig...
425ca0d675e01f5ca63e72c8765d398c72cdd2bf
SiddharthLucky/Deep-Learning
/Volume 1 - Supervised Deep Learning/Part 2 - Convolutional Neural Networks (CNN)/Section 9 - Evaluating, Improving and Tuning the CNN/Tuning_Cnn.py
3,164
3.765625
4
# Convolutional Neural Network # Installing Theano # pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git # Installing Tensorflow # pip install tensorflow # Installing Keras # pip install --upgrade keras # Part 1 - Building the CNN import tensorflow # Importing the Keras libraries and packages f...
dd2e188117b208cde0f5436cd42fc16774215e01
Justinyu1618/python-bee
/medium/11.py
373
3.859375
4
''' Q11: Given two lists of integers a and b with equal length, create a list where each element is the sum of the respective elements of a and b. >>> f([1,2,3,4],[2,3,4,5]) [3, 5, 7, 9] >>> f([],[]) [] >>> f([385, 10, 234],[2, 87, 17]) [387, 97, 251] ''' def f(a, b): # Your Code Here! pass if __name__ ==...
74be9e5bfe66511500f665c9b5942e5f02620afa
HarshaaArunachalam/GUV
/code/207.py
84
3.546875
4
base,height=input().split() base=int(base) height=int(height) print(base*height//2)
cb00de580e2f740133934361c45881bd536f828c
wangdongfrank/LeetCode-python
/Search2DMatrix.py
539
3.625
4
class Solution: # @param matrix, a list of lists of integers # @param target, an integer # @return a boolean def searchMatrix(self, matrix, target): row = len(matrix) col = len(matrix[0]) if row<1 or col<1: return False i = 0 j = col-1 ...
f3ac0e6eec6d25bf040cda1b6f9ff0418cdceb2f
daniel-reich/ubiquitous-fiesta
/ojBNREQrg7EW9ZzYx_5.py
1,157
3.828125
4
def count_eatable_chocolates(tm, cost_one): def get_money(string): words = string.split() for word in words: if '$' in word: if '$' == word: return int(words[0]) tr = [] for item in word: try: tr.append(str(int(item.replace('$','')))) ...
b2a931c340522e0465bb4e0ed0255d05e82ee8bb
blauks/ntnu-2
/TDT4137 - Kognitive arkitekturer/exercises/4/a-og-b.py
7,219
3.515625
4
#!/usr/bin/python3 def perceptron(expectedIO, times=100): from random import random def step(val): return 1 if val >= 0 else 0 # Init weightCount = len(expectedIO[0][0]) weights = [random() - .5 for i in range(weightCount)] threshold = random() - .5 learning_rate = 0.1 epoch = 0 matches = 0 p...
39df9df3a97e0f7917bdfde2fbba5e7960d93d79
Caiofran/Curso-de-Python
/aula22/aula22.py
933
4
4
""" Lista em Python fatiamento append, insert, pop, del, clear, extend, + min, max range """ # 0 1 2 3 4 5 # lista = ['A', 'B', 'C', 'D', 'E', 10.5] # - 6 5 4 3 2 1 # lista[5] = 'Qualquer outra coisa' # print(lista[1:4]) # l1 = [1, 2, 3] # l2 = [4, 5, 6] ...
5e23d827c8ed24f785afeab30cffab42a9bf8de1
aanzum7/Python-For-access-Web-Data
/unicode.py
312
3.53125
4
#python3 all are unicode print(ord('D')) bangla= 'হরিনাছড়া সোয়াম্প ফরেস্ট | পাহাড়ের গহীনে নতুন জলাবন' print(type(bangla)) english='I am in' print(type(english)) #byteString byteStr= b'ab' print(type(byteStr))
94e4227259c2f6f5a1bce20dc14ae8f80eae06a8
pdhhiep/Computation_using_Python
/md/md.py
10,992
3.59375
4
#! /usr/bin/env python def md ( d_num = 3, p_num = 500, step_num = 500, dt = 0.1 ): #*****************************************************************************80 # ## MD is the main program for the molecular dynamics simulation. # # Discussion: # # MD implements a simple molecular dynamics simulation. # # T...
85906a53357ec0766465d7e6b8ecdc84eb38a47f
wijdanb/Python-scripts
/dictionaries.py
5,052
4.3125
4
#like a list, a dictionary is a collection of many values # but unlike list indexes, indexes for dictionaries can use many different data types not just integers #index for dictionaries are called keys and a key has an associated value. Its called key/value pair #index is typed with { } and accessed with [ ] myCat =...
60b2c60a1013dbf7c696714a8154ac6d7205e24d
CiaranGruber/CP1404practicals
/prac_03/password_check.py
708
4.28125
4
""" Ciaran """ MIN_LENGTH = 5 def main(): """Check password""" password = get_password() print_password(password) def print_password(password): """Print password""" for x in range(len(password)): print('*', end='') print() def get_password(): """Get the password""" passwor...
f849103e5107d14441e41af98f67d2c2dee9dea7
SharonLingqiongTan/pythonSkills
/threadLock.py
1,013
3.984375
4
import threading # lock doesn't allow one thread change a shared resource when other one is working on it def do_this(): # sth thread do global x, y, lock1, lock2 lock1.acquire() while x < 300: x += 1 print x # lock1.release() def do_after(): global x, y, lock1, lock2 lock2.acquire() x = 450 while x < ...
1d141d75deb282068cf36c9a8cd68a3b758bab81
liloganle/Reinforcement-Learning
/Chapter9/Figure9-1.py
4,958
3.53125
4
# -*- coding:utf-8 -*- import numpy as np from tqdm import tqdm import matplotlib.pyplot as plt class RandomWalk(object): def __init__(self, num_states=1000, groups=10, alpha=2e-5): self.num_states = num_states # the number of states self.groups = groups # the number...
a808988da5f0a4f17565c9cddc6f626bd7aba62a
yogalin910731/studytest
/linkedtable/linkedqueue.py
1,610
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/8/5 15:43 # @Author : fangbo class linkedNode: def __init__(self,value): self.val = value self.next = None class linkedqueue: def __init__(self): #用来记录队列头和尾 self.head = None self.tail = None ...
39bf28bbc67bc913160adfa358161050fb6e75cf
evilwire/PythonDataStructures
/sort/merge_sort.py
597
3.875
4
def merge( array_A, array_B ): merged_array = [] A_index = 0 B_index = 0 for i in xrange( len(array_A) + len(array_B) ): if array_A[ A_index ] >= array_B[ B_index ]: merged_array.append( array_A[ A_index ] ) A_index += 1 else merged_array.append( array_B[ B_index ] ) B_index += 1...
3975c2e46bfd09325edb9771384c3a1dff42c93e
KershawK5646/CSC-221
/Module_02/M2HW_56_KershawKyler.py
803
4.71875
5
""" Kyler Kershaw Define a function "rotate" that recieves three arguments and returns a tuple in which the first argument is at index 1, the second argument is at index 2, and the third argument is at index 0. Define variables a, b, and c containing "Doug", 22 and 1984. Then call the function three times. For each ...
dc52a532a9f09f7481fd1d9a7c5a56538f5c5658
shalinibhandari/lets_upgrade-assingments
/sum_of_entered_range.py
129
3.890625
4
num=int(input("Enter the range ")) sum=i=0 while(i<=num): sum+=i i=i+1 print(f"the sum of entered range is {sum}")
daf6ebbedec3d909cb62f994643fe2f9aa55eb74
rnikoopour/ProjectEuler
/Problem1.py
531
4.1875
4
def main(): starting_num = 1 ending_num = 1000 nums = range(starting_num, ending_num) multiples = [] for num in nums: if num not in multiples: if ((num % 3) == 0) or ((num % 5) == 0): multiples.append(num) print "Sum of all the multiples of 3 and 5 between " \ ...
5238640bc989d8a9ee37c910ea276d67e2a1b7e1
SmitPatel19/MIS3615-COURSE
/string_demo_2.py
2,930
4.15625
4
# built-in functions that take string(s) as parameters #print('John') #input('Please enter your name: ') #type('John') #len('John') #int('1') / float('1.23') / bool('John') team='New England Patriots' letter = team[1] print(letter) print(team[0]) #print(team[1.5]) #print(team[1.0]) print(len(team)) last = team[...
f758c7175b6f6b9798152c10ebe024b8e92db5fd
Wokiri/Desktop-Text-Editor-Using-PyQt
/newfrontier_text_editor.py
6,645
3.75
4
''' File Name: newfrontier_text_editor.py Author: wokirijoe@gmail.com Date: 13/05/2021 This python code creates a simple text editor with the ability to: 1. Open existing file for editing 2. Create a new file 3. Save an existing edited file 4. Save As functionality 5. Open the following file types:...
aa8b044d6468e5d98fb7f85d3dfba7c221383275
habereet/-100daysofcode-with-python-courseWork
/16-18/16/list_comprehensions_and_generators_part5.py
636
3.609375
4
from collections import Counter import calendar import itertools import random import re import string import timeit import requests from pprint import pprint as pp def leap_years_lst(n=1000000): leap_years = [] for year in range(1, n + 1): if calendar.isleap(year): leap_years.append(year) r...
6a8a3d2373b31beab4da309eac6322d1f56ea139
ajorve/pdxcodeguild
/warm-ups/close_but_far.py
776
3.765625
4
""" Close, but Far! Given three ints, a b c, return True if one of b or c is "close" (differing from a by at most 1), while the other is "far", differing from both other values by 2 or more. In: 1, 2, 10 => Out: True In: 1, 2, 3 => Out: True In: 4, 1, 3 => Out: True In: 4, 11, 34 => Out: False """ def...
2e8ffef9b028745ddea334da944e683a8efd8cf3
ValentynShvets/circle
/format.py
201
3.625
4
# str_1 = "{1} має {0} років".format("Valentyn", 15) # print(str_1) #print("%s має %i років" % ("Valentyn", 15)) name = "Valentyn" age=10 print(f"{name:<15} має {age:o} років")
2a10f644c96cce9458f06f76c8d4171177c53505
xiao-a-jian/python-study
/month01/day15/demo04.py
408
3.59375
4
class Wife: def __init__(self, age=0): self.age = age @property def age(self): return self.__age @age.setter def age(self, value): if 16 < value <= 30: self.__age = value else: # raise 抛出 raise Exception("我不要") # try 接收 try: ...
24b01a48379fa19b54a5329dd913adc1a1218912
Aditya-A-Pardeshi/Coding-Hands-On
/4 Python_Programs/Programs to demo python concepts/utility.py
260
3.515625
4
def addition(iValue1, iValue2): return iValue1 + iValue2 def substraction(iValue1, iValue2): return iValue1 - iValue2 def division(iValue1, iValue2): return iValue1 / iValue2 def multiplication(iValue1, iValue2): return iValue1 * iValue2
fe1eb08977fe26835a6b0da0aa7d34f591fe2736
here0009/LeetCode
/Python/MaximumSwap.py
3,806
3.90625
4
""" Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get. Example 1: Input: 2736 Output: 7236 Explanation: Swap the number 2 and the number 7. Example 2: Input: 9973 Output: 9973 Explanation: No swap. Note: The given numbe...
c4e78ff3b6e6ff31aa706344e74ed643d7bdbca2
TheFcat/LeetCode
/452. Minimum Number of Arrows to Burst Balloons.py
890
3.859375
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x, left=None, right=None): self.val = x self.left = left self.right = right class Solution: def lowestCommonAncestor(self, root: 'TreeNode', p, q): self.ans = None def dfs(node): if self....
50bf945f0caf3b1132dab3e5ee1da003d58dce8e
andresbernaciak/project_euler
/problem2.py
907
3.828125
4
#projecteuler.net # #problem2 #======== # #Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: # #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # #By considering the terms in the Fibonacci sequence whose values do not exceed four...
1b16d47a353cff43f95f175e3481b9da5f5fcdd7
ankitrev/Parking-Lot
/Models/ParkingLot.py
3,029
3.78125
4
import heapq class ParkingLot(): def __init__(self): ''' Contructor for parking lot ''' self.slot_vehicle_map = {} self.age_vehicle_map = {} self.age_slot_map = {} self.available_slots = [] def create_n_slots(self, number_of_slots): ''' This method will create the parking slots ''' for i in range(1...
242a14a45fbebe0010fc376bddecac875e41bd36
cah835/Intro-to-Programming-1284
/Program 8/lab8.py
4,572
4.0625
4
#Corey Henry & Geoffrey Sanchez #Date Assigned: 29Oct2014 # # #Course CSE 1284 Sec 02 #Date Due: 05Nov2014 #File name: lab8.py # #Program description - online department of gallery of arts that allows #you to search through peices of art. #de...
19e512238d22800a3e08f75888997c51dce0888e
chow-sys/yashu
/rem.py
117
3.75
4
l= ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow'] l= [x for (i,x) in enumerate(l) if i not in (0,4,5)] print(l)
09f52972d51df6162530adf947aa0efa3b6eb8f9
alextodireanu/candy_crush_sim
/candy_crush.py
1,807
4.125
4
# Candy Crush sim # There are a number of n colored balls on the screen; the colors are number coded. # A substring of at least 3 balls having the same color is called a sequence. # By shooting in a balls that’s part of a sequence, the whole sequence will be removed and # the right side of the string will shift to the ...
229b0fb033d8ddc0361eba5faa3f6e228c702c28
osamascience96/CS50
/Testing/Assert/assert.py
311
3.578125
4
def square(x): return x * x # These asserts line would return nothing, but if some line, where you are confident that # its going to have a specific behaviour and you assert it but do not get, it then # itll throw assertion error # Test No 1 assert square(10) == 100 # Test No 2 assert square(10) == 50
f6faa581730f274ae4c5e902a30c50ff1e67a6d7
Divine11/codeforces
/Page1_N_solved_descending/Taxi_158_B.py
1,820
3.5
4
# After the lessons n groups of schoolchildren went outside and decided to visit Polycarpus to celebrate his birthday. We know that the i-th group consists of si friends (1 ≤ si ≤ 4), and they want to go to Polycarpus together. They decided to get there by taxi. Each car can carry at most four passengers. What minimum ...
3c535e491d02b0c3d90bf3a31da602e34b678c02
whenjohn/IS211_Assignment5
/simulation.py
7,221
3.609375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """IS 211 - Assignment 5""" import csv import urllib2 import argparse import sys import logging import logging.handlers import queue import server import request def main(): """Main function that runs at start of program. Args: --file (url): command line...
0ada62e7767300f7ffd54332f02242631bbbd87a
gpldecha/cs-exercises
/python/algorithms/dynamic/hanoi_recursive.py
724
3.890625
4
def move_top(origin, destination): value = origin.pop() destination.append(value) def move(n, origin, destination, buffer): if n <= 0: return print('move1({},{},{},{})'.format(n-1, origin[0], buffer[0], destination[0])) move(n-1, origin, buffer, destination) move_top(origin, destination) p...
f038e60b5f2c1e43c1dcc2b01a3fe04cb5948b99
desophos/winning-the-ipd
/evolution.py
9,571
3.546875
4
''' Created on Mar 3, 2013 ''' from random import shuffle from itertools import islice from matplotlib import pyplot from collections import deque def evolution(populations, fn, individual_type, gen, args): # This function provides genetic algorithm functionality for multiple populations. # pop...
fb81eefb22eb853f27da35988a73c8d4c8d628d4
mikias21/Code-For-Algorithms-
/queue/queueExercise/queueExercise.py
4,387
3.9375
4
class CircularQueue(object): def __init__(self , limit=5): self.queue = [] self.front = None self.rear = None self.size = 0 self.limit = limit def getFront(self): if self.front is None: raise Exception("Queue is empty") return self.queue[self.front] def getRear(self): if self.rear i...
a4038a7a2a2c8415007fb7d675ee35ab5140b948
GitSeob/programmers
/all/kakao-2020-2nd/6.py
1,949
3.640625
4
res = [] def move(board, row, col, target=None): pos = [] if target == None: for r in range(row): if r != row and board[r][col] != 0: pos.append((r, col, 1)) # return r, col, 1 for c in range(col): if c != col and board[row][c] != 0: pos.append((row, c, 1)) # return row, c, 1 else: for r...
a708380b4bd0c4401e5939856caabc0054913e97
mida-hub/hobby
/practice/python/basic/061_070/065_merge_sort.py
1,083
3.875
4
def merge_sort(arr): if len(arr) > 1: res = [] mid = len(arr) // 2 L = arr[:mid] # [1, 2, 3, 4] => [1, 2] R = arr[mid:] # [1, 2, 3, 4] => [3, 4] print('-'*50) print(f'arr:{arr}') print(f'L:{L}') print(f'R:{R}') L = merge_sort(L) R = ...
5a4dbc23ebe27fa72dfd143597b07a809a1829f9
apabhishek178/website_work
/untitled/window.py
1,127
3.640625
4
from tkinter import * from tkinter import messagebox import tkinter class Login(Frame): def __init__(self,master): super().__init__(master) self.l1=Label(self,text="username") self.e1=Entry(self) self.l2=Label(self,text="password") self.e2=Entry(self,show="*") sel...
65fb9362c898a8e46c01bc394d1c3d2e93e0fe13
Chunzhen/leetcode_python
/problem_138.py
1,180
3.6875
4
#! /usr/bin/env python # -*- coding:utf-8 -*- class RandomListNode(object): def __init__(self,x): self.label=x self.next=None self.random=None class Solution(object): def copyRandomList(self,head): """ :type head: RandomListNode :rtype: RandomListNode """ current=head if not current: return Non...
d7ff8a93e519217286e9fc7d096237f2101d2485
nitsas/codejamsolutions
/Lawnmower/runme.py
1,859
3.734375
4
#!/usr/bin/env python3 """ Lawnmower problem for Google Code Jam 2013 Qualification Round Link to problem description: https://code.google.com/codejam/contest/2270488/dashboard#s=p1 Author: Chris Nitsas (nitsas) Language: Python 3(.3) Date: May, 2012 Usage: python3 runme.py input_file """ import sys #...
e73a9cae5c5a103f7e41fed8c82906b8ce8802d2
sergiomedeiros/python-senac
/Desafios/aula1_desafio1.py
130
3.734375
4
# imprima uma lista com numeros pares de 0 a 10 lista = list(range(100)) lista = [ i for i in lista if i % 2 == 0] print(lista)
7e149c816546500f56d333ebda817240c0326ff3
namratavalecha/Algorithms
/radix_sort.py
892
3.609375
4
def counting_sort(arr, exp1): n = len(arr) output = [0]*(n) count = [0]*(10) for i in range(0,n): index = (arr[i]//exp1) count[ (index)%10 ] += 1 for i in range(1,10): count[i] += count[i-1] i = n-1 while i>=0: index = (arr[i]//exp1) output[count[(index)%10]-1] = arr[i] count[(index)%10] -= 1 i -=...
dcc533578282c8abc3bd98fc75c0c9da4867e4d7
simiyub/python
/interview/practice/tests/linked_lists/TestRemoveDuplicates.py
879
3.609375
4
import unittest from interview.practice.code.Node import Node from interview.practice.code.linked_lists.RemoveDuplicates import remove class TestRemoveDuplicates(unittest.TestCase): def test_remove_duplicates(self): three = Node(3) four = Node(4) four2 = Node(4) four3 = Node(4) ...
b553ef957366e08f9013ccb2abe5f548798dbafe
laichao1995/learningpython
/026.AdvancedListLooping.py
1,476
4.28125
4
#!/usr/bin/python """Using the built-in methods to manipulate types. Joseph Kern """ # The importstatement is probably the most import[ant] staement that you can use # importing allows us to resue our code. Or, even better, use other peoples code. import string # import statements should be one to a line, and only im...
9b33a338846cd27f551a5335465a427d31eeaa40
mehulgoel873/Pacman
/node.py
8,040
4.1875
4
#Does all graph related work for A* and Dijkstra code import sys import copy class Node(object): def __init__(self, pos): self.pos = pos self.neighbours = [] def addNeighbour(self, n): self.neighbours.append(n) #print(f"Neighbours: {self.neighbours}") def __repr__(self): ...
9400f41c939f6987ccc41a3b402e0aa73956cb82
abhiranjan-singh/CodePY
/PatternRowCol.py
297
4
4
for row in range (1,5): for col in range(1,9): if (row==1 and col==4 or row==2 and col in range(3,6) or row==3 and col in range(2,7) or row==4 and col in range(1,8) or row==5 and col in range(0,9) ): print("*",end="") else: print("+",end="") print()
9be4c0cfe1528de5ee29c120480cb7e74ee1c110
jamestiotio/DW2020
/cohort/week6/cs1.py
142
3.921875
4
def reverse(string): new_string = "" for char in range(1, len(string) + 1): new_string += string[-char] return new_string
d840a6452f8a545024717c38360e3235faf089aa
AdityanJo/Leetcode
/problem_0172_factorial_trailing_zeros.py
569
3.5625
4
class Solution: # def fact(self,n): # if n==0: # return 1 # return n*self.fact(n-1) # def trailingZeroes(self, n: int) -> int: # factorial = self.fact(n) # factorial = str(factorial) # length = len(factorial) # i=length-1 # # print(factorial, f...
79d4132d395e752ee7a13e03a1e109263930b9d6
jdtully/coursera-python
/app.py
545
4
4
from taxes import taxes price = input("How Much is the item? ") try: price = float(price) except ValueError: print("I figured out how to trap for that :P") else: if price < 1.00: final_price = price else: county = input("What county are you in? ") county = county.lower() ...
31daf730de870196d7689fec21371c08370ef467
nayan2000/LeetCode_Solutions
/Random/1507_reformat_date.py
564
4.15625
4
''' This map of months vs MonthNumber is kept global as it would be accessed in every testcase. Also, zfill is a format function fills zeroes to make the length as argument ''' def zfill_implement(string, n): return ''.join(('0'*(n-len(string)),string)) months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "...
376b46211c6c6ff8016daa670b1d11d9696a3411
AG-kravtsov/rep_1
/how_y.py
1,770
3.59375
4
import datetime from dateutil.relativedelta import relativedelta from collections import namedtuple InnerBlock = namedtuple('Дата', 'год, месяц, день') class Employee: def __init__(self): self.date_today = datetime.datetime.today().date() self.date_new_post = None def set_date(self, date)...
13a71058c7728f15cecee7a50c88c4f35f3745bf
joshuap233/algorithms
/leetcode/problems/59.py
1,066
3.640625
4
# https://leetcode-cn.com/problems/spiral-matrix-ii/ # 59. 螺旋矩阵 II from typing import List class Solution: """ 设置 left, right, top, bottom 四个边界 和螺旋矩阵 I 一个方法, 不过需要首先初始化一个数组然后填数 """ def generateMatrix(self, n: int) -> List[List[int]]: ret = [[0] * n for _ in range(n)] left, ...
de99b7ccc7e4d04665e4f6bd58a46866c6fc5c5d
mhetrerajat/ds-challenge
/leetcode/neetcode-py/238_product_arr_no_self.py
1,600
3.53125
4
# https://leetcode.com/problems/product-of-array-except-self/ # 238. Product of Array Except Self # Neetcode - 6 """ NOTE - an algorithm that runs in O(n) time and without using the division operation. - solve the problem in O(1) extra space complexity """ from typing import List def productExceptSelf(nums: List[in...
f62d8dddb03fb3520c90ba162cb100fc4efd5ffe
HeydarO/Python-Crash-Course-
/Chapter3_Introducing Lists/exercise_seeing_the_world.py
563
3.5625
4
travel = ['Dubai','Brussel','Copenhagen','Barcelona'] print("\nOriginal List:") print(travel) print("\nSorted the List Temporarily:") print(sorted(travel)) print("\nOriginal List Again:") print(travel) print("\nSorted the List in reverse Temporarily:") print(sorted(travel, reverse=True)) print("\nOriginal List Agai...
6e58b4c613c7ca44e502ed3ebf226f94604e727c
lakshadvani/Project_Euler
/Q1.py
349
4.125
4
''' If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. 233168 ''' x = 0 i = 1 while i<1000: if (i%3==0) or (i%5==0): x = i + x print(x) i = i+1 els...
996807f75d23f1469220fb6aa81571ba5d7d0f2e
liuyaanng/Data_struct
/Self_data_struct_2.py
3,784
3.9375
4
#!/usr/bin/env python # _*_coding:utf-8 _*_ # @Time    :19-5-24 上午11:45 # @Author  : liuyaanng # @FileName: Self_data_struct_2.py # @Software: PyCharm Community Edition # 链表(双向链表) class Node(object): def __init__(self, item): self.item = item self.next = None self.prev = None class DLinkList(object): # 双向链...
85190da81da259e6ff035e0fadc631307eb4120c
Dis-count/Python_practice
/MyGame/roll_dice.py
1,450
4
4
import random def roll_dice(numbers = 3,points = None): print('----- 摇骰子 -----') if points is None: points = [] while numbers > 0: point = random.randrange(1,7) points.append(point) numbers = numbers - 1 return points def roll_result(total): isBig = 11 <= total <=1...
f7077bd5f83a0e56b3720733a5174cf4eed894d6
Catherinesjkim/Intro-Python-I
/src/01_bignum.py
510
3.78125
4
# Print out 2 to the 65536 power # (try doing the same thing in the JS console and see what it outputs) # console.log(Math.pow(2, 65536)); --> Infinity # console.log(Math.pow(3, 1000)); --> Infinity # a value that is about 1.79e+308 or 2¹⁰²⁴— the largest value that can be stored as a number primitive type in JavaScrip...
6e113479bcc387ee3fbdd6b05b9464a31bf3c654
JCgithubaccount/590-jc3155
/HW1.1/LectureCodes/D1.1.2-SciPy-SINGLE-VARIABLE-OPTIMIZER.py
1,095
3.6875
4
# #-------------------------------- # #OPTIMZE A FUNCTION USING SCIPY # #-------------------------------- import numpy as np import matplotlib import matplotlib.pyplot as plt from scipy.optimize import minimize # ax.plot(xe, ye, '-', label='Ground-Truth') # ax.plot(xe, model(xe, popt), 'r-', label="Model") #FUN...
81a74e4efa6f5ba1701186a386fd9287bff4f46b
wangfuli217/ld_note
/cheatsheet/编程笔记/07.Python/1.基础/5.5.functools.py
6,572
4.3125
4
functools提供了一些非常有用的高阶函数。# 函数操作工具 高阶函数就是说一个可以接受函数作为参数或者以函数作为返回值的函数,因为Python中函数也是对象, 因此很容易支持这样的函数式特性. 1. partial >>> from functools import partial >>> basetwo = partial(int, base=2) >>> basetwo('10010') 18 basetwo('10010')实际上等价于调用int('10010', base=2),当函数的参数个数太多的时候,可以通过使用 functools.partial来创建一个新的函数来简化逻辑从而增强代码的可读性,而p...
fe364c0c9097400d131e7730e7704856addd59f1
Dinoryong/algo-dinner
/SEASON_1/leetcode/Find First and Last Position of Element in Sorted Array/Find First and Last Position of Element in Sorted Array.py
1,363
3.609375
4
""" Array Binary Search sol.1 brute force -> complexity issue (문제 볼 때, 항상 먼저 complexity 먼저 확인하자) sol.2 binary search 1. begin, mid, end 설정 2. binary search 하면서 버리고 , mid로 begin과 end 옮기기 3. begin >= end 까지 반복 python : bisect """ # class Solution: # 이 부분을 새로 만들음, self 해서는 처음 풀었다, def searchRange(self, nums: Li...
96bb54fda6d30ca6f99a5f47bafe00d5e7bc1b20
LCuretti/ML-Course-Exercises
/ex1/ML-Exercise-01-optional.py
7,051
3.5625
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 20 12:10:21 2019 @author: LCuretti """ import numpy as np from numpy import loadtxt import matplotlib.pyplot as plt ''' ########################################################################### ############### Optional Exercises: ########################...
86eb000417182f3636f8ef370c395d737a2c5576
rodrigogazevedo/treinamento_cesar
/EstruturaSequecial/CalculateAreaSquare.py
220
3.96875
4
side = float(input("Digite o lado do quadrado: ")) squareArea = side ** 2 doubleSquareArea = squareArea * 2 print(f"A área do quadrado é {squareArea}") print(f"O dobro da área desse quadrado é: {doubleSquareArea}")
db05800e320cb2384f008f0920ad22f86ad07c09
BackupTheBerlios/ufsi-svn
/trunk/ufsi/src/ufsi/FtpFile.py
4,904
3.59375
4
""" An FTP implementation of ``ufsi.FileInterface``. """ import ufsi import FtpUtils import ftplib class FtpFile(ufsi.FileInterface): """ """ def __init__(self,path): """ Creates an FtpFile object for the path. Preconditions: * The path actually exists and is a file....
4a8921c76d02468fd1607e199c17e2956975fa04
foxmichellem/Project-Euler
/pe12.py
641
4.09375
4
def find_triangular_num_divisors(number_of_divsors): #start with 0 n = 2 #start divisors at 0 divisors = 1 #run the loop until a number with parameter number of divisors is found while divisors < number_of_divsors - 1: #reset the divisors to 0 #find the triangular number tri_num = (n * (n + 1)/2) #we will...
46f605be49a450d0cc5c9213db02aeefd74506f2
bhanugudheniya/Python-Program-Directory
/pattern.py
405
4.1875
4
rows = int(input("Enter Row nos. : ")) for i in range(rows): for j in range(rows): if i == 0 or i == rows - 1 or j == 0 or j == rows - 1: print('* ', end='') else: print('$ ', end='') print() # i == 0 : means first row # i == rows - 1 : means first element in blank row ...
3d37f8aa63b72924d4f77195e2500aba10e4d27f
LSDtopotools/lsdtopytools
/lsdtopytools/examples/plot_basic_topo_maps.py
2,819
3.78125
4
""" This example script download a test raster, and plot different first order figure, for example nice topographic map. Read the comments to understand each steps. Copy and adapt this script to learn. If any questions: b.gailleton@sms.ed.ac.uk B.G. """ # If you are facing a common matplotlib issue, uncomment that: ###...
04a23c0f6a123b63faece86524690e877e3e86b1
daniel-reich/ubiquitous-fiesta
/HBuWYyh5YCmDKF4uH_23.py
1,309
3.890625
4
def almost_sorted(num_list): out_cast = [] desc = [] asc = [] order = 0 for number in range(0,len(num_list)): if number == 0: continue if number > 0: if num_list[number] - num_list[number-1] > 0: asc.append(number) if num_list...
1c045a98abb170d88d6cb8fdfefe78baace1b87e
mbrummelhuis/OperationsOptimisation
/datageneration_new.py
2,620
3.921875
4
""" Data generation algorithm for AE4441-16 Operations Optimisation assignment Generating random input data for the optimisation algorithm Creates a .csv file in the file directory with the specified number of data points The user inputs to this are: Amount of data points The flight frequency in average flight...
a5b751f623cf4f1c64173b0953a899b9caa81bd3
rohitravishankar/Year-1
/CSCI-720/HW06_Ravishankar_Rohit/HW06_Ravishankar_Rohit.py
6,475
3.578125
4
__author__ = "Rohit Ravishankar" __email__ = "rr9105@rit.edu" import math import pandas as pd import seaborn from scipy.cluster import hierarchy from matplotlib import pyplot as plt def read_input(file_name): """ To read the input file and store it in a pandas dataframe :param file_name: Input file :...