blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
3686eb04bd7dac04c979302f451ff38a6d45df5e
MrHamdulay/csc3-capstone
/examples/data/Assignment_4/vhyros001/boxes.py
911
4.0625
4
""" module of functions to print hollow boxes Ross van der Heyde VHYROS001 31 March 2014""" def print_square (): print("*"*5) for i in range (5-2): print("*"," "*(5-2), "*",sep="") print("*"*5) def print_rectangle (width, height): print("*"*width) for i in range (heig...
a237e3f1811367309c513bfac5d5cedb3c6e7353
kooshine/LeetCode
/plan_200/047_trace_back_path.py
1,213
3.578125
4
# -*- coding: utf-8 -*- # -*- coding:utf-8 -*- class Solution: def hasPath(self, matrix, rows, cols, path): # write code here def dfs(matrix,path, i, j, k): if not(i < rows and i >= 0) or not(j < cols and j >= 0) or not (matrix[i*cols + j] == path[k]): return False ...
fcbdbefd43a6a2d9a1717a65a18ebf58a9ea3e12
dadisigursveinn/FOR3G-Skilaverkefni-1
/teningakast.py
785
3.96875
4
from random import randint summaTolvunnar = 0 for x in range(1, 7): summaTolvunnar += randint(1,6) playing = 0 attemt = 0 enter = 0 while playing == 0 and attemt < 3: attemt += 1 summaLeikmanns = 0 for x in range(1, 7): raw_input("Press enter to roll dice " + str(x)) summaLeikmanns += ra...
506d3d2d8fb11c1bd1a306113e6f9b45a4375ff0
CougarTasker/twenty-four
/proto/timehandel.py
2,680
3.65625
4
import time,math class TimeHandler: def __init__(self): self.playing = True#is the game paused self.offset = 0#the amount of time lost to the game being paused self.pausestart = 0#stores when the pause was started self.pausehandelers = []# keep refrences to all the pause handelers self.incHandel = []#...
c6ab70cabd9889b0b4cc0e53b8b2691f5b3d381e
sourabh-714/python-and-data-science
/DU_PythonML_21-main/crawl_3.py
545
3.53125
4
import urllib.request as url import bs4 movie = input("Enter movie name : ") response = url.urlopen("https://www.imdb.com/find?q={}".format(movie)) page = bs4.BeautifulSoup(response, 'lxml') td = page.find('td', class_='result_text') a_tag = td.find('a') href = a_tag.attrs['href'] response = url.urlopen("https://www...
ab73550655a00811bbb75c3428f573ee5a6b05f5
SavvasR1991/Safe-Geolocalization-Project
/Third_Party/Three-sphere-intersection-Python/Node_Localization.py
3,219
3.671875
4
import numpy from numpy import sqrt, dot, cross from numpy.linalg import norm # Find the intersection of three spheres # P1,P2,P3 are the centers, r1,r2,r3 are the radii # Implementaton based on Wikipedia Trilateration article. pointImportSeparator = 0 shapeCounter = 1 text_file = open("Output.txt", "w") ...
ef647e1777ff166e31aa150ddd4f4463555b22fe
alulec/CYPAlexisCC
/libro/problemas_resueltos/capitulo_2/problema2_4.py
578
4
4
# dada la matricula de un alumno y sus cinco calificaciones, imprime su matricula, su promedio y su estado (aprobado/ no aprobado) mat = input("Matrícula del alumno: ") cal1 = float(input("Primer calificación: ")) cal2 = float(input("Segunda calificación: ")) cal3 = float(input("Tercera calificación: ")) cal4 = float(i...
4e217dc78e7b2f38d8e7b1c8466b503fb3e3e786
J-in-Japan/snippets
/daily/daily_20190524.py
725
3.96875
4
# n queens problem # given an nxn board, determine the max number of queens that can be placed safely # board: 1 = queen, 0 = empty def is_safe(board, row:int=0, col:int=0) -> bool: # check column for i in range(len(board)): if board[i][col] == 1: return False # check row for i in ...
57cfb68205101a3df11c69b7b8ff47f458c297cb
dna-witch/Rosalind
/Solutions/Python Village/condLoop.py
494
3.609375
4
### Solutions to Rosalind Problems ## "Conditions and Loops" file_name = "rosalind_ini4.txt" # insert your filename here as a string s = open(file_name, "rt").read().split() s = list(map(int, s)) a = s[0] b = s[1] result = 0 # here is where we do a trick! for i in range(a, b+1): # we want the range to be...
2a4cce0e554b5fb7979c8561046dd7ff7859749d
BIONIChae/Level-0-coding-challenge
/pseudocodetask7.py
211
3.78125
4
def convert(cels, fahr): for c in range(cels): fahrenheit = (9/5 * cels) + 32 for f in range(fahr): celsius = (fahr - 32) * 5/9 return fahrenheit, celsius print(convert(35, 68))
18106448a0c1340c2370d33f6669ff07185c01ed
sandeeppy-ds/Py
/Excercise_1_Problem_19.py
105
3.859375
4
#Convert an integer to string format and print it. x = 10 print(type(x)) print(type(str(x)),x)
11e69a46e9c17b2e303b106141e4ccbdb8b8ab33
dikshax/uni
/intro_pro/workshop_7/part_1.py
1,921
4.40625
4
# 1. create three dictionaries: dic1 = {1:10, 2:20} dic2 = {3:30, 4:40} dic3 = {5:50, 6:60} # a. write code to concatenate these dictionaries to creat a new one. create a variable called nums to store the resulting dictionary. there are multiple ways to do this, however, one of the easiest is to convert each of the d...
09fb417898f879d575e03724163f5d6d77ff7a5b
cleliacrv/adv-python-group-3
/src/ie_pandas/__init__.py
7,030
3.65625
4
import numpy as np import matplotlib.pyplot as plt from prettytable import PrettyTable class dataframe: def __init__(self, dic): ''' This is a docstring to explain the __init__ ''' self.dictionary = dic self.columns = list(self.dictionary.keys()) self.values = lis...
ec469c37e652ef0fa8cf2f3139836e2c2ff0b1bf
liu-yuxin98/Python
/chapter6/6.29.py
1,084
3.96875
4
#-*- coding=utf-8-*- def doubleDigit(digit): # ÿһλԶ if digit >=5 : double = (2*digit) % 10 + 1 else: double = 2*digit return double def sumDoublednumber(number): sum=0 count=0 while number!=0: #print("number={}".format(number), end=" ") digit=number%10 cou...
e9cf53b863580bb342f59374c80e61f85dad8e2f
seeni-dev/CourseRecommendation
/src/Handler.py
1,028
3.734375
4
import pandas class Handler(): def __init__(self): pass def connect(self): raise Exception("Need to be implemented") def open(self): raise Exception("Need to be implemented") def read(self): raise Exception("Need to be implemented") def getData(self): ra...
962c1e015febafc53e2e83fc3cb4c87ea7cf7d9a
myanir/Campus.il_python
/self.py/square.py
220
3.953125
4
def squared_numbers(start, stop): squared = list() while start <= stop: squared.append(start **2) start += 1 return squared print(squared_numbers(4, 8)) print(squared_numbers(-3, 3))
ab3902308edf927f6025f29d0e881c23c714fef4
sivanivelchuri/Python-Programs
/sherlock and his girlriend.py
603
3.625
4
def prime_factors(): n=25 seive=[i for i in range(n+1)] ## print(seive) i=2 while i*i<=n: for j in range(i*i,n+1,i): if seive[j]%i==0: seive[j]=2 i+=1 for k in range(2,n+1): if seive[k]==k: seive[k]=1 seive[0...
ff804b8ba67daf3bedc78adaeb37929f53f1cc26
XingyuHe/cs110
/recursion/additive_primes.py
2,711
4.5
4
""" ***************************************************************************** FILE: additive_primes.py AUTHOR: Xingyu He ASSIGNMENT: Project 7 additive_primes DATE: Oct 19 2017 DESCRIPTION: This program has two function. The first is to determine ...
adf36fc98a9e8694b572c2224f041d1090dda32a
valeriangalliat/virtualis-client
/virtualis/methods/list.py
855
3.734375
4
from . import Response from abc import abstractmethod class LazyDict: def __init__(self, get): self.get = get def __getitem__(self, name): return self.get(name) class ListResponse(Response): '''Response for a protocol formatted list.''' def parse_loop(self, dict): '''Loop o...
5e6e92f135c4b09b57cdd762dd0fe3b52f16d525
crispto/algorithm
/backtracking/python/rooms.py
742
3.6875
4
def search_room(v): """ [[1, 2, 3], [3], [2], []], 每个房间里通向其他房间的钥匙 """ if search_dfs(v, 0, 1, [0]): return True return False def search_dfs(v, current, level, walked): if level == len(v): return True for i in v[current]: if not i in walked: walked.app...
4aebbcf2ba9a1aec82b2ed213319cd209adc07f4
Munyekiliz/pythonProject2
/Assignment1.py
311
3.984375
4
names = input("Enter your first and last name: ") #print(names) print("Name: " + " " + names) print() # Enter What are your goals for this class - long term goals? goals = input('What would you like to be ....when all is said and done with the class?: ') print("My goals are to be a : " + " " + goals) print()
9a21980e8a5983a651bc37dee76077ad3c8743dd
Chauhan-Veer/oto-helper
/oto_helper_library/video_to_audio_converter.py
997
4.1875
4
""" This function is used to convert the passed video file into a audio file for further processing. """ """We use *args and **kwargs as an argument when we have no doubt about the number of arguments we should pass in a function""" def extract_audio(video_file_name, audio_output_file=audio.mp3, *args, **kwargs): ...
cb708acbc240745344a9566db4bfd553301dd861
pmgasper/leetcode
/0001_two_sum.py
2,361
3.875
4
#!/usr/bin/env python3 # # 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, and you may not use the same element twice. # Example: # Given nums = [2, 7, 11, 15], target = 9, return [0, 1]. ...
afef2cb9528d0e515445dfeeb79d202f7dfa1739
tapumar/Competitive-Programming
/Uri_Online_Judge/2583.py
394
3.53125
4
casos = int(input()) for i in range(casos): qnt = int(input()) tudo = [] for j in range(qnt): coisa = input().split() if coisa[1] == "chirrin" and coisa[0] not in tudo: tudo.append(coisa[0]) elif coisa[1] == "chirrion" and coisa[0] in tudo: tudo.remove(coisa[0...
c8293109d0849c257d6bbd2cc15a4ad7b121b287
ShuvenduRoy/Interview
/BackTracking/22. Generate Parentheses.py
1,216
3.65625
4
class Solution(object): def generateParenthesis(self, n): """ :type n: int :rtype: List[str] """ def generateParenthesisHelper(currentStack, left, right): if left == right == n: result.append(''.join(currentStack)) return ...
58307fbf074d1cccc066359afe9f0dd2194a8318
Redul94/codeforces_python
/070 - 749A - Bachgold Problem.py
144
3.71875
4
n = int(input()) if n % 2 == 0: print(n//2) print('2 ' * (n//2)) else: n = n - 3 print(n//2 + 1) print('2 ' * (n//2) + '3')
b2658b6239360f2520db5a32b42e412e263e9d46
strawsyz/straw
/my_cv/07/07_03_example/car_detector/sliding_window.py
359
3.65625
4
"""滑动窗口的函数""" def sliding_window(image, step_size, window_size): """给定一副图像,返回一个从左向右滑动的窗口,直至覆盖整个图像""" for y in range(0, image.shape[0], step_size): for x in range(0, image.shape[1], step_size): yield (x, y, image[y:y + window_size[1], x:x + window_size[0]])
ccb46c1be4727007699474f971bb76be7e12162d
L-Groeninger/Python_projects
/Katas.py
3,362
3.9375
4
# -*- coding: utf-8 -*- """ Created on Fri Jul 24 11:36:57 2020 @author: Administrator """ # 1. ############################################################################## # Kata to place someone in a category (7kyu) def open_or_senior(data): res = [] for i in data: ...
790a01dfdc2d574ebcac8f522d63a5d5af07763a
zyjImmortal/geek
/al_interview/toutiao/array.py
3,680
3.546875
4
from typing import * class Solution: def maxProfit(self, prices: List[int]) -> int: ''' 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。 注意你不能在买入股票前卖出股票 :param prices: :return: ''' max_profit = 0 for i in range...
b69de8c508eb547497ec17bf3c2dc6b2cae74a60
sidazhong/leetcode
/leetcode/easy/206_Reverse_Linked_List.py
876
3.96875
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): #双指针, 左None,右1 def reverseList(self, head): l = None r = head while r: tmp = r.next r....
604dc0a51c88084a3f47b33e46faf49f20260d9f
zeroWin/Python
/Core python programming(2th)/Chapter 3/3_10_readTextFile.py
302
4.3125
4
'readTextFile.py -- read and display text file' import os # get filename fname = input('Enter filename: ') print() # attempt to open file for reading if os.path.exists(fname): fobj = open(fname,'r') for readLine in fobj: print(readLine,end = "") fobj.close() else: print("ERROR:No such file")
e49dfe3ccc5db3bbed630bed0e5fe7c9e468c283
zhuobinggang/NLP-100-knock
/deep-learning-test-ground/index.py
698
3.515625
4
import matplotlib.pyplot as plt import numpy as np def plot_data(data, labels): """ argument: data: np.array containing the input value labels: 1d numpy array containing the expected label """ positives = data[labels == 1, :] negatives = data[labels == 0, :] plt.scatter(positives[:, 0],...
ff78870667c0998e885d95485e6fade1811ff365
edson-gonzales/sudoku2015-C
/src/tests/game/test_sudoku_grid.py
2,605
3.5625
4
""" This module is in charge of testing the different types of Grid for the Sudoku2015-C game performed by the SudokuGrid class. """ import unittest from ...game.sudoku_grid import SudokuGrid class TestSudokuGrid(unittest.TestCase): def test_sudoku_grid_can_be_created_with_no_arguments(self): grid = Sud...
a09e487fcf27f280f660bda6ff9545b3535ce11d
vitor-apolinario/NUMERIC
/cordas.py
448
3.6875
4
def f(x): return (x**3)-5 a = int(input('A:')) b = int(input('B:')) e = 0.000001 it = 0 x1 = float(((a*f(b))-(b*f(a)))/(f(b)-f(a))) xn = 0.0 while True: if f(x1)*f(a)> 0: xn = float(((xn*f(b))-(b*f(xn)))/(f(b)-f(xn))) else: xn = float(((a*f(xn))-(xn*f(a)))/(f(xn)-f(a))) ...
ab53e237060290007b95e8d6395425b691222fb0
viszi/codes
/CodeWars/6kyu/Python/024-backwards-read-primes.py
1,482
4.09375
4
# https://www.codewars.com/kata/5539fecef69c483c5a000015 # Find all Backwards Read Primes between two positive given numbers (both inclusive), the second one always being greater than or equal to the first one. The resulting array or the resulting string will be ordered following the natural order of the prime numbers....
484ae4675d4e66fe9eab383094877590aee91e73
PakornChaenglew/6230403882-oop-labs
/pakorn-6230403882-lab6/Prob3.py
112
3.734375
4
read = input(">>>") with open(read, encoding='utf8') as f: for line in f: print(line, end='')
89333d7df809c3c32fa5a54a4ba601a33a55f5da
kleberfsobrinho/python
/Desafio078 - Maior e Menor Valor em uma Lista.py
603
3.75
4
lista = [] maior = 0 menor = 0 for c in range(0, 5): lista.append(int(input(f'Digite o valor da {c + 1}ª posição: '))) if c == 0: maior = menor = lista[c] else: if maior < lista[c]: maior = lista[c] if menor > lista[c]: menor = lista[c] print(f'Valores {lista}...
12bc3b814f24eecce861cf56418bcd7f509119a4
jnnabugwu/JavaScript-Algo-Problems
/Python problems/paratheisis.py
681
3.859375
4
# Remove the minimum number of invalid parentheses in order to make the # input string valid. Return all possible results. # Note: The input string may contain letters other than the parentheses ( and ). # Examples: # "()())()" -> ["()()()", "(())()"] # "(a)())()" -> ["(a)()()", "(a())()"] # ")(" -> [""] def uniplz...
7e5d974d6b01bfc8d0022610ed3e1d1bf68ae886
JanakSharma2055/Cryptopals
/set2/challenge9.py
751
3.953125
4
def pad(text, size): """pads text to make it of size `size`, according to the PKCS#7 padding scheme Args: text (bytes): the text to pad size (int): required size of padded string Returns: bytes: the padded string with size = `size` """ length = len(text) if length %...
53c8b4ef52de4db30b38b0cde3ccbd05c8467b3b
ds-ga-1007/assignment9
/js5991/Assignment9.py
1,805
3.546875
4
''' Created on Dec 3, 2016 This is the main module of assignment 9 @author: Jingyi Su js5991 @descriptions: This program asks user for a year and then display the graph of income per person across all countries in the world for the given year. The user will be ased the question until 'finished' is entere...
be06acfb5598cc233a1670e853b61e55a9bb7a57
gistable/gistable
/dockerized-gists/564313/snippet.py
2,509
3.609375
4
""" I've been thinking lately about how perfect Redis would be for storing a simple social graph. I posited that it would be relatively few lines of code, and that it'd be clean code too. So here it is: a basic social graph built on Redis. """ class FriendGraph(object): def __init__(self, ring): self....
fc2db4b21f77bf618b862575c601dce3c22c532f
gonzalob24/Learning_Central
/Python_Programming/BinaryTrees/HeapTree.py
3,052
3.765625
4
# Heap Tree array implementation class HeapEmptyError(Exception): pass class Heap: def __init__(self, maxSize=20): self.a = [None] * maxSize self.n = 0 # all values in the heap should be less than this value self.a[0] = 99999 def insert(self, value): self.n += 1 ...
6b5a1dfe490096c1d3a0abe5516ba4cb9ae05159
Zildjiandrummerx/Python-Files
/instances.py
659
4.1875
4
# Create a function named combiner that takes a single argument, # which will be a list made up of strings and numbers. # Return a single string that is a combination of all of the strings # in the list and then the sum of all of the numbers. # For example, with the input ["apple", 5.2, "dog", 8], combiner would # ...
4eee4bbf979b36dcb71a63143edcc065db03eea0
AngeloESFM/All_programs
/juego_adivina_el_numero_2.0.py
1,559
3.75
4
# 41 JUEGO DE ADIVINAR EL NÚMERO 2.0 while True: import random # Variables para modificar el juego posibilidades = 5 limite = 100 intentos = 0 print(" Hola, ¿cómo te llamas?") nombre = input() print("Bien " + nombre + " vamos a jugar, estoy pensando un número del 1 al " + str(limit...
6aa5b6e597ad2b0d78ec4b3c15a756d776a22a1f
Ni4ka1991/OopTouristAgency
/app.py
555
3.59375
4
#!/usr/bin/env python3 from money import Money from dateTime import Period #import datetime #tour = TourBuilder("Italy","The best parst of Italy",[Tourist("John Doe", 21), Tourist("Jane Doe", 30), Tourist("Jenny", 6)],Period("01.01.2021","02.01.2021")).withEnsurance().withGuide().build() price_1 = Money(300, "MDL")...
b65dea3c356e89c8ca52a304b70bdc19b84d8799
fromasmtodisasm/rose_backup
/CSSE 120/Python Programs/In Class Stuff/src/minimum.py
139
4.03125
4
def printMinofThrre(): x1, x2, x3 = input("Enter 3 numbers seperated by commas: ") if x1 <= x2 <= x3: min_val = x1
1e0a2aabe80202ade7056ef664a2dff38b52a859
vierth/hcs
/morestring.py
710
3.90625
4
# Some more string stuff: s = "test string for fun testing" # find returns -1 if no results: print(s.find("y")) # rfind returns the last results print(s.rfind("s")) # string slices: s[0] # first character s[:10] # first ten characters (index 0 to 9) s[10:] # characters from ten to the end of teh string s[10:14] # ch...
8945e1608fc2ba6c7304351cb811711eca0a8a73
AceRodrigo/CodingDojoStuffs
/Python_Stack/flask/flask_fundamentals/hello_flask/hello.py
871
3.515625
4
from flask import Flask #Import Flask to allow us to create our app app = Flask(__name__) #Create a new instance of the Flask Class called "app" @app.route('/') #The "@" decorator associates this route with the function imediately following def hello(): re...
6a2e9df713c3de682e8917d5c1016bb94a2de515
Yakobo-UG/Python-by-example-challenges
/Additional challenges/challenge 38.py
186
4.25
4
#Create a function that returns True if an integer is divisible by 5, and false otherwise. def num(num1): if num1%5 == 0: return True else: False print(num(3000))
f63ea9a0062a4c290f99fb4a3c1f268067fba541
borisachen/leetcode
/228. Summary Ranges.py
448
3.671875
4
228. Summary Ranges Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. class Solution(object): def summaryRanges(self, nums): """ :type nums: List[int] :rtype: List[str] """ ranges = [] for n in nums: if no...
7bf5a4ad3f32aa0fac0fede1e38dae01e4d32e42
snowdj/cs_course
/Algorithms/challenges/lc008_string_to_integer_atoi.py
2,385
3.75
4
""" Time: O(n) Space: O(n) Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be specified vaguely (ie, no given input specs...
14f008cd3cb8ff67e5b9a0d328ca2ecbf1f1ce5f
mishazakharov/DL-library
/DL/tensor.py
304
3.578125
4
import numpy as np def tensor(input_data): """ Reshapes input_data in tensor M x N x J, where M - number of samples, N - number of attributes, J - 1 So every object is (8,1) matrix! """ tensor = input_data.reshape(input_data.shape[0],input_data.shape[1],1) return tensor
fe3ae5983a84419ea98a4c1f5a2650414ec1b9df
HarikrishnaRayam/Data-Structure-and-algorithm-python
/Stacks/Nearst Greater to right
919
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 7 17:02:00 2020 @author: Cheerag """ ''' Foundation Code ''' def nearestGreaterToRight(arr): ''' arr[] : 3 7 6 9 10 result : 7 9 9 10 -1 ''' stack = [] result = [] for ele in range(len(arr)-1,-1,-1): if len(s...
f34337c57f718ed66b8a7f73183148fc12f5b1b7
ritesh-deshmukh/Algorithms-and-Data-Structures
/180Geeks/Arrays/rotate_by_n.py
559
3.703125
4
arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] arr1 = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] n = 4 def rotate(arr, n): temp = [] * n # count = 0 for x in range(len(arr[:n])): temp.append(arr[x]) del arr[:n] # print(f"Array after deletion = {arr}") for y in range(len(temp)): ...
03b5d3b8ee37f9fdfaa22f2c1e9ea5cc1639166b
chippolot/advent-of-code
/2015/9_1.py
972
3.515625
4
import sys file = open('9_1_input.txt', 'r') nodes = {} def get_or_add_node(id): if id not in nodes: nodes[id] = [] return nodes[id] def add_connection(id_a, id_b, distance): node_a = get_or_add_node(id_a) node_a.append({'id':id_b, 'distance':distance}) node_b = get_or_add_node(id_b) node_b.append({'id':id_...
239332f3235346a60d3d9fe7b8ca2def073bb19b
Zakanawaner/EA
/maximum.py
1,340
3.625
4
# Finding the maximum of the function # y = -x * (x-2) * (x-5) # between 0 and 5 using evolutionary algorithms import random GENERATIONS = 1000 INDIVIDUALS = 8 RANGE = 5 BEST_SELECTION = INDIVIDUALS // 2 MUTATION = INDIVIDUALS - BEST_SELECTION def equation(x): return -x * (x - 5) * (x - 1) def reproduction(x1...
46b9acb8474603b14076a5af2d7d892cfc47684c
Babkock/python
/8 - Sets and Dictionaries/Module8/more_fun_with_collections/set_membership.py
197
3.890625
4
#!/usr/bin/python3 """ Tanner Babcock October 15, 2019 Module 8, topic 1: Sets in Python """ def in_set(the_set, element): if (element in the_set): return True else: return False
0f7ef11a921d779e9f0755efa396863cce5c2a0b
gabrielratao/curso_python
/Códigos Curso/05 repetições/confere_lista_em_outra_lista.py
548
3.921875
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 18 19:44:31 2021 Criar duas lista de dados. Descobrir se os dados da lista 2 estão dentro da lista 1 e mostrar quais estão e quais não estão @author: User """ lista1 = ['UFSC', 'Uva', 5, 5.2, 'Nelson', 'Python', 'Sabonete'] lista2 = ['Uva', 5, 'Vaca', 'Gab...
a11c5cf0b5fb3a01ac83a5ad18f62557b5d9258a
locke12456/OrbAI
/move.py
1,509
3.96875
4
from enum import Enum import math class Move(Enum): up = -6 left = -1 right = 1 down = 6 def can_move(self, index): row = math.floor(index / 6) if index < 0 or index > 29: return False if self == Move.right and index == 0: return True if s...
7aaa0f5e7e6d2f0ac7ddf30c1fffb32e24758986
eltnas/ExerciciosPythonBrasil
/02 - EstruturaDeDecisao/12.py
898
3.84375
4
horasTrab = float(input("Quantas horas trabalhou esse mes? ")) valorHoras = float(input("Valor das horas: R$ ")) salBruto = horasTrab * valorHoras if salBruto >= 2501: desc = 20 elif salBruto <= 2500 and salBruto >= 1501: desc = 10 elif salBruto <= 1500 and salBruto >= 901: desc = 5 else: desc = 0 salIR = (salBr...
deb716d7640b7d68dfbae95dd0519b722a7c4c64
MartinYan623/Lint-Code
/Algorithm/Easy/1000+/1137ConstructStringfromBinaryTree.py
828
3.84375
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param t: the root of tree @return: return a string """ def tree2str(self, t): # write your code here result = "" ...
e753d16255bdf622fbaf1ab7515731e3d2b17edc
fyangss/questions
/python/practice/string_permutation_01.py
323
3.765625
4
def premuteStringHelper(permutation, string_left): if len(string_left) == 0: print(permutation) for i in range(len(string_left)): a = permutation + string_left[i] premuteStringHelper(a, string_left[:i] + string_left[i+1:]) def permuteString(string): premuteStringHelper('', string) permuteString('ABC...
3144b5f2b55187523bf7ae92024ee9bdff9e08be
rmanantsoa/pdsnd_github
/bikeshare.py
7,302
4.28125
4
# # This is final Udacity project that explore bike share date with Python # import time import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } MONTHS = ['january', 'february', 'march', 'april', '...
d2b901b76b823f9f2d3f44f44e31678b19cd64d0
conniemomo-htx/hello-world
/exercism/python/pangram/pangram.py
401
4.0625
4
import string def is_pangram(sentence): alphabet = string.ascii_lowercase # Strip out all non-word, and set to lowercase alphaOnly = [ c.lower() for c in sentence if c.isalpha() ] # Compare the length of the set (unique) vs original string length return ( len( alphabet ) == len( set(alphaOnly) )...
e0a459bdace6931dfb1bc58e6de1bcbae6e4aa87
chaitanyalotake/Problem_solving_hackerank_python
/min_max_sum
446
3.890625
4
#!/bin/python3 import math import os import random import re import sys # Complete the miniMaxSum function below. def miniMaxSum(arr): arr.sort() minsum=0 maxsum=0 for i in range(1,len(arr)): maxsum=maxsum+arr[i] j=0 while(j<len(arr)-1): minsum=minsum+arr[j] j=j+1 ...
848ccc24977149ec690d41519d5729c271b259f4
medishettyabhishek/Abhishek
/Abhishek/Section 9/Section 9-1/Metacharcters.py
339
3.734375
4
#. is the most important dotmetacharacter #import re #pattern = r"gr.y" # the string should start with this name so that it returns true #if re.match(pattern ,"agray"): # print("match found") #else: # print("match not found") import re pattern = r"[A-Z][A-Z][0-9]" if re.search(pattern , "AA1"): print("...
fa7da29c6a3a9bc7d8a6127e4722a6e5d1f344c1
fredpaiva42/Grokking-Algorithms
/binary_search.py
940
3.953125
4
def binary_search(list, item): # * low e hight definem as duas metades da lista low = 0 high = len(list) - 1 while low <= high: # ! enquanto você não tenha restringido para 1 elemento mid = (low + high) # * pega o elemento do meio guess = list[mid] if guess == item: # * se o ...
6cc02781a1d02a9b43be234cc29fa57c1761c34b
Squidjigg/pythonProjects
/oddOrEven.py
536
3.984375
4
userInput = '' # contine until user enters q to quit. while userInput != 'q': userInput = input("Type in a number between 1 and 1000 (type q to quit): ") if userInput == 'q': break # convert input var to int. userNumber = int(userInput) print(userNumber) # if remainder of division...
5fa4db7e17e19c4668a9d0e0fcfaf6c3fde39021
jeremy-oz/y10programming
/Lab08/gui_ex2.py
1,068
3.703125
4
#====================== # imports tools #====================== import tkinter as tk from tkinter import ttk # Create object win = tk.Tk() # Add a title win.title("Student Survey") # Adding a Label that will get modified tea_drinkers = 0 coffee_drinkers = 0 tea_label = ttk.Label(win, text=f"{tea_drinkers} students d...
80c2a2a5ea961a2383fe11b25ac298a5375170fb
kiranrraj/100Days_Of_Coding
/Day_48/right_angle_tri.py
511
4.46875
4
# Title : Triangle Calculations # Author : Kiran Raj R. # Date : 1/12/2020 import math width = float(input("Enter the width length of the triangle: ")) height = float(input("Enter the height of the triangle: ")) third_side = math.sqrt((width**2) + (height**2)) perimeter = third_side + height+ width area = 0.5 * ...
f3f174188eee37005aa0e6a0a2ae1ecc76bb2888
FBoyang/DNN-SNPs-Analysis-
/autoencoder_saliksyed2.py
3,184
3.515625
4
""" Deep Auto-Encoder implementation An auto-encoder works as follows: Data of dimension k is reduced to a lower dimension j using a matrix multiplication: softmax(W*x + b) = x' where W is matrix from R^k --> R^j A reconstruction matrix W' maps back from R^j --> R^k so our reconstruction function is softmax'...
b2b707338cd13a343b6ce8acbd8b26ff424cf08b
fatima-rizvi/CtCI-Solutions-6th-Edition
/Ch2_Linked_Lists/04_partition.py
932
4.3125
4
# Write code to partition a linked list around a value x, such that all nodes less than x comes before all nodes greater than or equal to x. NOTE: The partition element x can be anywhere in the "right" partition; it does not need to appear between the left and right partition from utils import LinkedList # List visua...
b926a9d71e954b1b1804a1eab5316249a0831fa4
SoniaZhu/Lintcode
/High Frequent/424. Evaluate Reverse Polish Notation [M].py
795
3.59375
4
from collections import deque class Solution: """ @param tokens: The Reverse Polish Notation @return: the value """ def evalRPN(self, tokens): # write your code here stack = [] for token in tokens: if token not in ["+", "-", "*", "/"]: stack.append...
75317124a0890798ff97ba3d79106e39757ad483
JasonEAshworth/Python_Pygame_Game
/trunk/NewBullet.py
979
3.6875
4
# Rock G Bolton + Cameron Schuette # # # # # New Bullet # #------------------------------------------------------------------------------- import math import pygame class bullet(object): def __init__(self, bulletX, bulletY, angle, damage): self.remove = False self.x = bulletX self.y = bulletY self.damage = da...
64fa4fafa08d9b580a6c9df9fcbdd0317a60b0d7
alextretyak/empireofcode.com-solutions
/Adamantite mine 2/Super Root.py
1,054
3.734375
4
import math def w0(x): # Lambert W function using Newton's method eps = 0.000000000001 # max error allowed w = x while True: ew = math.exp(w) wNew = w - (w * ew - x) / (w * ew + ew) if abs(w - wNew) <= eps: break w = wNew return w def super_root(number): return math...
a5fd0fb65394a512da5174acf46dca2d5b817ad6
sohumd96/CTCI
/Chapter1/Problem7/test_rotate_matrix.py
474
3.5625
4
from unittest import TestCase from Chapter1.Problem7.rotate_matrix import rotate_matrix class Test(TestCase): def test_rotate_matrix(self): self.assertEqual(rotate_matrix([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]), [[13,9,5,1],[14,10,6,2],[15,11,7,3],[16,12,8,4]]) se...
af5f912ccfde2e24c8d8792876a693dfce142db4
alago1/adv-code-2020
/src/day1.py
551
3.609375
4
import functools file = open('input/day1', 'r') nums = [int(x) for x in file.readlines()] def sum2_solver(vals, target): seen = set() for n in vals: if n in seen: return [n, target-n] seen.add(target - n) return False def sum3_solver(vals, target): for n in vals: ...
ebc7aea31e89e84e90c763292ef2d8e32ba3ecca
BenceBanyasz/Beadando
/10001st prime.py
323
4
4
def isPrime(n): for i in range(2,int(n**0.5)+1): if n%i==0: return False return True def stPrime(n): numberOfPrimes=0 prime=1 while numberOfPrimes<n: prime+=1 if isPrime(prime): numberOfPrimes+=1 return prime print(stPrime(10001)...
6f559ecbab95d58f6ded2fef6db0db873b0bd840
Colosimorichard/Pet-Simulator
/Pet Simulator.py
3,771
4.1875
4
# pet dictionary pet = {"name": "", "type": "", "age": 0, "hunger": 0, "toys": []} # Pet toys data object petToys = {"cat": ["scratching post", "toy mouse", "ball of yarn"], "dog": ["chew toy", "stick", "frisbee"], "fish": ["undersea castle", "fake coral", "buried treasure"]} # Prompt for different options of pet...
2f7079310394167a51e61f3126ffa9fa0437a5f2
VivaanPawar/Vivaan-Pawar-Python-
/Python.py/ATM.py
1,464
3.625
4
import time a = str(input("Type The Name Of The Card Owner By Which This Card Is Registerd\n")) if a == ("Vivaan41208"): time.sleep(2) password = 1208 pin = int(input("Enter You'r Pin\n")) balance = 10000 if pin == password: while True: print("Welcome") print("""...
f5b5a7cd4e183b736fa0bf08a9a7b163e643b745
pkoetzing/test-driven-development
/unit_testing_basics/math_functions.py
791
4.125
4
def fib(n): """ The ratio of two consecutive Fibonacci numbers tends to the golden ratio as n increases. """ a, b = 0, 1 for _ in range(n): a, b = b, a + b return a def next_collatz_element(n): """ The Collatz conjecture is a conjecture in mathematics that concerns a ...
022128d8022097a58492533bbe8ab8d7ea4bda11
KaterinaMutafova/SoftUni
/Programming Fundamentals with Python/Exams_preparation/problem3_Numbers.py
468
3.609375
4
numbers = list(map(int, input().split())) average_sum = sum(numbers) / len(numbers) top_numbers_above_average = [] counter = 0 numbers.sort(reverse = True) for num in numbers: if counter == 5: break if num > average_sum: top_numbers_above_average.append(num) counter += ...
14a15c7dbbeb64abd1104019ed0721f1085810ae
RamanMehat/Python-Labs
/Lab 4/lab_4.py
1,461
3.734375
4
""" SYSC 1005 A Fall 2013 Lab 4 Image processing examples. D.L.Bailey, SCE, Carleton University """ from Cimpl import * from Filters import * def maximize_red(img): """ Modify the photo bound to img to look like it was taken at sunset, by maximizing the red component of every pixel. """ for pixel in img...
dcfe0b6e2e50accbcf04dcd2fb8c6fd6bd77e9c1
slott56/my-euler
/euler62.py
2,946
4.1875
4
#!/usr/bin/env python3 # Cubic permutations # ================== # Problem 62 # The cube, 41063625 (:math:`345^3`), can be permuted to produce two other cubes: # 56623104 (:math:`384^3`) and 66430125 (:math:`405^3`). In fact, 41063625 is the smallest # cube which has exactly three permutations of its digits which ar...
942841eb69ad1f83934b0c5f8414f71e56116174
rbdannie/CS3423--Systems-Prog
/python/part1/datatypes.py
230
3.9375
4
#!/usr/bin/env python3 pi = 3.14 radius = 3 circumference = 2 * pi * radius # ints must be converted to strings to concatenate them msg = "c = 2 * " + str(pi) + " * " + str(radius) print(msg) print("c = " + str(circumference))
5e465a82d344c517162af3baa4154e7411a8d81d
yuzhecd/al_py
/Divide_conquer/find_repeat.py
437
3.796875
4
def find_repeat(list_a, list_b): i, j = 0, 0 while i < len(list_a) and j < len(list_b): if list_a[i] != list_b[j]: return list_a[i] if list_a[i] < list_b[j] else list_b[j] else: i += 1 j += 1 return list_a[i] if j == len(list_b) else list_b[j] if __name...
bd6552cc1abc96cc5613ec058399325ef88c6b34
RobinQi/BioUtils
/fetch_entrez_seq.py
992
3.5
4
'''Reads sequence IDs or gene names from a text file and retrieve sequences from Entrez Db. ''' import sys from Bio import Entrez, SeqIO def fetch(queries, email, db="protein", rettype="fasta", retmode="text"): for qid in queries: handle = Entrez.efetch(db=db, rettype=rettype, ...
5a60b881aa69f02b3f689147b7de89d088e5ed41
manhar336/manohar_learning_python_kesav
/Revision/for_loop.py
543
3.734375
4
for string_name in ("asj1wapi601","asj2wapi601"): conca = string_name + ".webex.com" print(conca) for tup in (10,20,30,40): print(tup) for keys in {"first":"Manohar","last":"dharmala"}: print(keys) course_offered = ['devops','aws','python'] for courses in course_offered: if courses == 'python':...
3e1a24d0c54d1ae7a6923bb5631315d344622313
mina0805/Programming-with-Python
/Python_Fundamentals/01.Python Intro/05.Numbers with Step.py
108
3.609375
4
num1 = int(input()) num2 = int(input()) step = int(input()) for i in range(num1, num2, step): print(i)
58ad7d5c54716d559ce8bba5f3343a4e2e71202c
karanadapala/foobar
/boombaby.py
882
3.671875
4
def solution(x, y): # Your code here x = int(x) y = int(y) if x==1 and y==1: return "0" if x == y: return "it would be not possible" if x ==1 or y ==1 : if x>y: return "{}".format(x-1) else: return "{}".format(y-1) else: if y%2=...
7da5de6b1714e1367fc84b300f882823b9894955
alee1412/activities
/Lesson_2_Python/Practice_1.py
246
4.03125
4
print("Hello User!") name = str(input("What is your name? ")) age = int(input("What is your age? ")) print(str(name)) print(int(age)) if(age < 21): print("Awww... you're just a baby!") else: print("Ah... A well traveled soul are ye.")
3ecfb15796e0fceb6d84e7bf18347fcf7c6c8d39
LevanBerelidze/test-py-deb
/usr/bin/test.py
286
3.5
4
#!/usr/bin/python import sys if len(sys.argv) > 1: print "We read only one argument, though you might have provided many more of them: %s" %(str(sys.argv[1])) else: print "Hello There! You can pass 1 argument from command line to me" print "The script has the name %s" %(sys.argv[0])
3c891cdfce71dfa70a672602d010ee3473c76b82
AlyoshaS/codes
/startingPoint/Inicial/01.py
177
3.703125
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Soma de a + b def main(): a = 3 b = 4 soma = a + b print ("A soma de a + b é igual a", soma) main ()
5ba0f4df613580bb4736c5946b02c1ba6449aaca
svendsentune/Advent-of-Code
/2016/day5.py
565
3.65625
4
import hashlib import string """ https://adventofcode.com/2016/day/5 """ def generatePassword(input_string): i = 0 c = 0 alphabet = string.ascii_lowercase pw_dict = {} while c < 10: hashed = hashlib.md5((input_string+str(i)).encode('utf-8')).hexdigest() if hashed[:5] == '00000' and hashed[5] not in ...
f2b689f6dee5e95c4fc11de51c4bc6eeba80bb83
tpotjj/Python
/DataStructuresAndAlgo/Recursion/capFirst.py
163
3.5625
4
def capFirst(arr): resultArr = [] for item in arr: resultArr.append(item.capitalize()) return resultArr print(capFirst(['ja', 'nee', 'test']))
561044e55e3c24344cf41e6ea1e596d58071cd5c
krisskax348/python_basics
/22.area_of_figures.py
415
3.984375
4
import math figure_type = str(input()) area = 0 if figure_type == "square": a = float(input()) area = a * a elif figure_type == "rectangle": a = float(input()) b = float(input()) area = a * b elif figure_type == "circle": r = float(input()) area = math.pi * r**2 elif figure_type == "triang...
65b4cd53aa9125ab9893678556886d0417360413
manoznp/LearnPython-Challenge
/DAY1/rangesum.py
509
4.09375
4
lower = int(input('Enter Lower Value: ')) #4 upper = int(input('Enter Upper Value: '))#7 sum = 0 for i in range(lower, upper + 1): sum = sum + i print("The total sum is{}".format(sum)) if sum%2 == 0: print("This number is EVEN") else: print("This number is ODD") if sum > 1: for i in range(2, sum): ...
92fda620defff3a5eebaf219723c81818012b08b
blafuente/unit1immersive-11-18-BL
/week1/dictionaryExercises.py
1,354
4.21875
4
#Dictionary Exercises #Exercise 1 phonebook_dict = { 'Alice': '703-493-1834', 'Bob': '857-384-1234', 'Elizabeth': '484-584-2923' } # Printing Elizabeth's number print phonebook_dict['Elizabeth'] # Add Kareem's number to phonebook dictionary phonebook_dict.update({'Kareem': '938-489-1234'}) print phonebook...
5c454c19511333975e97557a599aec1b5e216a28
paolo-26/Programming-for-IoT-Applications
/lab3/lab3_es1.py
1,494
3.875
4
#!/usr/bin/env python3 """ @author = Paolo Grasso Run 'calculator.py' in order to use this script. """ import json import requests OP = ' - add\n - sub\n - mul\n - div' INP = '\n > ' class Application(object): def __init__(self): self.run() def run(self): while True: inp = inpu...
b8e6f7299553d12c6b1833771220fdb4a72639b6
Afantor/ESP8266-MicorPython
/tutorial_src/Basic/irq.py
942
3.53125
4
#hardware platform: FireBeetle-ESP8266 import machine from machine import Pin import time value=1 counter=0 def func(v): global value,counter time.sleep_ms(50) if(button.value() == 0): return while(button.value() == 1): #If press the button, it will wait until released time.sleep_m...