blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
b4264a48c54c4383d340f82a8d66d4a1e6157d36
mwnickerson/python-crash-course
/chapter_11/language_survey.py
589
3.984375
4
# Language survey # Chapter 11: Testing a class # The program for the function from survey import AnonymousSurvey # Define a question and make a survey question = "What language did you first learn to speak?" my_survey = AnonymousSurvey(question) # Show the question and store the responses to the question my_survey....
01aba01399a6548bc4035f1fe6f4baf9c5a379d4
azkanab/Convex-Hull
/quickhull.py
5,783
3.859375
4
#QUICKHULL.PY #by AZKANAB 16013 #Membentuk garis pada titik - titik terluar dari titik - titik yang sudah ada import random import math import matplotlib.pyplot as plt print() print(">>> __ __ __ __ __ <<<") print(">>> .-----.--.--.|__|.----.| |--.______| |--.--.--.| | | ...
60793895fd80830ae6bcb2ea4ea70b357bb568ca
AdamZhouSE/pythonHomework
/Code/CodeRecords/2153/60885/244989.py
182
3.828125
4
num = int(input()) result = 0 neg = num < 0 if neg: num = -num while num > 0: result = result * 10 + num % 10 num = int(num/10) if neg: result = -result print(result)
d14504b60be5774c0f12b47fc7e0abdc49e35992
chenyanniii/Intro-to-Python
/littlelists.py
1,823
4.15625
4
## littlelists.py ## Yanni Chen ## 4/8/2020 ############################################### string = 'The quick brown fox jumped over the lazy dog' print(string) print("###############################################") print("#1 Count the number of spaces in the string") print("The number of spaces in the string is "...
493ab5a3b1c0d1881cdc6588aa7dc6c8b5971ad0
rahulsingh50/Machine-Learning-Deep-Learning-Notes-And-Practice
/Hands-On-Natural-Language-Processing-NLP-using-Python/4-Section-4-Regular-Expressions/reguler_exp_4.py
2,190
3.921875
4
# shorthand character classes import re sentence1 = "Welcome to the year 2018" sentence2 = "Just ~% ++++++ ==== arrived at @jack's place. #fun123" sentence3 = "I love you" sentence1_modified = re.sub(r"\d", "", sentence1) print(sentence1_modified) sentence2_modified = re.sub...
92c06ac5ebaaa42a09fcae306b4a484b87bc8836
olabknbit/Neural-Networks
/final_project/perceptron/neural_network_regression.py
6,608
3.65625
4
def activate(weights, inputs, bias): activation = bias for weight, input in zip(weights, inputs): activation += weight * input return activation class NeuronLayer: def __init__(self, neurons, bias_weights): """ :param neurons: list, of which an element is a dict with 'weights' ...
60a3190b179d5bf85483ee6e3b78c3ddb6e16b3c
WJChoong/Exercise-Python
/Exercise/Formula.py
555
4.125
4
''' Write a program that reads a positive interger, n, form the user and hen displays the sum of all of the integers from 1 to n. The sum of the first n positive integers can be computed using the formula: sum = (n)(n+1)/2 ''' status = 0 #check input while status == 0: try: n = int(input("Please e...
62b111ba8940ba23c2cb4097a70c4ef025ef83c9
lidongze6/leetcode-
/a564. 背包问题 VI.py
653
3.515625
4
class Solution: """ 给出n个物品, 以及一个数组, nums[i]代表第i个物品的大小, 保证大小均为正数, 正整数target表示背包的大小, 找到能填满背包的方案数。 每个物品可重复使用多次,且装物品的顺序不同算不同的方法 """ def backPackIV(self, nums, target): if not nums: return 0 f = [0] * (target + 1) f[0] = 1 for i in range(1, target + 1): for...
27763ae4fdd249101661dc9c6d4550247d0d3de4
git4lhe/lhe-algorithm
/Simulation/음계.py
349
3.6875
4
input_data = list(map(int, input().split())) answer = '' for i in range(1, len(input_data) - 1): if input_data[i - 1] < input_data[i] < input_data[i + 1]: answer = 'ascending' elif input_data[i - 1] > input_data[i] > input_data[i + 1]: answer = 'descending' else: answer = 'mixed'...
b5c7f0c2d19119c510c3095767183bbb57ebf642
otecilliblazh/New
/ex6.py
150
3.65625
4
a=int(input("Введите год :")) b=a%4 c=a%400 d=a%100 if d==0 and c!= 0: print("No") elif b == 0: print("Yes") else: print("No")
ecc0a287c1e9108b53d94d3025a6da8672c60570
rckortiz/codewars
/split-strings.py
522
3.546875
4
# https://www.codewars.com/kata/515de9ae9dcfc28eb6000001/train/python def solution(s): if len(s) == 0: return [] elif len(s) % 2 != 0: s = s +'_' return map(''.join, zip(*[iter(s)]*2)) elif len(s) % 2 == 0: return map(''.join, zip(*[iter(s)]*2)) else: s = s + '_'...
70bbcef35f5d5d154ef9379b8e69ae8e0276f812
DanRodFox/blogz
/helpers.py
1,361
3.75
4
def validate_user(email, password, password_verify): error = {} #error[email_error]='' #error[password_error]='' #error[password_verify_error]='' if not " " in email: if len(email) >= 3 and len(email) <= 20: if "@" in email and "." in email: error['ema...
5fc63a8e3fd032662abe4e3c5269cb99d641e96b
ChinaLongGanHu/Data-Structures-and-Algorithms
/bubbleSort.py
417
3.953125
4
#!/usr/bin/env python def bubbleSort(theSeq): n = len(theSeq) for i in xrange(n-1): swapCount = 0 for j in xrange(n-1-i): if theSeq[j] > theSeq[j+1]: swapCount += 1 theSeq[j], theSeq[j+1] = theSeq[j+1], theSeq[j] if not swapCount: print "Repeat count : %s"%(i+1) break if __name__ == '__ma...
7aca10afc31f29ae7d05ee6333f9aa970bea9e8c
JavganJG/module3
/pyramide.py
199
3.890625
4
blocks = int(input("Number of blocks: ")) height = 0 layerblocks = 0 while layerblocks <= blocks: height += 1 blocks -= layerblocks layerblocks += 1 print("Layers: "+ str(layerblocks))
94768fcb08ac71771244233ea7117806a2b87487
AdamZhouSE/pythonHomework
/Code/CodeRecords/2817/60714/241114.py
414
3.5625
4
n = int(input()) kids = [int(x) - 1 for x in input().split()] length = 0 ans = False for i in range(0, n): temp = i flags = [False for x in range(0, n)] while flags[temp] is False: flags[temp] = True temp = kids[temp] length += 1 if temp is not i: length = 0 if length...
ae39d18ddb6a9c1045e919ce55f308f0d8e7f24f
anuragpatil94/Python-Practice
/LeetCode/codes/206_ReverseLinkedList.py
881
4.1875
4
""" Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? """ class ListNode: def __init__(self, x): self.val = x self.next = None ...
df50f29390277a71e24df94d1f377f089796e1cb
shrukerkar/ML-Fellowship
/PythonLibraries/PlotlyScatterPlot/ScatterPlotForDatasetAndShowDataLabelsOnHover.py
1,153
3.921875
4
#Write a program to draw a scatter plot for a given dataset and show datalabels on hover #https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv import plotly import plotly.plotly as py import plotly.graph_objs as go import numpy as np import pandas as pd plotly.tools.set_credentials_file(usern...
29c54165f6c59a17a41a59d6230070ed8870bf06
bkalcho/python-crash-course
/dice.py
455
4.125
4
# Author: Bojan G. Kalicanin # Date: 05-Oct-2016 # Simulate rolling of dices with different number of sides from die import Die print("\nRolling the 6 sides Die... ") six_side_die = Die() for i in range(10): six_side_die.roll_die() print("\nRolling the 10 sides Die... ") ten_side_die = Die(10) for i in range(10)...
889b149377c3bc54cf1b0ecb2c7171e3bb0c601a
JUNE001/offer-python
/paixu.py
510
3.5
4
# -*- coding:utf-8 -*- class Solution: # array 二维列表 def Find(self, target, array): # write code here m = len(array[0]) - 1 n = 0 flag = 0 while m >= 0 and n < len(array): if target == array[n][m]: return True elif target ...
e59d35c177ac4b7fd39b90a1a6f0579c05aeb915
chenpeikai/Rice_python
/11/alg_project3_template.py
6,621
3.96875
4
""" Student template code for Project 3 Student will implement five functions: slow_closest_pair(cluster_list) fast_closest_pair(cluster_list) closest_pair_strip(cluster_list, horiz_center, half_width) hierarchical_clustering(cluster_list, num_clusters) kmeans_clustering(cluster_list, num_clusters, num_iterations) wh...
31ea40587187e3adaa6f3fc88a155f0767d32f46
Shiva2095/Graphival_User_Interface
/radiobutton.py
519
3.609375
4
import tkinter as tk root=tk.Tk() v=tk.IntVar() tk.Label(root, text="""Choose programming language : """, justify=tk.LEFT, padx=20).pack(anchor=tk.E) tk.Radiobutton(root, text="Python", padx=20, variable=v, value=...
2db5f0f06833e38dde202f69053184a0e858a671
libinjungle/LeetCode_Python
/Array/259_3sum_smaller.py
1,331
3.703125
4
class Solution(object): def threeSumSmaller(self, nums, target): """ brutal-force :type nums: List[int] :type target: int :rtype: int """ if len(nums) < 3: return 0 i, j, k = 0, 1, 2 length = len(nums) count = 0 for i ...
45a797401e6a9bb6d294d64016bce42ed18c0d6b
jdb5523/rosalind
/solutions/reverse-compl.py
125
3.5
4
s = open("data.txt").read() reverse = s[::-1] complement = str.maketrans("ATCG", "TAGC") print(reverse.translate(complement))
6f0b66b166e816cfb464975bbada2ecd70a50a19
durgaprasad1997/missionrnd_python_course
/finaltest_problem2.py
1,202
4.3125
4
__author__ = 'Kalyan' max_marks = 25 problem_notes = ''' Imagine a line starting from 0 to infinity. You color parts of that line green by specifying it as an interval. For e.g (0, 2) will cover the segment from 0 to 2 green. You are given a list of tuples that have to be colored green. If the tuples ar...
12b1c6dae9b262d4c75723f7c8da5bf84df3fb82
cdamiansiesquen/Trabajo06_Carrillo_Damian
/Damian/simples/ejercicio14.py
910
3.734375
4
import os precio_de_pantalones, precio_de_polos, precio_de_vestido= 0 , 0 , 0 #INPUT precio_de_pantalones = int (os.sys.argv[ 1 ]) precio_de_polos = int (os.sys.argv[ 2 ]) precio_de_vestido = int(os.sys.argv[ 3 ]) # Processing total = (precio_de_pantalones + precio_de_polos + precio_de_vestido) #Verificador comprobando...
2e45cf07cd7c652af7a099ec2d8e7f4a50d5718f
nasilo/python-practice
/lesson16.py
826
3.9375
4
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def print_grades(grades): for grade in grades: print grade print_grades(grades) def grades_sum(scores): total = 0 for score in scores: total += score return total def grades_average(grades): grade_sum = grades_sum(g...
17cd86a7a66624f41e4a0a1640a6891a00809109
rishabhranawat/challenge
/leetcode/distribute_candies.py
511
3.59375
4
def distributeCandies(candies): types = set() dist = 0 n = len(candies)/2 N = len(candies) counter = 0 while(dist < n): print(counter) if(candies[counter] == -1): counter += 1 counter = N%(N+counter)-1 else: types.add(candies[counter]) candies[c...
5f539827c45c84696010ed1c4f3f949722b60f57
ShaneMazur/leetcode-solutions
/problem_200.py
1,262
3.703125
4
''' Problem: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Ex. Input: 11110 11010 11000 00000 Output: 1 In...
08a5de4805c0e9b2b5596ad5dbff8d3e100694ab
Polin-Tsenova/Python-Advanced
/Email Validator.py
996
3.6875
4
class NameTooShortError(Exception): def __str__(self): return f"Name must be more than 4 characters" class MustContainAtSymbolError(Exception): def __str__(self): return f"Email must contain @" class InvalidDomainError(Exception): def __str__(self): return f"Domain mu...
660abdb3dad6fe68f72d3d4f53b870579fd3e12c
sarthakgup/AlgorithmsToolbox_Coursera
/APlusB.py
349
3.8125
4
# python3 # taking a look at python version too # i need to improve my python skills # def indicates new user defined function aka method def sum_of_two_digits(first_digit, second_digit): return first_digit + second_digit # main method header if __name__ == '__main__': a, b = map(int, input().split()) pr...
fdd0905f65fecbdaef5219d4b31d866f9b7f037b
DrRelling/python-lessons
/Lesson 4/8 for_and_enumerate.py
378
4.0625
4
supplies = ['pens', 'staplers', 'flamethrowers', 'binders'] for item in supplies: print("Item:", item) input() for index in range(len(supplies)): print("Item", supplies[index], "is at index", index) input() for index, item in enumerate(supplies): print("Item", item, "is at index", index) input() for ...
5a93a142459ecb4141a51e9918ce28640875648f
plee0117/LC
/538.py
656
3.6875
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def convertBST(self, root: TreeNode) -> TreeNode: numbers = [] def addEm(node): nonlocal numbers ...
c193b9ad80d3a2fee64bcf8a534109a6aca39d47
chudichen/algorithm
/arrays/generate_parenthesis.py
1,253
3.875
4
""" 生成所有的括号组合 本题采用回溯(Backtracking)的思想:在当前局面下,你有若干种选择。那么尝试每一种选择。 如果已经发现某种选择肯定不行(因为违反了某些限定条件),就返回;如果某种选择试到最后 发现是正确 https://leetcode.com/problems/generate-parentheses/ """ from typing import List class Solution: def generateParenthesis(self, n: int) -> List[str]: def generate(combination, op_count, cl_cou...
07520937ddbc9204bf104d455c2e495253cd5708
ali-mahani/ComputationalPhysics-Fall2020
/PSet2/P1/koch_set.py
1,710
4.0625
4
#!/usr/bin/env python """ This program draws the koch fractal set to the level specified by the user. Normally as much as it is distinguishable in account for the screen resolution. about level 4 or 5. :) """ import turtle from sys import argv class Koch: """ The class to represent the koch fractal set "...
7cdea93a64c35b449032cfb225e58dfd88aef121
marquesarthur/programming_problems
/leetcode/graph/dfs.py
1,473
3.890625
4
def build_graph(input): from collections import defaultdict graph = defaultdict(list) n = len(input) m = len(input[0]) for node, i in enumerate(range(n)): for to, j in enumerate(range(m)): edge = input[i][j] if edge > 0: graph[node].append((to, edge...
5a39741108a645cb373a4031cbb2b8dff1a9d889
angelusualle/algorithms
/cracking_the_coding_interview_qs/1.7/rotate_arr_90_deg.py
1,014
3.78125
4
from copy import deepcopy # does in O(n) time and O(1) space (in place) where n is number of elements def rotate_arr_90_deg(arr): n = len(arr) rotate_layer(arr, n) return arr def rotate_layer(arr, n): if n <= 1: return for x in range(n - 1): val = arr[0][x] tmp = arr[x][-1]...
685fb303305fc7ed2d18a1b1c7cc21c678875888
sacontreras/HackerRankPractice
/InterviewPrepKit/Dictionaries/TwoStrings/mysolution.py
1,578
3.78125
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'twoStrings' function below. # # The function is expected to return a STRING. # The function accepts following parameters: # 1. STRING s1 # 2. STRING s2 # def twoStrings(s1, s2): d_s1_subs = {} d_s2_subs = {} # to...
29c8f47f7ffaa24d525fdbf17216549a2c242f50
mingyuema1217/leetcode-practice
/200_NumberOfIsland.py
1,050
3.59375
4
class Solution: """ @param grid: a boolean 2D matrix @return: an integer """ def numIslands(self, grid): if not grid: #check if empty return 0 count = 0 for r in range(len(grid)): for c in range(len(grid[0])): if grid[r][c] == 1: ...
fb7d9fc9eb07a6397bd6a3f3d78edc559f9294bf
CRingrose94/ProjectEuler
/problems_000_099/Euler 026.py
644
3.84375
4
from helpers import prime_sieve def compute(limit): period = 1 for i in prime_sieve(limit)[::-1]: # Run through all primes backwards to find largest first while pow(10, period, i) != 1: # pow(a, b ,c) == a ** b % c period += 1 if i - 1 == period: ...
838233a0773c8827ec8ef709708096f42a980c3b
AdrianVasquez1/Learning.py
/Learning.py
2,136
4.21875
4
# this is an octothorpe -- it makes a comment (line ignored by computer) # print("hello world") print("Howdy, y'all") print("I like typing this") print("this is fun") # math skills demo # prints the following sentence print("I will not count my chickens", 2) # calculates the equation giving the number of hens print("...
15095a4d9e3cba1d7a570ae52f0a71559f878703
sssvip/LeetCode
/python/num217.py
911
4.125
4
#!/usr/bin/env python # encoding: utf-8 """ @version: v1.0 @author: David @contact: tangwei@newrank.cn @file: num217.py @time: 2017/11/8 17:47 @description: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arra...
fac59c90ba48665c3226865282e82a3b60f4737e
cigna2020/python_stepik_course
/1-st_part_easy_tasks/print_ruble.py
415
3.765625
4
ruble = int(input()) if ruble > 99 or ruble <= 0: print('ошибка') elif str(ruble)[-1] == '1' and ruble != 11: print(ruble, 'рубль') elif str(ruble)[-1] == '2' and ruble != 12: print(ruble, 'рубля') elif str(ruble)[-1] == '3' and ruble != 13: print(ruble, 'рубля') elif str(ruble)[-1] == '4' and ruble !=...
066746b6fa183781ada27826e7ed05fb962e3650
SandraTang/Encryptors-and-Cryptology-Practice
/caesar-encryptor-spanish.py
1,245
4.125
4
#Caesar Cipher Encryptor (Spanish) #by Sandra Tang print "Caesar Cipher Encryptor (Spanish)" from random import randint alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "Ñ", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] decrypted = raw_input("What do you want to encryp...
6c8bbcc2fa65724c37c73f3c9a359a6389ccd7fe
SakuraGo/leetcodepython3
/PythonLearning/twelve/c12.py
572
3.75
4
import time def decorator(func): def wrapper(*args,**kw): #使用可变参数. print(time.time()) func(*args,**kw) ##可以调用任何多种类的参数 return wrapper @decorator def f1(func_name): print("This is a function named:"+func_name) @decorator def f2(func_name,funcname2): print("This is a function named:"+f...
9c65c182828b95cc790a889ec21cd677a5dcc90f
wreyesus/Learning-to-Code
/python/python_crash_course/chapter_9/9-3.users.py
1,037
4.4375
4
""" Make a class called User . Create two attributes called first_name and last_name , and then create several other attributes that are typically stored in a user profile. Make a method called describe_user() that prints a summary of the user’s information. Make anoth """ class Users: def __init__(self, first...
86bed8193fe577f683eed7292300f9dbf8911dcd
DanielFlash/IntModel
/tmp.py
446
3.578125
4
import matplotlib.pyplot as plt import numpy as np def main(): x = np.array(range(100)) y = np.zeros(100) for i in range(len(x)): y[i] = pow(x[i], 0.5) plt.figure() plt.plot(x, 1 - y / 10, label='coefficients', linestyle='--', marker='o') plt.legend() plt.xlabel("Number of kernels...
c41672c7a03182c7701d282546f4eaa70ef00d3c
MarkFuller1/WikiScraper
/scraper.py
1,783
3.59375
4
from bs4 import BeautifulSoup import urllib3 import re #list of sites visited listmap = set("wiki/Baylor_University") # scrape takes a url and gets a list of embedded urls from the html # returns the number of files visited def scrape(url, counter): #get GET request page response = http.request('GET', url) ...
fde4f5320dee3b0cc71ef9e15fc74bcc7cb634d2
mgermaine93/python-playground
/python-coding-bat/logic-1/sorta_sum/test_module.py
2,062
3.703125
4
import unittest from sorta_sum import sorta_sum class UnitTests(unittest.TestCase): def test_3_and_4_returns_7(self): actual = sorta_sum(3, 4) expected = 7 self.assertEqual( actual, expected, 'Expected calling sorta_sum() with 3 and 4 to return "7"') def test_9_and_4_retu...
69a62158eac6c2657064142ca48b19051ad7f262
IndoG117/Binus-Semester-1
/3 Rough Files (do not look)/Python Projects/Python Projects Old/Gadtardi W2D3 TA result.py
1,551
3.90625
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 29 18:19:31 2019 @author: Gadtardi Wongkaren """ #%% #Problem 2: Deck of Cards #Shuffle a deck of cards and print all of its content from random import shuffle def printCard(): shape = ["heart", "spade", "diamond", "club"] numbers = ["A", "1", "2", "3", "4", "...
06b9dc73c07d78605c92ca11201498d71caf1b29
davesdere/hafizCam
/toolbox/sortingCheatsheet.py
6,157
4.21875
4
#### @Davesdere | David Cote | MIT License 2018 # coding: utf-8 # 16/02/2018 # Let's compare algorithms print('# # # # # # # # # # # # # # # # # # # # #') print('Algorithme Best Case Worst Case') print('Tri par selection : O(n^2) O(n^2)') print('Tri par insertion : O(n) O(n^2)') print('Tri...
7665b12a27dd3b3b3f7965c212241398e06310f6
Ruknin/Day-08
/Day 08 List2/Lesson8a.py
313
3.953125
4
Friends = ('Sovon','pritom','rohit','Zobayer') for x in Friends: print(x,end='\t') '''print("\nTotal number of Friends:", end="") print(len(Friends))''' print("Total number of Friends {0}".format(len(Friends))) digits=(1,2,3,4,5,6,7,8,9) print(min(digits)) print(max(digits)) print(sum(digits))
b71f33227f045ea14f3a4fb1b20aca760e59907b
M1c17/ICS_and_Programming_Using_Python
/Week2_Simple_Programs/Lecture_2/V-file-open-r-w.py
543
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 8 20:30:23 2019 @author: MASTER """ nameHandle = open('kid', 'w') nameHandle.write('Michael\n') nameHandle.write('Mark\n') nameHandle.close() nameHandle = open('kid', 'r') for line in nameHandle: print(line[:-1]) nameHandle.close() #open the...
f86145941eb067d124e056359586ce02232abaac
JasonVanRaamsdonk/Python-Programs-Projetcs
/Class_based-Vigenere_cipher.py
4,687
3.765625
4
""" author: Jason van Raamsdonk """ from abc import ABC, abstractmethod class AbstractClass (ABC): @abstractmethod def getUserInput(self): pass @abstractmethod def msg_and_key(self): pass @abstractmethod def create_vigenere_table(self): pass ...
850892cace73ce3cb85b49e0c1ff0047cbddd8cc
ZE3-Edu/Lab5.1-SimpleNeuralNets
/lab5_1.py
2,733
3.96875
4
import numpy as np from matplotlib import pyplot def logistic_func(x): return 1/(1+np.exp(-x)) """ 1. Try your hand at choosing weights for a network that can compute this function | Input 1 | Output | |---------|--------| | 0 | 1 | | 1 | 0 | """ # remember the second input here is just o...
b8a233a97f1cd8a90a9a0ff7e9130b8c5a6c8090
aminrashidbeigi/ai-classical-search-algorithms
/SearchAlgorithms/ClassicSearchAlgorithms.py
17,475
3.671875
4
import sys def lists_have_same_value(list1, list2): for l1 in list1: for l2 in list2: if l1 == l2: return l1 return None def find_node_with_minimum_cost_to_expand(nodes): min_cost = sys.maxsize min_node = () for node in nodes: if min_cost > node[1]: ...
49c881ad59b8eff8e6462b1a80c72a677b429d86
daniel-reich/turbo-robot
/xFQrHSHYAzw9hYECy_5.py
1,161
3.90625
4
""" Someone is typing on the sticky keyboard. Occasionally a key gets stuck and more than intended number of characters of a particular letter is being added into the string. The function input contains `original` and `typed` strings. Determine if the `typed` string has been made from the `original`. Return `True` i...
a66e9307bcaeaffbf9f373e457b0d6169c7410db
Aasthaengg/IBMdataset
/Python_codes/p03307/s448241322.py
41
3.71875
4
n = int(input()) print(2*n if n%2 else n)
e918e09d3566253121c60a1b3f6b1f4ba64bc52d
JorgeVazquez19/MinijuegosPython
/1.py
730
3.703125
4
import random from pip._vendor.distlib.compat import raw_input carmen = raw_input("Erecribe el nombre del jugador 1: ") primer_dado = random.randint(1,6) segundo_dado = random.randint(1,6) print (carmen + " has sacado un " + str(primer_dado) + " y un " + str(segundo_dado)) carmen_dados = primer_dado + segundo_dado d...
f6696665bf44709890a6bae4e52cf36b2fae6a14
kirstencodes/IntroToProg-Python-Mod08
/Assignment08-KGE.py
5,368
3.703125
4
# ------------------------------------------------------------------------ # # Title: Assignment 08 # Description: Working with classes # ChangeLog (Who,When,What): # RRoot,1.1.2030,Created started script # RRoot,1.1.2030,Added pseudo-code to start assignment 8 # KElghoroury,3.9.2021,Modified code to complete assignme...
e45f291b0bb4d0197508d1bf06e7413ceed0620b
python20180319howmework/homework
/wangzhansen/20180329/h4.py
794
3.59375
4
import datetime import e3293_module as mye import turtle def mytime(mytimestr): for i in mytimestr: if i == "+": turtle.write("年",font=('Arial', 20, 'normal')) turtle.penup() turtle.forward(40) turtle.pendown() elif i == "-": turtle.write("月",font=('Arial', 20, 'normal')) turtle.penup() turt...
27e6fdb86c9bc126261695cd1e2670021712910c
DmitryVakhrushev/Python
/PythonProjects/MOOC_ProgForEverybody/Py4Inf_01_prog01.py
337
3.859375
4
#-------------------------------------------- # Testing: Lecture 02 #-------------------------------------------- print("Hello Kitty!") x = 'Hi' y = 'There' print(x + y) #---------------------- # Multi-way IF x = 0 if x < 2 : print ('Small') elif x < 10 : print ('Medium') else : print ('LARGE') print (...
ae5e06da086b6da886fb3f2d27e8f36ffa8bcaa4
aichibazhang/python3-virtuosity
/02/02为元组命名.py
806
4.125
4
""" __title__ = '' __author__ = 'Yan' __mtime__ = '2018/7/19' """ # eg:('Jim',16,male,'1@1.com') # 元组存储:提升性能和可读性 # 方案一:定义数值常量或者枚举类型 # 方案二:使用nametuple NAME ,AGE ,SEX ,EMAIL = range(4) student = ('Jim',16,'male','1@1.com') def func(student): if student[AGE]<18: print(student[NAME]) # 弊端:多种类似数据难以、处理 # 枚举 fr...
f8537a448dd86b2a63f5e75a3cf0b95b6f7a5524
Abassade1/switch_adebayo
/assignment_switch.py
202
3.828125
4
print ("====VALUE OF AN AREA====") print () lenght = int(input("Room lenght = " )) breath = int (input ("Room Breath = ")) room_size = (lenght * breath) print ("Room Size is ", room_size)
b626077ab62275f9943861cf836a318e85289fb7
NYU-Python-Intermediate-Legacy/lhsu-ipy-solutions
/lhsu-1.1b.py
4,733
3.921875
4
#!/usr/bin/env python import csv import pandas as pd valid_summary = ["maximum","minimum","average","median","centered"] valid_ticker = ["AAPL","FB","GOOG","LNKD","MSFT"] #list could also be built directly from file directory max_days = 251 #******************* #FUNCTIONS IN THIS SECTION #******************* #this...
0db29d09d41a38397766cfdf57eca739ddff3074
jackhong6/PHYS210
/jackhong_assignment_7/mandelbrot2.py
1,313
4.1875
4
def in_mandelbrot(c): # Check if c is in the mandelbrot set using iteration z = 0 max_iter = 100 for n in range(max_iter): z = z**2 + c if abs(z) > 2: return False # no need to use break return True # ---------------- TEST CODE -------------------- test = True # Set to T...
232806982947a29020a1f2195823b71121759b76
sophialuo/CrackingTheCodingInterview_6thEdition
/17.16.py
872
3.71875
4
''' 17.16 The Masseuse. A popular masseuse receives a sequence of back-to-back appointment requests and is debating which ones to accept. She needs a 15 minute break between appointments and therefore she cannot accept any adjacent requests. Given a sequence of back-to-back appointment requests (all multiples of ...
74510a917b49866898ad1202e973a8f6a2d985ad
danielleappel/Numerical-Integration
/eulers_forward.py
442
4.0625
4
# Euler's Method import numpy as np def eulers_forward(f, x_start, x_stop, h, initial_val): """ Returns the x and y vectors from euler's forward method given a function f, start and stop values for x, step size, and initial value of y """ x = np.arange(x_start, x_stop + h, h) y = np.zeros(len(x...
77fd3491e20cae336f0701f632002e31e4ea4faf
congyingTech/Basic-Algorithm
/medium/others/all-paths-from-source-to-target.py
1,612
3.75
4
#encoding:utf-8 """ 问题描述:给定N个nodes的有向无环图,求所有的通路 解决方案:例如 Input: [[1,2], [3], [3], []] 0--->1 | | \/ \/ 2--->3 Output: [[0,1,3],[0,2,3]] 就是有向图的路径输出,可以用backtrack的思路 """ class DirectedGraph(object): def __init__(self,vertices): self.vertices = vertices self.graph = [[0]*self.vertices for i in ran...
1306beb266b1d332083a7fbda06d912f9b03839a
Keerthanavikraman/Luminarpythonworks
/recursion/pattern_prgming7.py
429
3.875
4
#rectangle pattern # * * * * * * * * # * * * * * * * * # * * * * * * * * # * * * * * * * * # * * * * * * * * n = int ( input ( " enter the number of rows " ) ) for i in range ( n ) : for j in range ( n ) : print ( " * " , end = " " ) print ( ) # def square(n): # for i in...
50bb016a0af4ec380852a52c1d4e5d91c8166cff
yknot/adventOfCode
/2016/22_01.py
1,320
3.625
4
"""Day 22 part 1""" class Drive(): """class to define a drive""" def __init__(self, x, y, size, used, avail): self.x = x self.y = y self.size = size self.used = used self.avail = avail def __lt__(self, other): return self.avail < other.avail def parse_dr...
83db3dada0600d4aca4eaed8910366853fa4d514
GuillermoForero/competitive-programming
/CF-A/GravityFlip.py
128
3.515625
4
input() rows = input().split(' ') for x in range(len(rows)): rows[x] = int(rows[x]) rows.sort() for i in rows: print(i)
f34c54785f2a85cc2279edf07e9b2ab888d82521
Dbackx/Project-Euler
/Problem-012.py
1,397
4.21875
4
__author__ = "Daniel Backx" __email__ = "dbackx11@gmail.com" __problem__= 12 __name__ = "Highly divisible triangular number" __source__ = "https://projecteuler.net/problem="+str(__problem__) __example__= """ Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,10 15: 1,3...
3a9064782e0a471c3df7008cc6164ca2d89d7a63
daniel-reich/ubiquitous-fiesta
/3Eia4oLLCcyyLN2L7_16.py
165
3.578125
4
def remove_repeats(s): arr = [] for i in range(len(s))[:-1]: if s[i] != s[i + 1]: arr.append(s[i]) ​ return "".join(arr)+(s[-1])
48940590e9db7ae191f0c5121088042556a6df21
shyammaurya1/Raspberry-pi4-basics-and-related-projects
/second.py
372
3.765625
4
#Pogram to turn led bulb on & off on user`s input import RPi.GPIO as GPIO import time LED_PIN = 17 GPIO.setmode(GPIO.BCM) GPIO.setup(LED_PIN, GPIO.OUT) while True: i = int(input("")) if i==1: GPIO.output(LED_PIN, GPIO.HIGH) print("ON") elif i==0: GPIO.output(LED_PIN, GPIO.LOW) ...
144b0461fdd3ab96eabc9ae184a07eaddc855d61
8snayp8/Task
/№3.py
522
3.890625
4
#3 import random class Cat: def __init__(self, count,CatBoy = 0,CatGirl = 0): while CatBoy + CatGirl < count: CatBoy = random.randint(0,count) CatGirl = random.randint(0,count - CatBoy) self._count = count self._boy = CatBoy self._girl = CatGirl def __display_info(self): print(self.__st...
e9c8993c1841480c697845c05759e251d47dfdcf
thom0497/python-challenge
/PyBank/main.py
1,133
3.6875
4
import os import csv profit = 0 months = 0 maximum = 0 max_month = "" minimum = 100000000 min_month = "" previous = 0 sum = 0 average = "" csvpath = os.path.join("Resources", "budget_data.csv") with open(csvpath, newline="") as csvfile: csvreader = csv.reader(csvfile, delimiter=",") csv_header = next(csvreade...
255cb757296231da66ae2e376b95ddb3664fee53
haoyingl/PythonLearning
/euler20.py
442
3.6875
4
#-*- coding:utf-8 -*- ######################################################################### # File Name: euler20.py # Author: Liang Haoying # mail: Haoying.Liang@nokia-sbell.com # Created Time: Tue 06 Feb 2018 04:18:26 PM CST ######################################################################### #!usr/bin/env py...
799f2a3919ef9bced768f526c79490e0db0edeff
chcbaram/picosystem
/micropython/examples/picosystem/test.py
666
3.5625
4
fh = 0 col = 0 def update(tick): global h global col print("UP: ", button(UP), end=", ") print("DOWN: ", button(DOWN), end=", ") print("LEFT: ", button(LEFT), end=", ") print("RIGHT: ", button(RIGHT)) r = 0 g = 0 b = 0 if button(A): r = 100 if button(B): g =...
33c8d7e3d774c4363257c20324507fd833980b45
jaykumar-parmar/python-practice
/educative_io/puzzle/binary_search/bitonic_peak.py
692
3.9375
4
def find_highest_number(A): low = 0 high = len(A) - 1 # Require at least 3 elements for a bitonic sequence. if len(A) < 3: return None while low <= high: mid = (low + high)//2 mid_left = A[mid - 1] if mid - 1 > 0 else float("-inf") mid_right = A[mid + 1...
b5213051ad9b595c3f9f80a4da332e30859f218e
bawjensen/COMP-116-DataStructures
/Finished Stuff/Lab #5 Snowflake.py
735
3.984375
4
import turtle def turtleSnowflake(recurDepth): wn = turtle.Screen() T = turtle.Turtle() length = 81 depth = recurDepth recursion(T, length, depth) T.right(120) recursion(T, length, depth) T.right(120) recursion(T, length, depth) turtle.mainloop() def recursion(T, length, depth): if dep...
0743935f748731d4e7abd8becb25343d2e97a7bc
nagagopi19/Python-programms
/RecursiveFunction factorial.py
510
4.4375
4
#Recursive Function---> A function calls it self # Examples of Recursive Function ---> Factorial Value, lcf,gcd,towers of hanoi # To find the factorial value using recursion '''def fact(n): if n ==0: res =1 else: res = n*fact(n-1) return res res = fact(4) print(res)''' #To find the factorial value using re...
83e30aa2d6818874df22b1b103cb323fcb1c5330
firesofmay/Reliscore-Answers
/6-degrees-of-serparation/6-degrees.py
981
3.78125
4
#http://reliscore.com/activity/ap/4226/ from collections import defaultdict import sys def find_shortest_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if not graph.has_key(start): return None shortest = None for nod...
941f983cc8890d7393de61ba6faf40063dd354e9
jz4o/codingames
/python3/practice/classic_puzzle/easy/largest-number.py
686
3.640625
4
# import sys # import math import itertools # Auto-generated code below aims at helping you parse # the standard input according to the problem statement. number = int(input()) d = int(input()) # Write an answer using print # To debug: print("Debug messages...", file=sys.stderr, flush=True) digits = list(map(int, ...
37b0eb21895897c320311a1097cb7c2ade7c9433
HansHuller/Python-Course
/ex050 Soma núm pares.py
670
3.75
4
''' Desenvolva um programa que leia seis numeros inteiros e mostre a soma somente daqueles que forem pares. Se o valor digitado for impar, desconsidere ''' color = {"br": "\033[0;30m", "vm": "\033[0;31m", "vd": "\033[0;32m", "am": "\033[0;33m", "az": "\033[0;34m", "rx": "\033[0;35m", "cn": "\033[0;36m", "cz": ...
1af5df43f07d9780cfa6b76404353f2f06545442
pas-campitiello/python
/NotesLearningPython/4-OtherChapters/11-7-Tools-For-Working-With-Lists.py
782
3.796875
4
# The bisect module contains functions for manipulating sorted lists import bisect scores = [(100, 'perl'), (200, 'tcl'), (400, 'lua'), (500, 'python')] bisect.insort(scores, (300, 'ruby')) print(scores) # The heapq module provides functions for implementing heaps based on regular lists. # The lowest valued entry is...
8e692fa460c8b9b946a2f2342bb772b53298a32c
Jebasingh5/sum-of-n
/sum of n.py
73
3.640625
4
n=int(input()) summ=0 for i in range(0,n+1): summ=i+summ print(summ)
6fa3c138f174d94f726790c3b7ea31d3c0f8e948
ArpitaDas2607/MyFirst
/exp33.py
425
3.984375
4
i = 0 numbers = [] while i<6: print "At the tope i is %d"%i numbers.append(i) i += 1 #check how a list (in this case numbers) appear without havaving to specify it's location and nothing like %r etc. print "Numbers now: ",numbers print "At the bottom i is %d" %i print "The numbers: " #num is alr...
0118d1f697e2590e55691e88d457a0d900ea8279
ziggy-data/TDD-Python
/dominio.py
2,145
3.84375
4
from src.leilao.excecoes import LanceInvalido class Usuario: def __init__(self, nome, carteira: float): self.__nome = nome self.__carteira = carteira def propoe_lance(self, leilao, valor: float): if not self._valor_eh_valido(valor): raise LanceInvalido('Não pode ...
0edd9b65b5860acd6fbe4ae55bc20556d3913cf6
sseering/AdventOfCode
/2015/aoc08.py
4,812
4.21875
4
#!/usr/bin/env python3 # --- Day 8: Matchsticks --- # # Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital copy. He needs to know how much space it will take up when stored. # # It is common in many programming languages to provide a way to escape special characters in string...
aaca33287a1b55cb02fe8ee15310ae9f5785c2e9
prachichouksey/Design-1
/Design_MinStack.py
1,878
3.609375
4
# Time Complexity : O(n) # Space Complexity : O(n) # Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : No # Your code here along with comments explaining your approach class MinStack: def __init__(self): """ initialize your data structure here. ...
9517280435bd966f01de40c60094890f0e396c01
viswanathrba/Python
/Interview Questions/Palendime.py
375
4.21875
4
#how to write palindrome def palindrome(input): revarsedinput = input[::-1] if input == revarsedinput: print "{} it is palindrome".format(input) else: print "{} it is not palindrome".format(input) palindrome("akka") palindrome("anna") palindrome("sis") palindrome("mam") palindrome...
ae43bd428df7d201f018964d26162278aaa32496
MDupdup/PolyNN
/Matrix.py
3,128
3.875
4
from random import randrange, randint class Matrix(object): def __init__(self, rows, cols): self.rows = rows self.cols = cols self.data = [[0 for x in range(self.cols)] for y in range(self.rows)] # Randomize the newly created matrices def randomize(self): for i in range(se...
e0be731e96e44f10ebaec729704453f39b810c5b
mdgregor/PyWeb-03
/homework/calculator.py
4,861
4.15625
4
""" For your homework this week, you'll be creating a wsgi application of your own. You'll create an online calculator that can perform several operations. You'll need to support: * Addition * Subtractions * Multiplication * Division Your users should be able to send appropriate requests and get back proper...
008a0b5689bcdc43c02682ab70a9aac5638f6b77
RJD02/Joy-Of-Computing-Using-Python
/Assignments/Week-1/Assignment1_3.py
316
4.1875
4
''' Given two integer numbers as input, print the larger number. Input format: The first line of input contains two numbers separated by a space Output Format: Print the larger number Example Input 2 3 Output 3 ''' a, b = input().split(" ") a = int(a) b = int(b) if a > b: print(a) else: print(b)
c0fccc198050edaddfc0b068850ca97fae78b14f
CalumWood/Git-Test-Repository
/test.py
370
3.53125
4
import unittest import app class TestMethods(unittest.TestCase): def test_squared(self): squareNumbers = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] for i in range(1, 10): self.assertEqual(app.squared(i), squareNumbers[i-1]) def test_cubed(self): self.assertEqual(app.cubed(3), 2...
b88b30ec956c15c8fe0fef48484525c52f2be3a6
Vitaliann/-laba-3
/Лаба 3/лаба 3.py
184
3.984375
4
a=int(input("Введите число:")) if a<0: print(a,"меньше нуля") elif a==0: print(a,"равно нулю") else: print(a,"больше нуля")
2421fa1369c2813760380744b1274c44a81efd18
lisu1222/Leetcode
/mySqrt.py
568
4.4375
4
''' Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Example 1: Input: 4 Output: 2 ''' def mySqrt(x): left, right = 0, x ...
3346f13b1e130eb71d76794ddcc85d69c0d9aaf8
HEroKuma/leetcode
/1440-convert-integer-to-the-sum-of-two-no-zero-integers/convert-integer-to-the-sum-of-two-no-zero-integers.py
1,012
3.90625
4
# Given an integer n. No-Zero integer is a positive integer which doesn't contain any 0 in its decimal representation. # # Return a list of two integers [A, B] where: # # # A and B are No-Zero integers. # A + B = n # # # It's guarateed that there is at least one valid solution. If there are many valid solutions y...
4f98bdffa6d4f8c831719480be67731a63ddf25a
nsarlin/ml_simple
/Utils.py
1,274
3.6875
4
import numpy as np import numbers def sigmoid(z): """ The sigmoid function is used to uniformally distribute values from [-inf;+inf] to [0;1]. z can be a matrix, a vector or a scalar """ return 1.0/(1.0+np.exp(-z)) def sigmoid_grad(z): """ Gradient of the sigmoid function """ ...
107d7b3c092597dfa5e7290d53277a15a5524f1a
jinuxplain/Python-study
/Python & web/Lecture 25.py
1,408
4.03125
4
# # 예제 3 ) 자의로 에러 발생 시키기 # class MyCustomError(Exception): # def __str__(self): # return "Custom Error!!" # try: # raise MyCustomError() # except MyCustomError as e: # print(e) # # 예제 2) 커스텀 에러 # class MyCustomError(Exception): # def ___str___(self): # return "나만의 특별한 에러 처리!" #...