blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
b8425ef8448badbcfd0fb88c43708040d870d1df
AUGUSTO664/10exercises-C-Python-
/exercise2.py
672
4.21875
4
# given a list of strings delete all special chars in each one #non alphanumeric chars #this code is a variation of a code found in #http://www.openbookproject.net/thinkcs/archive/python/spanish2e/cap07.html #this function delete non alpha numeric chars in a word def delete_nonalpha(s): non_alpha = "!#$&/(){}[]+*%...
5fb32f1da6f2bca132a0ec3fac6d07b9d793e3bf
rangarajanps/projectEuler
/python/problem9.py
387
3.515625
4
import math def findSpecialPythagoreanTriplet(limit): for a in range(1,(limit//2)+1): for b in range(a+1,limit//2): c = math.sqrt(a*a+b*b) if c.is_integer(): c = int(c) //print(a, b, c, (a + b + c)) if a+b+c == limit: return a*b*c if ...
c38a211f2ee11a00d2aec7f047f34e694fd47135
bridgette/Python100
/mystery_cipher/substitution_cipher.py
1,413
3.625
4
# -*- coding: utf-8 -*- """ Created on Fri Feb 05 10:12:34 2016 @author: breiche """ import unittest class SubstitutionCipher(object): ''' A general substitution cipher, where every letter can match to any other letter. Can accept guesses, a map with key = encoded char; value = decoded char. ...
816d0fe9a857ba58cc44d7139f916b88f60f5ec3
zuigehulu/AID1811
/pbase/day11/code/mpa_text2.py
130
3.84375
4
def pow2(x,y=2): return x**y sum1 = 0 for x in map(pow2,range(1,10)): print(x,end = " ") sum1 += x print() print(sum1)
5b7dc8486110a6b4611dfbd9042a27b78e10948c
mehul-choksi/contextual-ads
/contextual_ads/conceptHierarchy/tree.py
2,983
3.53125
4
""" # TODO: Fix: - treeToJSON """ import collections class Node(): def __init__(self, name='', parent='', children=set(), confidence=None): self.name = name self.parent = parent self.children = children self.confidence = confidence self.synonyms = dict(...
333e3fbe3b156e068a7d5ca72a76a88482191b80
adilsonLuz/OficinaPython
/O2-Ativ-31.py
998
3.65625
4
def palavras_arquivo(arquivo): dic_palavras = { } try: with open(arquivo, 'r') as arq: for linha in arq: #print("\n",linha) frase = linha.split() #print("Split") #print(frase) for palavra in frase: ...
a1350fe6807de10705215ab6b7bc1f618e32517e
devqhuy/Python
/scratch_13.py
232
3.609375
4
if __name__ == '__main__': n = input() a =list(map(int,input().split())) for k in range (3): b=list(filter(lambda x:x%3==k,a)) if b: print(min(b),max(b)) else: print("Khong co so nao chia 3 du",k)
5c03cfd56330ba9bc290de14adb2379d8640f524
songtoan0201/algorithm
/leetCode/threeSum.py
495
3.921875
4
def threeSum(nums): """ :type nums: List[int] :type target: int :rtype: List[int] """ myDict = {} arr2D = [[]] for i in range(len(nums)): for j in range(1, len(nums)): #print(nums[i]) print("i is", i) print("j is", j) if nums[j] in ...
914533d7d3dc02addf4231faad04ca1e57c58819
dashboardijo/run-file
/mm.py
225
3.59375
4
def html(a,b,c): import math if a+b<=c or c+b<=a or a+c<=b: print('三边不能构成三角形') return else: x = (a+b+c)/2 s = math.sqrt(x*(x-a)*(x-b)*(x-c)) return s
9c793ab0258bcd2d2c41e2db39496dec029e5a63
anjaligr05/TechInterviews
/review/arrays/minimumSubarray.py
563
3.6875
4
def minimumSubarray(arr, s): st = 0 curSum = 0 minLen = len(arr)+1 minlen = '' print arr, 'sum>=s: ', s for i in range(len(arr)): curSum += arr[i] if arr[i]>=s: print arr[st:i+1] return 1 if curSum>=s: while curSum-arr[st]>=s: curSum-=arr[st] st+=1 if i-st+1<minLen: minLen = i-st+1 ...
f2c675be143ab97c6854e846fb5b9eaa46dfe851
GlitchHopper/AdventOfCode2019
/AoC_2019_Day1/AoC_2019_Day1_Part1&2.py
901
3.546875
4
import math def GetBaseFuel(mass): return math.floor(int(mass) / 3) - 2 def GetAdjustedFuel(mass): fuelMass = GetBaseFuel(mass) totalAdjusted = fuelMass #sumStr = str(fuelMass) while GetBaseFuel(fuelMass) > 0: fuelMass = GetBaseFuel(fuelMass) totalAdjusted += fuelMass #sumS...
49686b45ccaa9ccb1e8ddcc60006092dc72b6dbb
namratarane20/python
/algorithm/mergesort.py
317
3.96875
4
#this program is used to do the sorting of values by merge sort from util import utility try: lst = [int(x) for x in input("enter the number with space ").split()] print(utility.merge_sort(lst)) # calls the method nad prints the output except ValueError: print("ENTER THE INT VALUES")
d883227121f760aba3648cb8643b7e6484148880
janealdash/T2.15
/task2.15.py
419
4.09375
4
# Write the code, which will print numbers from 0 till your age. And if your age # is odd, will be printed all odd numbers till your age, if even all even numbers. age = int(input('Enter your age: ')) lon = [] if age % 2 == 1: for i in range(1, age+1): if i % 2 == 1: lon.append(i) elif age %...
f9f68defad7243d4174780ae4aac0a0b245a041d
HBinhCT/Q-project
/hackerrank/Data Structures/Insert a node at a specific position in a linked list/test.py
1,384
3.5625
4
import unittest import solution class TestQ(unittest.TestCase): def test_case_0(self): inputs = [16, 13, 7] outputs = [16, 13, 1, 7] linked_list = solution.SinglyLinkedList() for item in inputs: linked_list.insert_node(item) node = solution.insertNodeAtPosition...
614eb9afaf224895bea0c99f84807b16c73d5a7b
hyun031916/python-study
/Quiz/전화번호.py
897
3.515625
4
def phonenumber_to_region(phone): phone_numbers = {"02": "서울", "051": "부산", "053": "대구", "032" : "인천", "062": "광주", "042": "대전", "052": "울산", "044": "세종", "031": "경기", "033": "강원", "043": "충북", "041": "충남", "063": "전북", "061": "전남", "054": "경북", "055":...
c5989fb562387f2614f4e9593a318f9faa2f7b48
phamtheanh95/Sentiment-Analysis
/baseline_model.py
5,304
3.5625
4
# Satisfaction scores range from 0 to 10. I have the data of the patients' demographic information and their comment left on healthcare record. # The classification problem would then be based on features extracted from numerical and textual data. # Import necessary packages import numpy as np import pandas as pd fr...
9f0824a60e56ac49841607ff78c75a797d82b1fc
rafaeljimenez01/advanced-algorithms-class
/act3-3/main.py
3,333
3.75
4
from os import read ''' 0/1 Knapsack solution using dp Advanced algorithms class Authors: Rafael Jimenez A01637850 Joshua Hernandez A01246538 ''' # INPUT: # - elements: the possible elements to be added to the knapsack in format [value, weight] # - knapsack_cap: int, max weight available # OUTPUT: # - sol...
2774e2dfe70ecb4696463f2aae0f542de3a02933
alxmirandap/Coding
/ProgrammingPraxis/SumXor.py
6,680
3.84375
4
import sys import time # Sum and Xor: # Assume there are two positive integers a and b that have sum s and XOR x. # Given an s on the range [2, 1012] and x on the range [0, 1012], # find a list of possible values of the ordered pairs (a, b). For instance, # given s = 9 and x = 5, there are four possible pairs: #...
1580575d1b113573263dc111062790d8cb617f95
shantanusl15150/Hackerrank-Solutions-in-Python
/funny string hackerrank
627
3.71875
4
#!/bin/python3 import math import os import random import re import sys # Complete the funnyString function below. def funnyString(s): result = [ord(i) for i in s] new_result = result[::-1] for i in range(len(result) - 1): if abs(result[i + 1] - result[i]) != abs(new_result[i + 1] - new_result[i])...
6b74fa2badd24e0fb54667cb373d4ad0bbef8803
L200180212/Prak_algostruk
/MODUL_1/nomer12.py
497
3.671875
4
import random def tebakAngka(): a = random.randrange(1,101,1) b = -1 n = 0 print ("Permainan Tebak Angka") print ("Saya Menyimpan sebuah Angka Bulat antara 1 sampai 100. Coba Tebak.") while a != b : n = n + 1 b = int (input ("Masukkan Tebakan ke- " + str(n) + ":> ")) if b...
c3fafc20e88f180ce4e7f69e194deaf37c8a64b5
HafrizDjzulkiman88/CoinChange
/Coin Changing Brute Force.py
688
3.65625
4
#!/usr/bin/env python # coding: utf-8 # In[4]: from __future__ import print_function import sys import time # In[5]: def coinChange(coin, amount) : koin = len(coin) if (amount == 0) : return 0 result = 1000 for coins in coin: if (coins <= amount) : result = min(result, ...
6eb80d66cf45aa465d6114e660d4e5357019a3fa
cale-i/atcoder
/AtCoder/ARC068/C - X Yet Another Die Game.py
107
3.5625
4
# 2019/08/11 x=int(input()) ans=(x//11)*2 if x%11>6: ans+=2 elif x%11>0: ans+=1 print(ans)
270095ccf833044617a3972ddfd6649f741ea539
lsn199603/leetcode
/37-快速排序.py
1,391
4.25
4
""" 快速排序 快速排序(Quick Sort)是一种效率很高的排序算法,是对冒泡排序的一种改进排序算法。 1. 从待排序列表中选取一个基准数据(通常选取第一个数据)。 2. 将待排序列表中所有比基准数据小的元素都放到基准数据左边,所有比基准数据大的元素都放到基准数据右边(升序排列,降序反之)。用基准数据进行分割操作后,基准数据的位置就是它最终排序完成的位置,第一轮排序完成。 3. 递归地对左右两个部分的数据进行快速排序。即在每个子列表中,选取基准,分割数据。直到被分割的数据只有一个或零个时,列表排序完成。 快速排序的时间复杂度为 O(n^2) 。 快速排序是一种不稳定的排序算法 """ def quick_sort(array...
ae68e6d57c9af698ab929bb28386de0c0ff29b5d
sasikrishna/python-programs
/com/algos/sortings/BubbleSort.py
341
4.21875
4
def bubble_sort(array): for i in range(len(array)): for j in range(i + 1, len(array)): if array[i] > array[j]: temp = array[j] array[j] = array[i] array[i] = temp return array if __name__ == '__main__': array = bubble_sort([15, 7, 8, ...
a6fc50e15fe88302c3df7f14bedf0e086b14ec0d
harmansehmbi/Project4
/practice4f.py
194
3.765625
4
# Built-Ins on Strings name = "Fionna Flynn" name.upper() print(name) # Strings are Immutable # Whenever we perform any modification operation on String we got to know thant srtings are IMMUTABLE
a7a57c6f41528d0f61321f4853c80d078c3dcd70
AEC-Tech/Python-Programming
/airline.py
381
3.8125
4
n=int(input("How many direct flights are there ")) flight=[] for i in range(n): source=int(input("Enter the source city number ")) dest=int(input("Enter the destination city number ")) flight.append((source,dest)) print(flight) onehop=[] for x in flight: for y in flight: if x[1]==y...
f508f597150b30cac529a52b9efb3edff87086f6
Rellikiox/pymap
/geometry.py
4,480
3.578125
4
import math class Point: def __init__(self, x, y): self.x = x self.y = y def scaled(self, scale): return Point(self.x * scale, self.y * scale) def int(self): return Point(int(self.x), int(self.y)) def tuple(self): return (self.x, self.y) ...
c88af534baf5afee78855375470b44cf6e723e26
feiooo/games-puzzles-algorithms
/simple/life/life-asn1.py
10,051
3.5625
4
#!/usr/bin/env python3 from paint import paint import sys from time import sleep import numpy as np """ # Sample format to answer pattern questions # assuming the pattern would be frag0: ..* **. .** ############################################# # Reread the instructions for assignment 1: make sure # that you have the ...
149564190c12b5666aed5474dd47835ab051cfdc
JeromeLefebvre/ProjectEuler
/Python/Problem122.py
872
3.5625
4
''' http://projecteuler.net/problem=122 Efficient exponentiation Problem 122 ''' ''' Notes on problem 122(): ''' def problem122(): m = {} seen = set() def gen(current, maximum): if maximum > 200: return if current in seen: return if maximum not in m: ...
66e0f16554c6745dcb8f7ad86cf37e01535ccec9
RightArmFast/LinkedList
/SinglyLinkedList.py
2,749
3.921875
4
# simple Linked List class with basic CRUD operations class Node: def __init__(self, value=None, next=None): self.value = value self.next = None class SinglyLinkedList: def __init__(self): self.head = None def prepend(self, value): newNode = Node(value) if self.hea...
7da9d2500497c18b0b43020141aa132ff86a6c85
beade88/ejercicios_python_principiantes
/ej14.py
661
4.1875
4
""" Exercise 14 Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates... """ # This function returns a list that contains the elements of the initial list but without duplicates elements. def list_without_duplicates(list_to_anal...
dbf3275c1abac7350ba2639c8fc43a41fae99ac2
askhmar/misc_alg
/6-1.py
597
3.78125
4
import random arr=[] while 1>0: n=int(input("Input size of arr bigger 6 ")) if n>6: break else: print('Error of input ') for i in range(n): arr.append(random.randint(1,10)) print arr while 1>0: k1=int(input("Input k1 ")) k2=int(input("Input k2 ")) if (k1...
aba84c9511690da8b757be97ef052c1019077eb2
sudhal/Docs
/Removing_duplicates.py
145
3.671875
4
# Removing duplicate items form a list l=[1,2,4,5,7,4,2,5,2,6,7,8,9,4] s=[] for i in l: if i not in s: print i s.append(i) print s
4d7073048dad3da03c35bf3201b672268620fb56
Anik2069/DataCamp
/Intermediate Course/datacamp_numpy.py
3,176
3.734375
4
# Pre-defined lists names = ['United States', 'Australia', 'Japan', 'India', 'Russia', 'Morocco', 'Egypt'] dr = [True, False, False, False, True, True, True] cpc = [809, 731, 588, 18, 200, 70, 45] # Import pandas as pd import pandas as pd # Create dictionary my_dict with three key:value pairs: my_dict my_dict={ ...
7336bc902627d57613fb3b3cd1f658a6318133c8
lemonase/programming-challenges
/project-euler/06/06.py
774
3.953125
4
#! /usr/bin/env python3 # The sum of the squares of the first ten natural numbers is, # 1^2 + 2^2 + ... + 10^2 = 385 # The square of the sum of the first ten natural numbers is, # # (1 + 2 + ... + 10)^2 = 55^2 = 3025 # Hence the difference between the sum of the squares of the first ten natural numbers and the square ...
7e3bc592778d9aa9c6bd62bdb2add910670cae53
galbwe/csv_parser
/main.py
554
3.59375
4
import argparse import sys from csv_parser import parse parser = argparse.ArgumentParser(description="Parse a csv to Python.") parser.add_argument('input') parser.add_argument('--file', action="count") parser.add_argument('--output') args = parser.parse_args() if args.file: with open(args.input, 'r', encoding...
02cf7482964a2d8a1fd15faa80a2d01c40b8a344
velasciraptor/Election-Analysis
/Python_practice.py
3,201
4.5
4
print("Hello World!") # What is the score? score = int(input("What is your test score? ")) # 3.2.8 Determine the grade. if score >= 90: print('Your grade is an A.') elif score >= 80: print('Your grade is a B.') elif score >= 70: print('Your grade is a C.') elif score >= 60: print('Your grade is a D.')...
dad4624a9dda23fd1b4febf65e7e051ae9a5311c
Cbkhare/Challenges
/CodeForces_A_Robot_Seq.py
1,625
3.71875
4
if __name__=='__main__': n = int(input()) d = input() count = 0 i=0 while i <=len(d)-2: hori,veri =0,0 if d[i] in ['U','D']: if d[i]=='U': veri+=1 else: veri-=1 elif d[i] in ['L','R']: if d[i]=='R': hori+=1 else:...
cf3d6225aeb522d3f16cb1676f69993c02e751cd
Slackar/COMP2101
/PythonWork/L5C3.py
539
3.609375
4
import random def funcOne(inOne,inTwo): randNum = random.randint(1, (len(inOne) + len(inTwo))) print (inOne, inTwo, sep='---') return randNum def funcTwo(): for i in range(6): print ('Zz') for z in range(10000000): continue def funcThree(argOne,argTwo,argThree): for cN...
57592b7d23d1a735084e42c2500a1ead79a60e71
dotmons/Python
/MongoDB/Mongo_Db_Datacamp.py
923
3.546875
4
# -*- coding: utf-8 -*- """ Created on Wed May 6 09:04:19 2020 @author: Dotmons """ from pymongo import MongoClient record = MongoClient('mongodb://localhost:27017')["datacampdb"].articles article = {'author': 'Adeoye Oludotun', 'about': 'Introduction to MongoDB and Python', 'tags': ['mongod...
73a72008a04370c45534ed752ca7214cc938a951
teobouvard/study
/4-UiS/data-mining/assignment2/metrics.py
422
3.5
4
import numpy as np def RMSE(x, y): distance = (x - y) ** 2 return np.sqrt(distance.mean()) if distance.size > 0 else 0 def log_RMSE(x, y): return np.sqrt(((np.log(x) - np.log(y)) ** 2).mean()) if __name__ == "__main__": y_true = np.array([3, -0.5, 2, 7]) y_pred = np.array([2.5, 0.0, 2, 8]) ...
3ac8a67cfdfe9dd1ad1fbdc21b7be9ebb0c9f5b2
lost-person/Leetcode
/382.链表随机节点.py
987
3.5625
4
# # @lc app=leetcode.cn id=382 lang=python3 # # [382] 链表随机节点 # # @lc code=start # Definition for singly-linked list. import random class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def __init__(self, head: ListNode): """ @...
72c69a6d1067cb6178a8403b7467d381ada73091
Gafanhoto742/Python-3
/Python (3)/Ex_finalizados/ex059.py
1,305
4.3125
4
'''Crie um programa que leia dois valores e mostre um menu na tela: [ 1 ] somar [ 2 ] multiplicar [ 3 ] maior [ 4 ] novos números [ 5 ] sair do programa Seu programa deverá realizar a operação solicitada em cada caso. ''' from time import sleep num1 = int(input('Digite o 1º valor: ')) num2 = int(input('Digite o 2º val...
54398f9ffb92228b89e18e91f4d765d2bcd1bbe3
zilunzhang/puzzles
/puzzles-BFS-DFS/puzzle_tools.py
5,106
3.921875
4
""" Some functions for working with puzzles """ from puzzle import Puzzle # set higher recursion limit # which is needed in PuzzleNode.__str__ # uncomment the next two lines on a unix platform, say CDF # import resource # resource.setrlimit(resource.RLIMIT_STACK, (2**29, -1)) import sys sys.setrecursionlimit(10**6) d...
7790fd5c5d5a0c3d631427a32dd6d81191801311
littleyellowbicycle/DailyPython
/PracticePython/SensitiveWords.py
253
3.75
4
import io file = open("words.txt", "r", encoding="utf-8") wordlist = file.readlines() while (True): stdin = input() if (stdin in wordlist): print("freedom") elif (stdin == "exit"): break else: print("manrights")
fee528381505c21bc999cedb47b6d736d2eb2d63
Timothy-py/100-PythonChallenges
/Q10.py
465
4.25
4
# A program that accepts a sequence of whitespace separated words as input and # prints the words after removing all duplicate words and sorting them alphanumerically. prompt = input('Enter text strings here: ') parsed_text = [word for word in sorted(prompt.split(' '))] parsed_word = [] for word in parsed_text: if ...
df708195240a12bbc0acce319144f99f6cb0f656
vvspearlvvs/CodingTest
/2.프로그래머스lv1/핸드폰번호 가리기/solution.py
200
3.625
4
def solution(phone_number): answer = '' num = (len(phone_number)-4) *'*' back = phone_number[-4:] answer = num + back return answer print(solution("01033334444")) #"*******4444"
f536f5efe0ea108e0599d34b84c7720d55d5b578
jrakula/Python-For-Everyone-Book-Solutions
/ch-07_ex-01.py
655
4.5
4
## Write a program to read through a file and print the contents ##of the file (line by line) all in upper case. Executing the program will ##look as follows: ##python shout.py ##Enter a file name: mbox-short.txt ##FROM STEPHEN.MARQUARD@UCT.AC.ZA SAT JAN 5 09:14:16 2008 ##RETURN-PATH: <POSTMASTER@COLLAB.SAKAIPROJ...
6b74562659ef0df6455ce26d747727d2575bb250
tim-low/CZ1003-Introduction-to-Computational-Thinking
/Study - IntroComp Quiz 8 Nov/0. code test/ITCT Written Quiz/Questions/4. 16 Questions (short).py
1,710
4
4
# -*- coding: utf-8 -*- """ Created on Sun Nov 4 10:55:28 2018 @author: Tim """ #0: Print all x**2 for 1-100 if x**2 is divisible by 3 #1: Recursion: Get nth Fibonacci Number #2: Reverser: take a string and reverse it #3: Complete Binary Tree (CBT): Represent a Binary Tree #4: Number of Nodes: Takes a Tr...
441d9a7116f32ab69f289318e3251d2456efc01a
max397574/Codewars
/FindMissingTermProgression.py
283
3.59375
4
#https://www.codewars.com/katadef find_missing(sequence:list): def find_missing(sequence:list): step=int((sequence[len(sequence)-1]-sequence[0])/len(sequence)) for k in range(1,len(sequence)): if sequence[k]-sequence[k-1]!=step: return sequence[k-1]+step
382c931a9d1fa4c1309c180e539105a54f33a9d3
SurajPatil314/Leetcode-problems
/Linkedlist_deepCopy.py
1,220
3.53125
4
""" https://leetcode.com/problems/copy-list-with-random-pointer/ # Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random """ class Solution: def copyRandomList(self, head: 'No...
56d71b1d5670c64832ff493b5faad136ef281c97
sonalisaraswat/My-Programs
/code_chef_programs/Beginner/Mahasena.py
238
3.578125
4
t=int(input()) even=odd=0 a=[int(j) for j in input().split()] for i in range(t): if a[i]%2==0: even+=1 else: odd+=1 if even>odd: print("READY FOR BATTLE") else: print("NOT READY")
a60a353aa7b01e369e8a7941670791a0b7898a3c
trangthnguyen/PythonStudy
/rootpwr.py
608
4.53125
5
#!/usr/bin/env python3 #Write a program that asks the user to enter an integer and #prints two integers, root and pwr, such that 0 < pwr < 6 and root**pwr is equal #to the integer entered by the user. If no such pair of integers exists, it should #print a message to that effect. x = int(input('Input an integer:')) root...
d3b7d2644ec6ec376399b67eb05dae98af8468c5
Onyiee/DeitelExercisesInPython
/days_of_christmas.py
1,138
4
4
part_of_verse = "day of christmas, my true love sent to me, " first_part = "On the " days = { 1: "first", 2: "second", 3: "third", 4: "fourth", 5: "fifth", 6: "sixth", 7: "seventh", 8: "eight", 9: "ninth", 10: "tenth", 11: "eleventh", 12: "twelfth" } verses = { 1: "a...
ed338f08ef89fe7d9bde6f4f3d3335800eecbe89
Bautronis/Python
/ex13.py
448
3.65625
4
from sys import argv script, car, food, country = argv car = raw_input("What is your favorite color? ") food = raw_input("What is your favorite number? ") country = raw_input("What is your favorite shape? ") print(""" This program is called {script} and it's going to ask you some questions about your favourite thing...
10dc35bd172f9e1e6fa189efece0f14d4264bb68
gnublet/py_explorations
/general/learnpythonthemediumway/ex15.py
730
4.21875
4
#import the argv method of the sys library from sys import argv #first parameter is argv[0] which contains the script name #second parameter is argv[1] which contains the file name script, filename = argv #just printing for instructional purposes #print(script,filename) #print(argv) #print(argv[0],argv[1]) #open the ...
3960a275f66a1b2fa3468d76cf4fd55175a59886
MaayanLab/gen3va
/gen3va/heat_map_factory/filters.py
2,039
3.734375
4
"""Utility functions for filtering hierarchical clusterings. """ import numpy MAX_NUM_ROWS = 1000 def filter_rows_by_non_empty_until(df, max_=MAX_NUM_ROWS): """Removes all rows with mostly zeros until the number of rows reaches a provided max number. """ print('Starting shape: %s' % str(df.shape)) ...
24d8871399bc0a9075c0e345dea9d812fb734a64
yinhuax/leet_code
/datastructure/acwing_study/base_01/base_sort/QuickSort.py
1,523
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : Mike # @Contact : 597290963@qq.com # @Time : 2021/7/4 20:58 # @File : QuickSort.py class QuickSort(object): def __init__(self): pass def quick_sort(self, q, l, r): if l >= r: return x = arr[r] i = l ...
0328d4babcf33a4bf39a9206e33fa5cce950c7c2
aahevolution/Python
/list.py
547
4.03125
4
# python debugger import pdb ''' pdb allows a program to pause and give coder chance to run and inspect the instructions throughout the code ''' my_list = list(map(int, input('Enter a list of integers: ').split())) for element in my_list: sum = 0 sum += element pdb.set_trace() # adds a break-point print...
2da183dd2b32617f7524473eb1bd9855b0807975
NikithaChandrashekar/computerTime
/removefiles.py
304
3.859375
4
import time import os import shutil def getComputerTime(): t=time.localtime() currentTime=time.stfrtime("%H:%M:%S" , t) print(currentTime) question=input("wanna know the exact time of ur computer?") if(question=="yes"): print("Yay!ok so let me show you the time!") getComputerTime()
9e591ab5ca9fb45bd310d704a254ee917a5ecc6e
cristinamais/exercicios_python
/Exercicios Variaveis e tipos de dados/exercicio 49.py
1,151
4.21875
4
""" 49 - Faça um programa que leia o horário (hora, minuto, segundo) de início de uma experiência biológica. O programa deve resultar com um novo horário (hora, minuto e segundo) do termino da mesma. """ from datetime import datetime, date from time import sleep start = datetime.now() print(f"Início de uma experiênci...
4ddb2edadc51a0bd51c8ad255188eb32fcf4365e
curso-telmex-hub/robots_procedural
/posiciones.py
1,476
3.703125
4
# archivo que tiene funciones para pintar la posicion de un robot car_rep_primero = "-" car_rep_ultimo = "-" car_rep_relleno = " " car_rep_posicion = "*" def pinta_simple (maximo_x, caracter): print ("|%s|" % (caracter * (maximo_x - 2))) def pinta_primero (maximo_x): pinta_simple (maximo_x, car_rep_primero) ...
f374df30f162e484ee3697eb9ca703a3dfdad0ee
JamCrumpet/Lesson-notes
/Lesson 4 if statements/4.9_checking_whether_value_is_not_in_list.py
262
3.71875
4
# it is important to know if a value is not in a list # you use the keyword not in this situation banned_users = ["andrew", "carolina", "david"] user = "zoey" if user not in banned_users: print(user.title() + ", you can post a response if you wish")
2ad3ac7bcdbdbd440404584847c341675f4f7276
jizefeng0810/leetcode
/区间问题/56-合并区间.py
793
3.8125
4
class Solution: """ 给你一个区间列表,合并所有重叠的区间。 """ def merge(self, intervals) -> int: intervals.sort() res = [] left, right = intervals[0] for i_left, i_right in intervals[1:]: if right >= i_left: if right <= i_right: right = i...
5b1a3083b24cb4ed4a214d4b24e4dcd67879b048
ks-99/forsk2019
/week4/day2/bluegills.py
1,862
4.03125
4
""" Q. (Create a program that fulfills the following specification.) bluegills.csv How is the length of a bluegill fish related to its age? In 1981, n = 78 bluegills were randomly sampled from Lake Mary in Minnesota. The researchers (Cook and Weisberg, 1999) measured and recorded the following data (Import bluegills...
fc676e9206ef2a310f78c47d78026130656cec1c
niverton-felipe/URI_PYTHON
/1005.py
125
3.515625
4
nota1 = float(input()) nota2 = float(input()) media = (nota1 * 3.5 + nota2 * 7.5) / 11 print('MEDIA = {0:.5f}'.format(media))
5f490466473f1bc405bdab33f4bae793baa55cac
marcusiq/w_python
/PythonReview2.py
5,839
4.3125
4
import time import random print "EXERCISES Part 2 of Review - Loops!" print "You can learn more about loops here: http://www.learnpython.org/en/Loops" # Part B: For loops. # EXERCISES for Part 2 # 1. Print out this sequence, using a for loop and the range method. # You can get more help on range() with the command...
48bfe37fe2364bab87a4860b70d53295e53e2eab
MatheusOldAccount/Exerc-cios-de-Python-do-Curso-em-Video
/exercicios/ex026.py
287
4
4
frase = input('Digite uma frase: ') print('Aparecem {} veses a letra "A"'.format(frase.count('A'))) print('A letra A aparece a primeira vez na posição de índice {}'.format(frase.find('A'))) print('A letra A aparece a última vez na posição de índice {}'.format(frase.rfind('A')))
a00a612333cbbdb2c98287337578068940b5ccb5
kongzichixiangjiao/GAFile
/开发相关/Python/Basic/basic/04.number(数字).py
2,036
3.8125
4
import math number = 0xA0F # 十六进制 print(number) # 2575 number = 0o37 # 八进制 print(number) # 31 number = 10 print(float(number)) # 10.0 print(int(number)) # 10 print(complex(number)) # (10+0j) # 将 x 和 y 转换到一个复数,实数部分为 x,虚数部分为 y print(complex(number, 3)) # (10+3j) # 数学函数 ''' abs(x) 绝对值 ceil(x) 向上取整 floor(x) ...
b38d52e6ee230fada018ab8002b00706aaebcc81
malcolmmacleod/AutomateBoringStuff
/file1.py
2,912
3.65625
4
>>> import os >>> os.path.join('folder1', 'folder2', 'folder3', 'file.txt') 'folder1/folder2/folder3/file.txt' >>> os.sep '/' >>> os.getcwd() '/Users/malcolmmacleod/Documents/Developer/python/AutomateBoringStuff' >>> os.chdir('/Users/malcolmmacleod/Documents/Developer/') >>> os.getcwd() '/Users/malcolmmacleod/Documents...
090edde7a0af4dadef5cab8cf8fd32980b1574c7
MMVonnSeek/Hacktoberfest-2021
/Python-Programs/Largest_Num_Finder.py
330
4.375
4
# Largest_Num_Finder a = float(input("enter the first number")) b = float(input("enter the second number")) c = float(input("enter the third number")) if a > b and a > c: largest = a elif b > a and b > c: largest = b elif c > a and c > b: largest = c else: largest = "none" print("The largest number is",...
53d3b2c2eca50c30ec95981029e74973e141bbfb
jaycarson/Portfolio
/scripting_languages/Python_2_7/Eulers/Euler001.py
1,319
4.3125
4
#!/usr/bin/python import argparse class Euler001(object): """ Euler001 - This script is to solve the following Euler Problem: 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 o...
c54b061f9ac868f0c4421b4c2af03b3d0e48c97b
Javierggonzalvez/cursos
/Curso_python_twitter/twitter/tweets/pedir.py
355
3.78125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- #MODULO para uso de twitter def pedirtweet(usuario): tweet = None likes = 0 retweets = 0 tweet = input("Que esta pasando? ") likes =int(input("Cuantos likes? ")) retweets = int(input("Cuantos retweets ")) infotweet ={"Autor":usuario, "Mensaje":tweet, "Likes":likes, "Re...
ca4202410dc7310bdfc2356de51d7f3c4cfd9fbd
medyahan/NTP_Server_and_Client
/functions.py
612
3.96875
4
def textToDecimal(text): # Function that converts a text message to decimal list = [] new = [] for i in text: list.append(format(ord(i))) for j in list: if (len(j) == 2): new.append("0") new.append(j) else: new.append(j) return ''.join(new...
1f77b7bc29608040701455eb89776a4e21f7c575
HaroldCC/Pythonlearing
/第六章.py
3,637
3.859375
4
# 6-1 ''' friends = { 'friend_name':'san', 'last_name':'zahng', 'age':13, 'city':'shang hai', } print(friends['friend_name']) print(friends['last_name']) print(friends['age']) print(friends['city']) ''' # 6-2 ''' like_numbers = { 'zhang':15, 'li':20, 'zhao':16, 'cheng':40, 'wang':8, } print("zhang:"+str(like_n...
262cf03cd7f551af099dbc30afc24481b10b7977
TrellixVulnTeam/HelloPython_244B
/venv/src/Python100days/day3_12_19/person.py
891
3.875
4
class Person(object): def __init__(self,name,age): self._name=name self._age=age @property def name(self): return self._name @property def age(self): return self._age @age.setter def age(self,age): self._age=age @name.setter def name(self,nam...
f78245486d82c9724ade8976da7d3ee774959b6d
efnine/learningPython
/python_crash_course/10_files_and_exceptions/10_files_and_exceptions.py
1,748
4.4375
4
""" The keyword 'with' below closes the file once access to it is no longer needed. Notice how we call open() in this program but not close(). You could open and close the file by calling open() and close(), but if a bug in your program prevents the close() statement from being executed, the file may never clo...
eb584263667ac7575743c6b68e90be79a6d11990
HuynhLoc19/Practice_Git_GitHub
/Bai_081.py
366
3.515625
4
from random import randrange def Tao_List(lst, n): for i in range(n): lst.append(randrange(1950, 3000)) return lst def Dau(lst): for elem in lst: if elem>2005: return elem return 0 lst = [] n = int(input('Nhập số lượng phần tử của list: ')) print('List đc tạo là: ', Tao_L...
2edf2a7c50b26204da983e835918eab57884afdd
shankar7791/MI-10-DevOps
/Personel/Chandrakar/Python/Practice/23feb/while1.py
80
4
4
num=int(input("enter the number: ")) i=2 while i<=num: print (i), i=i+2
edb9dccf04443ff5c38694de85b8d63d5277cabd
NathanaelLeclercq/VSA-literate-waddlee
/scratches/scratch_2.py
305
3.8125
4
def myfunction(): print "I called My function" myfunction() def largest(x,y): ans = x if y > x: return ans largenum = largest(2,5) print largenum def getnum(prompt): ans = int(raw_input(prompt)) age = getnum("what is you age?") grade = getnum("what is your grade?")
dc7fcaa4fd37d729f0134790a8f709ca04aed341
rishav-1570/gcc-2021
/CodingChallenge2021/gcc-2021-rishav-1570/Question4/Question4.py
232
3.515625
4
def totalPairs(n, values): # Participants code will be here return -1 if __name__ == "__main__": n = int(input()) values = list(map(int, input().split())) answer = totalPairs(n, values) print(answer)
dc780dc9f6471911ae10ecf6dc01f76c82cee442
ebsbfish4/classes_lectures_videos_etc
/video_series/sentdex_python3_basic/python_files/while_loop.py
229
3.828125
4
#! python3 import time # Added sleep condition = 1 while condition < 10: print(condition) condition += 1 time.sleep(2) # This will create infinite loop. Also use with __main__? while True: print('doing stuff')
4b9be6e19a3f618cb6b73abb414b8a545124c0da
SatyamJindal/Competitive-Programming
/codeforces/Romaji.py
256
3.5625
4
vow=['a','e','i','o','u'] s=input() flag=0 for i in range(len(s)-1): if(s[i] not in vow and s[i]!='n' and s[i+1] not in vow): flag=1 break if(s[-1]!='n' and s[-1] not in vow): flag=1 if(flag): print('NO') else: print('YES')
81258f6070b0c5c151d491a8ed8a96a950dbf4f5
zlang19/projectEulerPython
/1/9.py
245
3.640625
4
from math import sqrt from math import floor for a in range(1, 500): for b in range(a, 500): c = sqrt(a * a + b * b) if c == floor(c): if a + b + c == 1000: print(a * b * c) break
463519052319764707667817ef3d7f1c46a71ebc
Dharshisenthil/python-program
/pro30.py
237
3.640625
4
def number(num): y=0 for i in range(0,len(num)): s1=num[0:i]+num[i+1::] if(int(s1)%8==0): y=1 break if(y==1): print("yes") else: print("no") num=input() number(num)
4a769a22de6f02326aa77d9814c9bfeb253f0eea
fraitjan/RebyskaIsLearningPython
/rebyska5.py
1,605
3.609375
4
import random BLUE = '\033[94m' GREEN = '\033[92m' RED = '\033[91m' COLOR_RESET = '\033[0m' animals = { "vydrinka": ["Slovensko", "Cesko", "Singapore"], "tucnacik": ["Antarktida", "Chile", "Argentina"], "peso": ["Slovensko", "Cesko", "Anglie", "USA", "Nemecko"], "slonik": ["Rwanda", "Indie"], "pan...
6919b3c77dd72af3e8429f04f2a2074676aa4b87
abdouglass/GWU_MSBA_Prog_for_Analytics_Fall14
/hangman_1person.py
4,393
4.09375
4
player = raw_input("Welcome player. What is your name? ") #Initiate game, by asking who is playing print "Hello {0}! Welcome to hangman.".format(player) with open('G:/Programming for Analytics/HW #1/words.txt','r') as words: #import word file that will be pulled from words = words.read().split("\n") import rand...
5a6d75b21ead8cc173a46f6c654a75588e25c9bd
Kollaider/CheckiO
/checkio/home/right_to_left.py
1,150
4.5625
5
"""Right To Left. URL: https://py.checkio.org/en/mission/right-to-left/ DESCRIPTION: You are given a sequence of strings. You should join these strings into a chunk of text where the initial strings are separated by commas. As a joke on the right handed robots, you should replace all cases of the words...
1fbf1acd7f12a6c6ee670db889b2050845334c2b
jli124/leetcodeprac
/BinarySearch/154FIndMininRotatedSortedArrayII.py
1,337
3.71875
4
# 154. Find Minimum in Rotated Sorted Array II """ Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). Find the minimum element. The array may contain duplicates. """ #------------------------------------------------...
e3e3ea330a082f99c121bb6d6462d173c845959b
anaswara-97/python_project
/Regular_expression/valid_2.py
133
3.5
4
import re x="56fg" n='[0-9]{2}[a-z]{2}' match=re.fullmatch(n,x) if match is not None: print("valid") else: print("not valid")
9eb915dbdb329656814ccd5161e2d79cdd7d6816
fengwangjiang/kufpybio
/kufpybio/subseqextract.py
2,332
3.546875
4
from Bio import Seq from Bio.Alphabet import DNAAlphabet class SubSeqExtractor(object): """Extract subsequences from a given DNA sequence""" def __init__(self, seq, coordinate_start=1, include_pos=True): """ seq - sequence string coordinate_start - 0 for 0-based system; 1 for 1-based s...
549ec4e5a5ed5ffa9ef7760b25d182ef7e6646be
dyyee/docker-tutorial
/2-common-commands/pyramid/pyramid.py
275
3.90625
4
import sys def print_pyramid(level: int): for i in range(level): new_line_str = '' new_line_str += ' ' * (level - 1 - i) new_line_str += '*' * ((i+1) * 2 - 1) print(new_line_str) input_level = int(sys.argv[1]) print_pyramid(input_level)
8e4bbb82449e145bc5ed59ecfddde06cb051ab9b
christianreotutar/Programming-Challenges
/ProjectEuler/12/12.py
738
3.984375
4
import fileinput import math import sys triNums = [0] def getTriangleNumber(num): return num + triNums[len(triNums)-1] def getDivisors(num): divisors = [] sqrt = int(math.sqrt(num)) for i in xrange(1, sqrt+1): if (num % i == 0): divisors.append(i) divisors.append(num/i...
90a9ec416951d9b1e6b14a40231d2df754a4a894
daniel-reich/ubiquitous-fiesta
/uWpS5xMjzZFAkiQzL_5.py
292
3.71875
4
def odds_vs_evens(num): b=str(num) a=len(b) sumOdd=0 sumEven=0 for i in range(0,a): c=int(b[i]) if(c%2==0): sumEven=sumEven+c else: sumOdd=sumOdd+c if(sumEven>sumOdd): return "even" elif(sumOdd>sumEven): return "odd" else: return "equal"
487d2aca36cea26af96cdb18f984100401e9069b
diegopnh/AulaPy2
/Aula 16/Ex075.py
591
4.0625
4
numeros = (int(input('Digite o primeiro valor: ')), int(input('Digite o segundo valor: ')), int(input('Digite o terceiro valor: ')), int(input('Digite o quarto valor: '))) print(f'A lista de números digitados foi {numeros}') print(f'O número 9 aparece {numeros.count(9)} vezes na lista') if 3 i...
7d795fbbed9ec3089fd52628417613205c2ba219
deepika087/CompetitiveProgramming
/LeetCodePractice/Search a 2D Matrix II.py
746
3.5625
4
""" 127 / 127 test cases passed. Status: Accepted Runtime: 112 ms """ class Solution(object): def searchMatrix(self, matrix, target): """ :type matrix: List[List[int]] :type target: int :rtype: bool """ i=0 j=len(matrix[0]) - 1 while (i < len(matrix...
845c6ab3ddc0ba483e7cf0f8111f1a6510f66640
sklx2016/algorithm
/Python/数组/数组中超过一半的数字/moreThanHalf.py
437
3.578125
4
def moreThanHalf(array): count = 1 number = array[0] for x in array[1:]: if x == number: count += 1 else: count -= 1 if count == 0: number = x count += 1 sum = 0 for x in array: if x == number: sum...
b4eeb659fb09b4529e7b6136a31a803748789017
JulyKikuAkita/PythonPrac
/cs15211/MostFrequentSubtreeSum.py
3,445
3.828125
4
__source__ = 'https://leetcode.com/problems/most-frequent-subtree-sum/' # Time: O(N) # Space: O(1) # # Description: Leetcode # 508. Most Frequent Subtree Sum # # Given the root of a tree, you are asked to find the most frequent subtree sum. # The subtree sum of a node is defined as the sum of all the node values forme...
dea83eece503a7fb45916ead732d91d328ce31dc
cfichtlscherer/rhofinder
/lcm.py
209
3.796875
4
def lcm(a, b): if a > b: value = a else: value = b while(True): if((value % a == 0) and (value % b == 0)): lcm = value break value += 1 return lcm
8cc87752e2bd0f9a7bc098742207e60f32abd45b
jasonyu0100/General-Programs
/2019 Programs/Progcomp/question_2/problem.py
979
3.578125
4
import random def center(string, max_size): out = ' ' * ( (max_size - len(string)) // 2 ) return out + string def christmas_tree(n): leaves = [] if n < 12: trunk = '#' else: trunk = '##' k = max(1, int(n/6)) base_width = int(2*k+1) base = '=' * base_width max_size = n * 2 - 1 size =...