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
95d188d21b205369aec1048f304e5f66a223a8e8
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/rna-transcription/619d4e9869c94029baa328440608ae0d.py
430
3.65625
4
class DNA(object): def __init__(self, nucleotide_sequence): self.sequence = nucleotide_sequence def to_rna(self): return ''.join([self.complement(nucleotide) for nucleotide in self.sequence]) @staticmethod def complement(nucleotide): complements = { 'G': 'C', ...
b909dc3109a5bc2ec52a47fe21f8fa88cf64c301
swang/euler-python
/euler004.py
594
4.0625
4
# Problem #4 # A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. the_max = float("-inf") def is_palindrome(num): str_num = str(num) str_len = len(str_...
f553a41fac58e9cca0b4dccbf7317b29df55ce00
RohanDeySarkar/DSA
/linked_lists/linked_list_palindrome/linkedListPalindrome.py
965
3.828125
4
# This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None # Recursion def linkedListPalindrome(head): isEqual, _ = isPalindrome(head, head) return isEqual def isPalindrome(leftNode, rightNode): if rightNode is None: return (Tru...
128c78e58326f91c3e2ad11764ec30082e9c1150
mohmmed-aabed/Data-Structures-In-Python
/Queues/Queue.py
456
3.828125
4
class Queue: def __init__(self): self.items = [] def is_empty(self): return self.items == [] def enqueue(self, item): self.items.insert(0, item) def dequeue(self): return self.items.pop() def size(self): return len(self.items) queue = Queue() print(queu...
20babfe64543f82a300e28bd8169b0e0da175ae8
Titania1/scrapetodb
/basicdatabase.py
564
4.0625
4
import sqlite3 conn = sqlite3.connect('lunch.db') c = conn.cursor() #delete table #c.execute('''DROP TABLE meals''') #create a table c.execute('''CREATE TABLE meals(sandwich TEXT, fruit TEXT, tablenumber INT)''') #data to insert sandwich = 'chicken' fruit = 'orange' tablenum = 22 #insert and commit to database c.e...
219f77c3b8bd30538824a1999bbfd96ea88e63f5
miro-lp/SoftUni
/Fundamentals/FundamentalExercises/TheHuntingGames.py
820
3.671875
4
days = int(input()) players = int(input()) energy = float(input()) water_per_person = float(input()) food_per_person = float(input()) total_water = water_per_person * days * players total_food = food_per_person * days * players is_enough_energy = True for i in range(1, days + 1): loss_energy = float(input()) ...
a73241693b56d7f378c7c3bba7bfa8e40657aabc
cfascina/caete-scripts
/leaf-age-effect/tests.py
6,844
3.609375
4
############################################ #TESTE COM VALORES REAIS E FIXOS FUNCIONANDO ############################################ # %% teste LLS 6 anos import matplotlib.pyplot as plt import numpy as np import math def fa(u, acrit, a): #return min(1,math.exp(u*(acrit-a))) return min(1,math.exp(u*(acrit-...
37f506c2d3b003f00ea566690187eb0223595c3f
Hoon94/Algorithm
/Leetcode/109. Convert Sorted List to Binary Search Tree.py
852
3.78125
4
from typing import Optional class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def sortedListT...
8ed5f1c76e1b8fbeae963d0ceca7f5a0ef7c822a
iamtonyxu/91alg_2_iamtony
/Q394_decode_string.py
3,221
3.5
4
''' 给定一个经过编码的字符串,返回它解码后的字符串。 编码规则为: k[encoded_string],表示其中方括号内部的 encoded_string 正好重复 k 次。注意 k 保证为正整数。 你可以认为输入字符串总是有效的;输入字符串中没有额外的空格,且输入的方括号总是符合格式要求的。 此外,你可以认为原始数据不包含数字,所有的数字只表示重复的次数 k ,例如不会出现像3a或2[4]的输入。 E1 输入:s = "3[a]2[bc]" 输出:"aaabcbc" E2 输入:s = "3[a2[c]]" 输出:"accaccacc" E3 输入:s = "2[abc]3[cd]ef" 输出:"abcabccdcdcdef"...
853b31659bf3a46ba5f879f8591445185269f18f
panavtyagi/feedback-categorizer
/merging.py
2,939
3.640625
4
# The highest level code that brings everything together. import extractor import filter import scoring from sys import argv import numpy as np import additional_filter from nltk.stem import PorterStemmer, WordNetLemmatizer stemmer = PorterStemmer() lemmatiser = WordNetLemmatizer() def print_usage(): # Display ...
5ed4c46e3c134d4bc59f104e04755779c71966bf
nikozhuharov/Python-Fundamentals
/Functions - Exercise/02. Add and Subtract.py
306
3.953125
4
def sum_numbers(num_1, num_2): return num_1 + num_2 def subtract(num_1, num_2): return num_1 - num_2 def add_and_subtract(num_1, num_2, num_3): return subtract(sum_numbers(num_1, num_2), num_3) n1 = int(input()) n2 = int(input()) n3 = int(input()) print(add_and_subtract(n1, n2, n3))
06c9bb20b47cf619e2ae924988dba54bf2567a13
FlorianC31/Dict2csv
/main.py
3,348
4
4
def dict2csv(dictionary, csv_file, separator=';'): """ Transform a double dictionary (dict of same type dictionaries) in a CSV file. Each line corresponds to an entity from the primary dictionary (with key in first position) Each column corresponds to each keys of the secondary dictionaries :param ...
87b79ea25213f0286d568d2007e21b1dca472345
YashwanthLokam/Yashwanth1997
/dictionaryprog.py
1,848
4.34375
4
"""Program to print meaning of given word""" import requests import pyttsx3 from playsound import playsound def word_meaning(): meaning_of_word = information_of_word['results'][0]['lexicalEntries'][0]['entries'][0]['senses'][0]['definitions'][0] print("The meaning of " + user_word + " is " + meaning_of_word + ".") ...
bb5964e7a502a0da3a938a4add17d515ca250b1e
psbarros/Variaveis3
/2019-1/231/users/4213/codes/1690_2471.py
333
3.828125
4
a=float(input("Idade:")) b=float(input("IMC:")) if(a<0 or b<0): print("Dados ivalidos") elif (a<45 and b<22): print(a,"anos") print(b) print("baixo") elif (a<45 and b>=22): print(a+"anos") print(b) print("medio") elif (a>=45 and b<22): print(a+"anos") print(b) print("medio") else: print(a+"anos") print(b) ...
2ea566be95488731a4d944f94182e03322c4af39
nayaksneha/python.ws
/2.py
141
3.984375
4
num = int(input("enter a number")) temp = num rev = 0 while num!= 0: rev = rev*10 + num%10 num//=10 print(f"rev of {temp} is {rev}")
992c80b4f23f198c74596c7183b4f76cf6d973c1
leanndropx/px-python-logica-de-programacao
/80 - Dicionarios - Cadastro de funcionários - Tabela colorida.py
2,880
3.734375
4
# - DESCREVENDO O DESAFIO print('80 - Crie um programa que leia nome, ano de nascimento e carteira de trabalho, ',end='') print('e cadastre-os (com idade) em um dicionario se por acaso a CPTS for diferente de zero.') print('O dicionario também receberá o ano de contratação e o salário.') print('Calcule e acrescente...
d50ee13594631950889afbedea4f72cf0d5af854
sunheehnus/Think-Python
/choose_from_hist.py
596
3.71875
4
#!/usr/bin/env python # encoding: utf-8 def histogram(s): d = dict() for c in s: d[c] = d.get(c, 0) + 1 return d def choose_from_hist(d): res = [] for key in d: for i in range(d[key]): res.append(key) import random return random.choice(res) print choose_from_...
049f18c9021fe9f4a7db6cdee561892325c2ae4b
sgarcialaguna/Project_Euler
/problem17.py
3,328
4
4
"""If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? NOTE: Do not count spaces or hyphens. For example, 342 (th...
997b19859c331ba630b508c1d65850f88af770dd
jtiguila/jtiguila_pcc_cis012_homework
/Module 5/loopy_loops.py
1,211
4.25
4
# Module 5 Homework # loopy_loops.py # Prof. James Mertz # Josue Tiguila Jr. # Tuple named pokemon that holds strings 'picachu', 'charmander', and 'bulbasaur'. # Print string located at index[1] # Values of pokemon unpacked in to starter1, starter2, starter3. pokemon = ('picachu', 'charmander', 'bulbasur') print (pok...
12ea761f2aa0f561f7db0e564e48e0f1f0b14d04
pikowals/hello-world
/time_datetime/timeDatetimeExploring.py
7,601
3.8125
4
# import time,datetime # # print(time.time()) # Funkcja time zwraca liczbe sekud które upłynęły od początku epoki systemy UNIX (od 1 stycznia 1970) import datetime # import time # def calcProd(): # product = 1 # for i in range(1,100000): # product = product*i # return product # startTime = time.time...
1cb35b43a8516c88de88378165b465563c62313d
wwfirsov/dz4
/6_b.py
184
3.546875
4
from itertools import cycle start = input("Введите значение: ") c = 0 for el in cycle(start): if c >= len(start): break print(el) c += 1
2e244698187a583b19d5182abb24ab578711852c
ilokhov/sentiment-analyser
/local_analyser.py
1,952
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import csv import urllib2 from bs4 import BeautifulSoup ### retrieve and save lists of positive and negative words ### def getWords(fileName): wordList = [] with open(fileName) as inputfile: for row in csv.reader(inputfile): term = ''.join(row) wordList.append(t...
6088e79a1155187147f2e67a4dbae71d4f9a5217
brandonholderman/data-structures-and-algorithms
/breadth-first-traversal/breadth_first_traversal.py
1,519
4.1875
4
from queue import Queue class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right class BFT: def __init__(self, iter=[]): self.root = None if type(iter) is not list: raise TypeError for item in iter: ...
7fda6a14f07ebd78837af949534c9b33a85fa646
eselyavka/python
/leetcode/solution_1471.py
1,031
3.84375
4
#!/usr/bin/env python import unittest class Solution(object): def getStrongest(self, arr, k): """ :type arr: List[int] :type k: int :rtype: List[int] """ if len(arr) == 1: return arr m = sorted(arr)[(len(arr) - 1)/2] t_arr = [tuple([x,...
84a79fd5249e2fae7929b1f6b968646e7b24dc51
developerking123/1st-repo
/python learning and practice/Class_test_Employee.py
695
3.9375
4
''' Write a test case for Employee. Write two test methods, test_give_ default_raise() and test_give_custom_raise(). Use the setUp() method so you don’t have to create a new employee instance in each test method. Run your test case, and make sure both tests pass.''' from Employee_Class import Employee import unittest c...
b14f2f488bd3d0cac78b17531257c9b835858e00
codingscode/curso_python
/Work001/file081_decorators.py
1,405
4.375
4
""" Decorators O que são ? - São funções - Decorators envolvem outras funções e aprimoram seus comportamentos - Decorators também são exemplos de higher order functions - Decorators tem uma sintaxe própria, usando '@' (Syntact Sugar/ Açucar Sintatico) """ # Decorators como funções (Sintaxe não recomendada /...
d8f2f327f0019d5dd0fc3b4d4a475ce1d5fbde99
akashnigam/snake-game
/square.py
803
3.703125
4
import pygame class Square: def __init__(self, x, y, side_length): self.x = x self.y = y self.side_length = side_length def draw(self, screen, color, addEye=0, eyeColor=(255, 255, 255)): # to keep square inside grid -2 and +1 in following side_length = self.side_lengt...
38b7b5030e6d39b2adaabe73e14b40e637a14e3b
feleck/edX6001x
/lec6_problem2.py
623
4.1875
4
test = ('I', 'am', 'a', 'test', 'tuple') def oddTuples(aTup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' result = () i = 0 while i < len(aTup): if i % 2 == 0: result += (aTup[i:i+1]) i+= 1 #print result return result # ...
50d6c82ca14452d55d78d66735c424d08c47154e
ryoman81/Leetcode-challenge
/LeetCode Pattern/7. Fast & Slow Pointers/876_easy_middle_of_the_linked_list.py
1,179
4.0625
4
''' Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) Example 2: Input: [1,2,3,4,5,6] Output: Node 4 from this list (Serializ...
8ac01c01aa045ffb103845daa64d7725312795a3
AVogelsanger/Python
/PythonCode/exerc3.py
296
3.859375
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 7 13:58:54 2019 @author: 748418 """ num1 = int(input("Digite um numero: ")) num2 = int(input("Digite outro numero: ")) if (num1 % num2 == 0): print("Numeros são divisíveis.") else: print("Os numeros não são divisíveis")
8c96704cfb3202e194896fe7f5504fe30783a7c8
Prakhar20000902/tathastu_week_of_code
/Day1/program5.py
702
3.859375
4
p1 =int (input("runs scored by first player")) p2 = int (input("runs scored by second player")) p3 = int (input("runs scored by third player")) srp1 = p1 * (100/60) srp2 = p2 * (100/60) srp3 = p3 * (100/60) print("strike rate of players are:") print("player 1 = " , srp1) print("player 2 = " , srp2) print("player 3 = " ...
34a2e2a11dc2c7531ad358ca2deea00fb66958b1
emanuel-mazilu/python-projects
/timer/timer.py
556
3.890625
4
import tkinter as tk window = tk.Tk() window.title("Timer") def countdown(count): mins, secs = divmod(count, 60) if mins >= 60: hours, mins = divmod(mins, 60) else: hours = 0 label1['text'] = str(hours).zfill(2) + ":" + str(mins).zfill(2) + ":" + str(secs).zfill(2) if count > 0: ...
f38b6633f77b87f68976ff12823480d6bd08f1d6
crowsonkb/partial-apply
/partial_apply/partial_apply.py
7,555
3.90625
4
"""Partial application of functions and method names, supporting placeholder values for positional arguments. Unlike :func:`functools.partial`, placeholder values are supported so that positional arguments for partial application do not need to be supplied solely from left to right. Keyword arguments are handled equiv...
419a3e24e9746a9d2579fc0ff44e99c3be7c7a4a
jdelgad/algorithms
/redblacktree/redblacktree.py
5,962
3.75
4
RED = 0 BLACK = 1 class Node(object): color = BLACK key = None left = None right = None parent = None def __init__(self, key): self.key = key class RedBlackTree(object): def __init__(self): self.root = None def insert(self, z=Node): y = None x = self...
b26dae5bcb6dde871e5c22cf48ab331317772274
Naysla/Machine_Learning
/10_cleaning with Apache Spark_/1_Defining a schema.py
617
4.09375
4
''' Defining a schema Creating a defined schema helps with data quality and import performance. As mentioned during the lesson, we'll create a simple schema to read in the following columns: Name Age City The Name and City columns are StringType() and the Age column is an IntegerType(). ''' # Import the pyspark.sql.t...
0fe9bc6757d1c4cfa04d929eee2c7f304bf7da2e
AliveSphere/Introductory_PyCharm_Files
/POTD/higher_lower.py
736
3.734375
4
# Charles Buyas cjb8qf import random print("Input a -1 to play with a random number") start = int(input("What should the answer be?: ")) count = 0 if start == -1: start = random.randint(1, 100) else: num = start while count < 4: guess = int(input("Guess a number: ")) if int(guess) == int(start): ...
5cd3be78e4e45bcff3e76983bc5e86eae377c7b3
enricozammitlon/Hex2018
/buses.py
6,449
3.671875
4
# Definitions of classes for buses, battery and route information. # Not to be executed, rather import if __name__ == '__main__': print("Why are you doing this?") # Constants # Efficiency of the motor is assumed to be 1.5 kWh/km maintanance = 0.3 # EUR/km charging_energy = 0.1 # EUR/kW eff = 1.5 # kWh/km d...
cc45651a0c186fcf1aedfbf704cfc677acc04308
niteesh2268/coding-prepation
/leetcode/Problems/43--Multiply-Strings-Medium.py
2,028
3.53125
4
class Solution: def addNumbers(self, num1, num2): if len(num1) < len(num2): num1, num2 = num2, num1 carry = 0 answer = '' diff = len(num1)-len(num2) for i in range(len(num2)-1, -1, -1): sum = (ord(num2[i])-ord('0')) + (ord(num1[i+diff])-ord('0')) + car...
c25ab3e95c806166ba94fde1c2e232e61821bb5c
SnyderMbishai/algorithms
/ransom_note.py
1,989
4.28125
4
""" Harold is a kidnapper who wrote a ransom note, but now he is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he mu...
3df39beb62eb27a569f6633b1fa24739e38bb315
jmelero611/Travelccines
/parsing_and_formating/country_3_to_num.py
1,218
3.640625
4
#!/bin/env python 3 def dict_name_to_three(): name_to_three = {} with open('three_to_country.txt', 'r') as c_t_3: for line in c_t_3: line = line.strip() line = line.split('\t') name_to_three[line[1].lower()] = line[0] return name_to_three def dict_three_to_num_pre...
247af02834e0d06ab885850167377c30f966a61f
Spiridd/python
/stepic/tables_union.py
1,404
3.734375
4
class TableList(object): """ Based on disjoint set parent[item] is data xor index parent data is negative or zero reference is positive (that's why you see [source-1]) """ def __init__(self, parent): self.parent = parent self.max_size = -min(parent) def get_max_size...
3bab5a5bc0ca17f82b7b17cd515062c2ef475228
nazim164/Python-Code
/voterwithclassfunction.py
292
3.765625
4
class Show(): def dis(self): name=(input("Enter Voter Name :")) age=int(input("Enter Voter Age :")) if age>=18 : print("You Are Eligible For Vote") else : print("Sorry .... You Are Not Eligible For Vote") f1=Show() f1.dis()
27675d68e28f926756f39e33a12743c793ed3748
Nate8888/programming-contest-practice
/programming-team/First Semester/Learn Problems/IntroProblems/sameletters.py
472
3.5625
4
i = 1 while True: first = input() second = input() if first == "END" and second == "END": break else: dict_1 = {} dict_2 = {} for each_l in first: if dict_1.get(each_l): dict_1[each_l] += 1 else: dict_1[each_l] = 1 for each_l in second: if dict_2.get(each_l): dict_2[each_l] += 1 el...
e16ddc3ce283062f10914bfbc1711bcc5f4dd160
Algogator/50-days-of-Python
/floor.py
563
4.15625
4
w = float(input()) h = float(input()) c = float(input()) """ http://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python3-x The difference is that raw_input() does not exist in Python 3.x, while input() does. In Python 2, raw_input() returns a string, and input() tries to ru...
781746e25dfb8f6a55be8ca639b63e01b1e7cb23
dlx24x7/fund_of_cpu_python
/week3_quiz.py
1,737
4.21875
4
""" week3_quiz.py """ def eval_bool(p, q): """ Takes boolean p and q and returns the values """ answer = not(p or not q) return answer print("answer 1:", eval_bool(True, True)) print("answer 2:", eval_bool(True, False)) print("answer 3:", eval_bool(False, True)) print("answer 4:", eval_bool(Fa...
93914766b4762b34275707ed4486d17ae338f760
imwujue/python-practice-wujue
/Q6.py
236
3.953125
4
# 递归 def fib(n): if n == 1 or n == 2: return 1 else: return fib(n-1)+fib(n-2) # 非递归 def fib1(n): a,b = 0,1 for i in range(0,n-1): a,b = b,a+b return b print(fib(10)) print(fib1(10))
fba59504414bc8e8e13f15de3f2c57a56b84cdb1
ptenteromano/data-analysis
/nyctemps.py
1,548
3.53125
4
# # Phil Tenteromano # 11-5-2018 # # Plotting NYC temperature data using # numpy, pandas, matplotlib, and a csv dataset import pandas as pd import matplotlib.pyplot as plt # 21264 rows x 12 columns data = pd.read_csv("./data/NYC_temps.csv") # convert time data into datetime object data['DATE'] = pd.to_datetime(dat...
4077ff1138d7cd100392939c7547ffd6c03e74e6
vineethamallu6/vineetha
/cspp1-practicem3/sum_1_end.py
88
3.984375
4
n=int(input("enter a number=")) i=1 sum=0 for i in range(1,n+1,1): sum=sum+i print(sum)
dd8037cd6c6b0ab568c1f4d136357c28ade58e4e
cu-swe4s-fall-2020/version-control-lcpowers
/math_lib.py
142
3.65625
4
def div(a, b): if b != 0: return a/b else: return "b cannot be equal to zero" def add(a, b): return a + b
fc0f4702a6a510e300dc29e93fbe78ca10f5e42b
beckytrantham/PythonI
/lab11.py
490
4.15625
4
#Converts temperature in Fahrenheit to Centigrade #Formula: C = 5/9 *(F-32) #Use Try statement to catch ValueError exceptions def f_to_c(ftemp): return 5.0 / 9.0 * (ftemp - 32) temp = raw_input("What is the temperature in degrees Fahrenheit? ") try: ftemp = float(temp) except ValueError: print "Value Err...
c6cdbec9d83612589ee00feea791d7a5c88e15f2
venkatesh123456779/Wipro-PJP-Python
/TM-2/Sets/3.py
233
3.671875
4
set1 = {2, 4, 5, 6} set2 = {4, 6, 7, 8} set3 = {7, 8, 9, 10} print("Set1: ",set1) print("Set2: ",set2) print("Set3: ",set3) print("set1 Union set2 : ", set1.union(set2)) print("set1 Union set2 Union set3 :", set1.union(set2, set3))
8c3c6128a75bf3cde96c5583a45a8b7968a0e684
souza10v/Exercicios-em-Python
/activities1/codes/69.py
472
3.703125
4
// ------------------------------------------------------------------------- // github.com/souza10v // souza10vv@gmail.com // ------------------------------------------------------------------------- from random import randint n=((randint(0,10)),(randint(0,10)),(randint(0,10)),(randint(0,10)),(randint(0,10)),)...
1cdcdd39c64d46a08367e4a693cc53d0bfa840c9
saraalrumih/100DaysOfCode
/day 030.py
329
4.21875
4
# for loop 2 # print odd numbers between 1 to 10 for i in range(1,10,2): print(i) else: print("These are the odd numbers between 1 to 10.\n\n") # nested for loops mothers =("Sara","Jana","Renad") daughters =("Mai","Fai","Nora") for mom in mothers: for girl in daughters: print(mom," is ",girl,"'s mo...
9f3cc2b37c299587da28fbc15aafa0c5d69a8882
netor27/codefights-solutions
/interviewPractice/python/01_arrays/02_firstNotRepeatingCharacter.py
1,190
4
4
'''' Note: Write a solution that only iterates over the string once and uses O(1) additional memory, since this is what you would be asked to do during a real interview. Given a string s, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'. Example For s =...
2b6b6c0353e7e629b4c4ff2c657018541b8685b2
CharmSun/my-leetcode
/py/160.intersection-of-two-linked-lists.py
971
3.578125
4
# # @lc app=leetcode id=160 lang=python3 # # [160] Intersection of Two Linked Lists # # @lc code=start # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None ## 精妙解法,pa, pb指向两个链表,不等时分别向后移动, ## pa为空时转向B链表,pb为空时转向A链表,直到相遇,或者均为null class Solu...
e327204503fe203b4be5830863a1910cabb3c4ee
KosukeShimizu/ProjectEuler
/question019.py
391
3.5625
4
# question 18 def monthData(yy): month_data = {1:31, 2:28, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31} if yy%4 == 0 and (yy%100 != 0 or yy%400 == 0): month_data[2] = 29 return month_data days = 1 count = 0 for i in range(1901, 2001): month_data = monthData(i) for j in range(1, 13): days +=...
11c0f9122dc5f0dd10149484121ac53237cb3a57
KristianMSchmidt/Fundamentals-of-computing--Rice-University-
/Interactive Programming/Andet/pig_latin.py
1,025
3.671875
4
################################################## # Student should add code where relevant to the following. import simplegui # Pig Latin helper function def pig_latin(word): """Returns the (simplified) Pig Latin version of the word.""" first_letter = word[0] rest_of_word = word[1 : ] global p ...
7cdb0f50930df5c324ccc04c5aa1f5856586e9cf
CodeForContribute/Algos-DataStructures
/TreeCodes/TreeTraversal/IterativePostOrderTraversal.py
1,895
3.84375
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None # Using 2 Stack def IterativePostOrderTraversal(root): if not root: return Stack1 = [] Stack2 = [] Stack1.append(root) while len(Stack1): temp = Stack1.pop() ...
b9c0f80e9d237e2b1ceb1e55984987adb48399d0
xiaozhengxu/GeneFinder
/gene_finder.py
8,021
3.640625
4
# -*- coding: utf-8 -*- """ YOUR HEADER COMMENT HERE @author: Xiaozheng Xu """ import random from amino_acids import aa, codons, aa_table # you may find these useful from load import load_seq dna = load_seq("./data/X73525.fa") def shuffle_string(s): """ Shuffles the characters in the input string ...
2a653e577169864a33d8bacc23c09c38c2f625f6
mennanov/problem-sets
/dynamic_programming/longest_commong_substring.py
1,129
4.15625
4
# -*- coding: utf-8 -*- """ The longest common substring of the strings "ABABC", "BABCA" and "ABCBA" is string "ABC" of length 3. Other common substrings are "AB", "BC" and "BA". """ def longest_substring(string1, string2): """ Longest substring problem dynamic programming approach. The running time is O(...
344704f8589abb1f128c141f5fd29ab3de0f2bc1
Manoj431/Python
/Collection_s/Solution_16_2.py
1,343
4.5625
5
#Hash Map.. It is same as Dictionary in map... student = {"Manoj" : 101, "Asir" : 102, "Swadesh" : 103, "Rajat" : 104, "Arijit" : 105, "Sen" : 106, "Aniket" : 107, "Bhalu" : 108, "Asis" : 109, ...
8b98a125a95f70ef808579cf5677ba7767cad6b2
rishi1212/hackerRank
/algorithmspython/marsexploration.py
234
3.53125
4
#!/bin/python3 import sys S = input().strip() a=int(len(S)/3) expected=[] for i in range(0,a): expected.append("SOS") ans1="".join(expected) count=0 for i in range(0,len(S)): if(S[i]!=ans1[i]): count+=1 print(count)
171fb3559dafb5ff8a8bd63258e85da2af1c5b0a
lufbasilio/BasicOfPython
/aula05/conta.py
494
3.671875
4
class Conta(object): #banco = "Nubank" def __init__(self, user, numero, saldo, credito): #construtor = recebe valores self.user = user self.numero = numero self.saldo = saldo self.credito = credito self.banco = "Nubank" def imprime_saldo(self): return self...
30228744762469c9b1489603446ac4345495b122
iwuch/python_examples
/find_duplicate.py
314
3.671875
4
from typing import List class Solution: def findDuplicate(self, nums: List[int]) -> int: # for i in range(len(nums)): # if nums[i] in nums[i+1:]: # return nums[i] seen = [] for i in nums: if i in seen: return i else: seen.append(i) lst = [1,3,4,2,2] print(Solution().findDuplicate(lst))
613dd0c923cd52531f0074ce333f775cdff2c7d3
Navyashree008/for_loop
/xum_of_num_input.py
91
4.0625
4
total=0 num=int(input("enter no:")) for x in range(1,num+1): total=total+x print(total)
d0bc72b6a6b9bf9860216d8366286733418e984c
JeffreyAsuncion/PCEP_training_2020_12
/2_2.py
257
4.25
4
# read two numbers number1 = int(input("Enter first number: ")) number2 = int(input("Enter second number: ")) # choose the larger number if number1 > number2: max = number1 else: max = number2 # print the result print("The larger number is ", max)
cd19f290374b81d5607a4735e335f262b8fae6fd
agk79/Python
/dynamic_programming/subset_generation.py
1,290
4.46875
4
# python program to print all subset combination of n element in given set of r element . #arr[] ---> Input Array #data[] ---> Temporary array to store current combination # start & end ---> Staring and Ending indexes in arr[] # index ---> Current index in data[] #r ---> Size of a combination to be printed def combi...
d883947a59e18165fba076a717fff8faa52c79a3
JohnCook17/holbertonschool-machine_learning
/supervised_learning/0x03-optimization/2-shuffle_data.py
449
3.8125
4
#!/usr/bin/env python3 """Shuffles data using np.random.permutation""" import numpy as np def shuffle_data(X, Y): """X is the first np.ndarray to shuffle. Y is the second, both have a shape of (m, nx), and (m, ny) respectivly m being the number of data points and the n value being the number of features i...
232373a237ee136cb9d004dea782ccd13c66b851
urbanfog/python
/100DaysofPython/Day18TurtleGraphics/turtle_shapes.py
589
4.25
4
#####Turtle Intro###### import turtle import random turd = turtle.Turtle() screen = turtle.Screen() def polygon(sides): r = random.randint(0, 256) b = random.randint(0, 256) g = random.randint(0, 256) turd.color((r, b, g)) turn = 360 / sides for _ in range(sides): turd.forward(100) ...
413f9c6e6298f0d6f03aa2eb0801b5456db33879
phucle2411/LeetCode
/Python/valid-mountain-array.py
551
3.5
4
# https://leetcode.com/problems/valid-mountain-array/ class Solution(object): def validMountainArray(self, A): """ :type A: List[int] :rtype: bool """ if len(A) <= 2: return False if A[0] > A[1]: return False increasing = True for i in range(1, len(A...
307c83feb408d74b2213a72f2fff52183b24a1e2
ashinsukumaran/pythonprograms
/regular expression/quantifiers.py
1,674
3.96875
4
# quantifires # x='a+' a including group # x='a*' count including zero number of a # x='a?' count a as each including zero no or a # x='a{2}' 2 no of a position # x='a{2,3}' minimum 2 a and maximum 3 a # x='^a' check starting with a # x='a$' check ending with a # import re # x="a+" # r="aaa abc aaaa cga" # matc...
6852996f47fd52128753d3664380f92986dad9d5
Jimut123/code-backup
/python/coursera_python/WESLEYAN/week3/COURSERA/week_3/copy_file_worked.py
1,134
3.75
4
# -copy_file.py *- coding: utf-8 -*- """ Exercise: Convert this function to a standalone program or script that takes two file names from the command line and copies one to the other. Steps: 1. Delete "Def" line. You don't need it. 2. Use Edit menu of Spyder to Unindent all the lines. 3. import the system library sys ...
0be3d9f8bc4877bf487c52f451128cba8711a4c7
tom-wagner/ip
/assessment/graph.py
1,455
3.78125
4
import collections # START TIME: class Graph: def __init__(self): pass @property def size(self): return '' def add_vertex(self, v): pass def remove_vertex(self, v): pass def add_edge(self, f, t): pass def contains(self, val): pass ...
2b41279ee024708b4310dfcf989e53fa71accfdd
rushithakare766/All-Python-Programs
/primenumber.py
484
4.28125
4
# program to check the enter number is prime or not num=int(input("Enter the number:")) if num>1:# this condition is true then control goes into for loop for i in range(2,num):# this for loop run from 2 to num-1 if num%i==0: # this condition is true when num is divisble by i and remainder is 0 ...
0602c319a68722c4bb7fdf58646066e92c984442
mnmnwq/python
/vowels.py
239
4.3125
4
vowels = ['a','e','i','o','u'] words = input("Provide a word to search for vowels:") found = [] for letter in words: if letter in vowels: if letter not in found: found.append(letter) for vol in found: print(vol)
6d4edd8c6bf849540d1995d49a269aff54557e78
meithan/AoC19
/day04.py
1,277
3.546875
4
import sys # Going from left to right, the digits never decrease def check_never_decrease(s): for i in range(len(s)-1): if s[i] > s[i+1]: return False return True # Count lengths of repeated groups (for Part 2) def count_repeated_runs(s): d = s[0] run = 0 repeated_runs = [] for i in range(len(s...
f6e1e2c113fc6805e10832272164b5ae65390095
smal1378/HighFrequencyCatFish
/main.py
1,012
3.515625
4
import threading import time import tkinter def event_loop(): while True: time.sleep(sleep_time) clock_callback() def speed_checker(): def calculate_speed(): s = 0 for i in range(current_d, current_d+len(d)-1): s += d[(i+1) % len(d)] - d[i % len(d)] if s !...
2bcd1959b5149b96e50e4ac04185323a27d73a1c
babache/ndh-challenges
/2k16-LOL_So_obfuscated/lol_so_obfuscated.py
1,829
3.75
4
#!/usr/bin/env python import itertools TEMPLATE = """\ #include <stdio.h> #include <stdlib.h> #include <string.h> void encrypt(char *key, char *string) { int i; int string_length = strlen(string); int key_length = strlen(key); for(i=0; i<string_length; i++) { if (i != 0) { string[...
13aed493b75df45b395e2537d4fd6b576dde8ec9
claudio-avolio/python-challenge
/modules/company.py
338
3.578125
4
import json companies = json.loads(open('resources/companies.json').read()) def get_by_name(name): nameUpper = name.upper() company = next((c for c in companies if c["company"].upper() == nameUpper), None) return company def get_by_index(index): company = next((c for c in companies if c["index"] == index), None...
88dfa38c0f3526fe0202f8417563c5e76d0ea89a
lalitkapoor112000/Python
/Common elements of list.py
383
3.8125
4
def common(l,m): res=[] l.remove('q') m.remove('q') for i in range(len(l)): if l[i]==m[i]: res.append(l[i]) return res k=[] p=[] while 'q' not in k: k.append(input("Enter numbers of list 1 and enter q to stop:")) while 'q' not in p: p.append(input("Enter ...
7ebcd5a8c55e633faf403aca647638c154cc5461
JIghtuse/exercism-solutions
/python/difference-of-squares/difference_of_squares.py
218
3.984375
4
def square_of_sum(n): sum_up_to_n = n * (n + 1) / 2 return sum_up_to_n**2 def sum_of_squares(n): return (2 * n**2 + 3 * n + 1) * n / 6 def difference(n): return square_of_sum(n) - sum_of_squares(n)
213456d79feb488c8eda4616b98f77e80cae233d
IliaYusov/TicTacToe-with-AI
/tictactoe_with_ai.py
11,533
3.53125
4
import random from abc import abstractmethod import pickle import os.path from enum import Enum class GameResult(Enum): WIN_X = 'X wins' WIN_O = 'O wins' DRAW = 'Draw' IN_PROGRESS = 'Game not finished' WRONG_POSITION = 'Wrong state!' class TicTacToe: # Такой хардкод – не гуд. Если захочется ...
66cb241d6d976874d08b86ddd61cfc0e96e67988
KevinArellanoMtz/AprendiendoPyhton
/Guiadepython(programas)/Conversiones.py
944
4.34375
4
#Kevin Luis Arellano Martinez #Matricula 1878209 #Segundo programa #Lo primero que haremos sera declarar una variable str #str es un tipo de dato de cadena se determina entre "" numero="19" #con un sencillo comando que es type y el print mostrara el tipo de dato que es este print(type(numero)) #Y para converti...
13157cad99a006230e637ff6691f14bcd2a7838f
greatabel/puzzle_I_cracked
/3ProjectEuler/i51_75/i72counting_fractions.py
1,148
3.890625
4
''' Consider the fraction, n/d, where n and d are positive integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction. If we list the set of reduced proper fractions for d ≤ 8 in ascending order of size, we get: 1/8, 1/7, 1/6, 1/5, 1/4, 2/7, 1/3, 3/8, 2/5, 3/7, 1/2, 4/7, 3/5, 5/8, 2/3, 5/7, 3/4, 4/5, 5/...
1d60349871b16753568f871daf1edf3f07443c4a
wjwjwj2223/NeteaseAlgorithm
/8/8_1_0.py
1,258
3.890625
4
class Node(object): def __init__(self, isWord): self.isWord = isWord self.next = dict() class Trie(object): def __init__(self): self.root = Node(False) self.size = 0 def getSize(self): return self.size # 添加单词 def addWord(self, word): cur = self.roo...
292772886f39c62a8443067191fcbf49de7611f1
Kunal352000/python_adv
/18_userDefinedFunction33.py
242
3.734375
4
def f1(*x,y,**z): print(x,type(x)) print(y,type(y)) print(z,type(z)) f1(3.2,4j,False,y=9,name="kunal",age=21) """ output: (3.2, 4j, False) <class 'tuple'> 9 <class 'int'> {'name': 'kunal', 'age': 21} <class 'dict'> """
e0ed3f04599a3b1e290535eac8177965045f978d
alexYooDev/onl_jud_al
/reversed_int.py
115
3.515625
4
def solution(n): arr = list(str(n)) arr.sort(reverse=True) answer = int("".join(arr)) return answer
ef22baba87fb0653a5e1c408796b2856402fe130
hafizaj/Dropbox
/Python Materials/CS97/rps_soln.py
818
3.5625
4
from random import choice def rpsCheat(personChoice): return "computer wins" def rpsRock(personChoice): if personChoice == 'rock': return 'tie game' elif personChoice == 'paper': return 'person wins' else: return 'computer wins' def rps2(personChoice, compChoice): if (com...
677762264caab9b2f0011406f415be3d71cac79a
wuqunfei/algopycode
/241.py
818
3.71875
4
from typing import List class Solution: def __init__(self): self.ops = { '+': lambda x, y: x + y, '-': lambda x, y: x - y, '*': lambda x, y: x * y } def diffWaysToCompute(self, expression: str) -> List[int]: res = [] for i, v in enumerate(e...
9904b6b714a55fc0736f40852272d22692dc7909
pravinraj0001/PythonPractice
/exercise-genrators.py
292
3.8125
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 17 16:32:35 2021 @author: Pravin """ ### Filter out a comments from the file # Read the file f = open("data.txt") # Go through the file through generators comments = (t fo t in lines if t[0] == '#') for c in comments: print(c)
ab8e302c270f3f6abfac7e211b1bb37b08e3a5eb
blackplusy/0525
/例子-0604-06.类的属性的访问特性.py
454
3.65625
4
#coding=utf-8 class test: a=100 #类的属性 def __init__(self,b): self.b=b #实例属性 t=test(998) #实例化对象 #1.通过实例化对象访问类的属性 print('t.a=%d' % t.a) #2.通过类名访问类的属性 print('test.a=%d' % test.a) #3.通过实例化对象访问实例属性 print('t.b=%d' % t.b) #4.通过类名访问实例属性 print('test.b...
f295f916d56b359d506eeb4896944de4e050d6f4
fingerman/python_fundamentals
/python_bbq/while_blut_alcochol.py
935
4.09375
4
while True: try: m = float(input("Weight: ")) break except: print("Weight should be numeric !") while True: try: v = float(input("How much did you drink(in ml.): ")) break except: print("The value should be numeric") while True: gender = input("Male o...
41ccba87e8524820d9146195962664785d868f8d
HandeulLy/CodingTest
/BOJ/3009.py
1,267
3.9375
4
# 3009 - 네 번째 점 # 세 점이 주어질 때, 축에 평행한 직사각형을 만들기 위한 네 번째 점을 찾는 프로그램 작성 # 입력 : 세 점의 좌표하 한줄씩 입력, 좌표는 1보다 이상, 1000이하인 정수 # 출력 : 네 번째 점의 좌표 출력 ##################################################### ##################################################### a = input().split() b = input().split() c = input().split()...
0120e84ea4e19f8423160823a10f6678ef1a8e9e
Edi6758/aula_OOP
/modulo3/imposto.py
508
3.6875
4
salario = float(input()) dep = int(input()) inss = 0 aliquota = 0 deducao = 0 desc_dep = dep*137.99 if salario <= 720.00: inss = salario*0.0765 elif 720.00 < salario <= 1200.00: inss = salario*0.09 elif 1200.00 < salario <= 2400.00: inss = salario*0.11 else: inss = 2400*0.11 if 1372.81 < salario <= 2743.25: ...
519c34f9268ec1264337d304b9b1021069ad4cf1
KonradKlos/Codebrainers_szkolenie
/python/0_8dzien/zad2.py
1,202
3.890625
4
def min (L): """Funkcja szukająca minimalnej wartości. Funkcja pobiera listę wartości i iteruje po nich, żeby znaleźć najmniejszą. >>> min([1,2,3,4]) 1 >>> min([]) Traceback (most recent call last): ... IndexError: list index out of range >>> min("Piotr") 'P' ...
961c6b4d5f6a90821395f0857af33571f8c4020a
LanderVanLuchene/test
/Lesweek1/Oef8.py
269
4.03125
4
time = int(input("geef aantal seconden op")) days = time/(60*60*24) time = time % (60 * 60 * 24) hours = time /3600 time = time % 3600 minutes = time /60 seconds = time % 60 print("d:h:m:s -> {0:{1:{2}:{3}".format(int(days), int(hours), int(minutes), int(seconds)))
c31b48181c0a12a3c1ac5ac1cf3e8d24594ea771
leskat47/cracking-the-coding-interview
/object-orientation/call-center.py
1,782
3.71875
4
class Queue(object): def __init__(self): self.queue = [] def enqueue(self, emp): self.queue.append(emp) print emp, " has been added" def dequeue(self): if self.queue: return self.queue.pop(0) else: return None class Employee(object): ...
d182e221f442d1720c99ea870a0b162dde637587
akshays-repo/learn.py
/files.py/Artificial intelligence/opencv/intro/drawline.py
288
3.53125
4
import numpy as np import cv2 # Create a black image img = np.zeros((512,512,3)) # Draw a diagonal blue line with thickness of 5 px and starting and ending point img = cv2.line(img,(0,0),(700,700),(255,0,0),5) cv2.imshow('image',img) cv2.waitKey() cv2.destroyAllWindows()
745a139675ad5fc4e716e02ff68039da60604935
ghoshorn/leetcode
/leet100.py
1,244
3.96875
4
# encoding: utf8 ''' Same Tree Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. ''' import unittest from pprint import pprint import pdb # Definition for a binary tree node. class T...
306fc4ae338e87175f7928d65d790b527a43aa9e
juliemyhu/HB_Labs
/markov-chains/markov.py
3,173
4.03125
4
"""Generate Markov text from text files.""" from random import choice import sys def open_and_read_file(file_path): """Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. """ text_file = open(file...