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
6e2c526860c260a41576a85b5187bb6224e62f7f
IbroCalculus/Python-Codes-Snippets-for-Reference
/Numpy.py
4,015
3.90625
4
import numpy as np import matplotlib.pyplot as plt #NUMPY VS LIST #1. Less memory #2. Fast #3. Convenient #SINGLE-DIMENSIONAL ARRAY a = np.array([1,2,3,4]) print(a) #MULTI-DIMENSIONAL ARRAY b = np.array([(1,2,3,4),(4,3,2,1)]) print(f'MULTIDEMENSIONAL: {b}') #MULTI-DIMENSIONAL ARRAY TO SINLE-DIMENSIONAL ARRAY b = n...
89279b55447199014c2fb78fce1f538f09095cc0
taisonmachado/Python
/Lista de Exercicios - Wiki_python/Estrutura de Decisao/18.py
358
4.25
4
#Faça um Programa que peça uma data no formato dd/mm/aaaa e determine se a mesma é uma data válida.) data = input("Digite uma data no formato dd/mm/aaaa: ") data = data.split('/') dia = int(data[0]) mes = int(data[1]) ano = int(data[2]) if(dia>0 and dia<=31 and mes>0 and mes<=12 and ano>0): print("Data válida") ...
be0cd60d399e3078a68cf03086aa8a979933088d
mfrankovic0/pythoncrashcourse
/Chapter 9/9-1_restaurant.py
614
3.921875
4
class Restaurant: """A restaurant model.""" def __init__(self, name, kind): """Initialize name and type.""" self.restaurant_name = name self.cuisine_kind = kind def describe_restaurant(self): """Describes restaurant name and type.""" print(f"{self.restaurant_name} i...
e6a022710436330ca1a11a46ebfb718ca730d4a6
lj015625/CodeSnippet
/src/main/python/string/ngram.py
486
4.125
4
"""Write a function get_ngrams to take in a word (string) and return a dictionary of n-grams and their frequency in the given string. """ def get_ngrams(n, string): d = {} # range end at index + 1 for i in range(len(string) - n + 1): temp = string[i:i + n] if temp in d: d[temp]...
3b699aa82119e5907ce723248e0bfcb3bba5a835
sjetho/Python1
/hw1-16.py
680
3.84375
4
# Medium 1 and 2 # def list(input): # sorted_list = sorted(input) # print(sorted_list[0]) # list([9,10,3,5,8,7]) # def list(input): # sorted_list = sorted(input, reverse=True) # print(sorted_list[0]) # list([1,4,5,2,10,9]) #Medium 3 and 4 # strings = ("These", "are", "words", "that", "i", "am", "testi...
cf491dac0a4f6bf5db3a02ed1d7121a75d7030e9
AppleEggX/Python-Algorithm
/mid-search.py
223
3.78125
4
def binary_search(li,val) low = 0 high = len(li) - 1 while low <= high: mid = (low + high) // 2 if li[mid] < val: low = mid + 1 elif li[mid] > val: high = mid - 1 else: return mid return none
67e335a792b8b1f3f65891ce2730e3c6711c5861
fnadiya/TugasIndividu_IMPAL
/TugasImpal_1301174701_NadiyaFitriana.py
733
4
4
a = int(input("Sisi 1 = ")) b = int(input("Sisi 2 = ")) c = int(input("Sisi 3 = ")) if(a<0 or a==0 ): print("segitiga tidak dapat dibangun") elif(b<0 or b==0): print("segitiga tidak dapat dibangun") elif(c<0 or c==0): print("segitiga tidak dapat dibangun") if(a>0 and b>0 and c>0): x=max(a,b,c) ...
d1a2e6b71d4f4db7561752fb77f67113f8cedc5d
eldonato/Estrdados_Uniesp
/avaliacao 2/matriz/exerciciof.py
452
3.953125
4
def main(): dadosGeral = [] dadosAluno = [] for i in range(3): nome = input('Insira o nome: ') matricula = int(input('Insira a matricula: ')) nascimento = input('Insira o nascimento: ') print(""*2) dadosAluno.append(nome) dadosAluno.append(matricula) ...
e184d831158a97c003783ac82ac8d104ff6fc385
NTUT-109AB8011/crawler
/exercise/learn_python_dm2039/ch6/ch6_56.py
342
3.546875
4
# ch6_56.py drinks = ["coffee", "tea", "wine"] enumerate_drinks = enumerate(drinks) # 數值初始是0 print(enumerate_drinks) # 傳回enumerate物件所在記憶體 print("下列是輸出enumerate物件類型") print(type(enumerate_drinks)) # 列出物件類型
f43270766accf87ad2ddfe3f8c37f7a9c85c9522
NachoElzo/Python
/Tuples.py
1,024
4.53125
5
#Tuples cant be modified, insert, delete #Tupleas can be a key for diccionaries #You can print elements #you can slice over the tuple #Are faster than list and diccionaries #You can transform tuples in a list with the function list() tupl = ("one","two","three","four","five","five") lit = list(tupl) #you can transfor...
9ee61669699836664c5529579f4611ea08b8ce7a
sabrinachowdhuryoshin/30-Days-of-Code-Challenge-HackerRank
/Day03.py
515
4.375
4
# Day03 # Given an integer n to perform the following conditional actions: # If n is odd, print Weird # If n is even and in the inclusive range of 2 to 5 print Not Weird # If n is even and in the inclusive range of 6 to 20 print Weird # If n is even and greater than 20, print Not Weird # The code starts here: n = int(...
58fb02162e52611ed7d41eb1e2c25a3ae93428d6
its-Kumar/Python.py
/2_Lists/has_33.py
273
3.796875
4
def has_33(lst): for i in range(len(lst) - 1): if lst[i + 1] == lst[i] == 3: return True return False print( has_33([1, 2, 3, 4, 5]), has_33([1, 1, 2, 3, 4, 5, 3]), has_33([1, 2, 5, 3, 3]), has_33([3, 4, 5, 3]), )
ac29e00c6917e122b497ff281767e707455f4613
luiz-amboni/extrator-url-python
/main.py
842
3.703125
4
#url = "https://bytebank.com/cambio?quantidade=100&moedaDestino=dolar&moedaOrigem=real" url = " " # Sanitização da URL url = url.strip() # Validação da URL if url == "": raise ValueError("A URL está vazia!!!") # Separa a base e os parâmetros indice_interrogacao = url.find('?') url_base = url[0:indice_interrogaca...
17bfb56ab9c48528950c1bc97727ca6e87342246
cthulhu1988/OpenKattisSolutions
/PythonSolutions/Ladder.py
160
3.875
4
import math from fractions import Fraction height, angle = map(int, input().split()) sinValue = math.sin(math.radians(angle)) print(math.ceil(height/sinValue))
095ce747b2294285cd009511a45bc69099610e41
chas182/magistracy-labs
/python/labs/py-lab-1.py
241
3.5
4
def array_cumulative_sum(arr): res = 0 for number in arr: yield res res += number yield res b = [1, 2, 3, 10, 14] print list(array_cumulative_sum(b)) b = [1, 1, 1, 1, 1] print list(array_cumulative_sum(b))
530e9d11bb5018d848fd4ba9d433fac044aab221
VanditoCodes/school-stuff
/misc/more_dict.py
112
3.78125
4
l = input("Enter a list: ").split() d = {} l1 = len(l) for i in l: d[i]=l.count(i) print (d)
63ea9a19647014663175389d75c12d25f47fcc47
cplyon/leetcode
/design/tweet_counts.py
1,521
3.703125
4
#! /usr/bin/env python3 class TweetCounts: def __init__(self): self.tweet_times = {} self.intervals = { "day": 60*60*24, "hour": 60*60, "minute": 60 } def recordTweet(self, tweetName: str, time: int) -> None: # O(1) if time < 0 or no...
44111d3809b035cdb5bf866e1f152b66e4f46548
kimjy392/TIL
/algorithms/day1/counting sort.py
716
3.53125
4
arr = [0, 4, 1, 3, 1, 2, 4, 1] # 양의 정수, 최대값을 알아야 된다. # 최대값 = 4 cnt = [0] * 5 # 배열의 인덱스 n-1 = 4 # 빈도수 계산 for val in arr: cnt[val] += 1 print(cnt) # 누적 빈도수 계산 for i in range(1, len(cnt)): cnt[i] = cnt[i - 1] + cnt[i] print(cnt) # for val in arr: # cnt[val] += 1 # # 누적 빈도수 계산 # numbers = [] # for i in range(...
3a8625a2938995cf8c073964761c3ffa4c2da69b
MatiasMdelP/CodingChallenge
/MarleyChallenge/MarleyChallenge.py
262
3.765625
4
MAX = 100 N1 = 3 N2 = 5 REPLACE1 = "marley" REPLACE2 = "mirko" REPLACEBOTH = "marleymirko" for i in range(1, MAX): if i % N1 == 0 and i % N2 == 0: print(REPLACEBOTH) elif i % N1 == 0: print(REPLACE1) elif i % N2 == 0: print(REPLACE2) else: print(i)
50bdfb5e8b298ce7b7dc1b946fc79aac6fea6532
hilljaxon/FractalGenerator
/src/Gradients.py
3,813
3.625
4
from abc import ABC, abstractmethod from colour import Color RAINBOW = [Color("blue"), Color("yellow"), Color("red"), Color("green"), Color("orange"), Color("purple")] ZRAINBOW = [Color("blue"), Color("orange"), Color("green"), Color("red"), Color("yellow"), Color("purple")] deep = [Color("blue"), Color("black"), Color...
206c696b82133a64151436f630d1aebaf78e76d4
euan-turner/essentials
/sorting/py/Bubble.py
596
3.9375
4
import random def bubble_sort(arr): for s in range(0,len(arr)-1): finished = True for i in range(0,len(arr)-1-s): if arr[i] > arr[i+1]: ##Flag to detect if sort is already finished finished = False ##Swap items arr[i],arr[i...
5d3f7ade86d7e25862beefa48266a8b4f16c54bc
yuan-na-na/ynnDemo1
/venv/com/ynn/demo/day03/pets.py
366
3.953125
4
#删除包含特性值的所有列表元素 pets=['cat','dog','cat','rabbit','dog','cat'] print(pets) while 'cat'in pets: pets.remove('cat') print(pets) #传递实参 #位置实参 def describe_pet(animal_type,pet_name): print("\nI have a "+animal_type+".") print("My "+animal_type+" 's name is "+pet_name.title()+".") describe_pet('hamster','harry')...
b82b04e080b436c4844601149f0e1d46b1c79532
Shin-jay7/LeetCode
/0504_base_7.py
740
3.703125
4
from __future__ import annotations class Solution: def convertToBase7(self, num: int) -> str: n, ans = abs(num), "" while n: ans = str(n % 7) + ans n //= 7 # print("-" * (num < 0) + ans or "0") return "-" * (num < 0) + ans or "0" class Solution: def c...
86d65140932fdae5bb2b3282d87069802f997253
QDylan/Learning-
/Leetcode/990. 等式方程的可满足性.py
3,488
3.59375
4
class UF: def __init__(self, N): self.parent = [i for i in range(N)] # 记录每个节点的父节点,相当于指向父节点的指针 self.size = [1] * N # 记录着每棵树的重量,目的是让 union 后树依然拥有平衡性 self.count = N # 记录连通分量个数 def union(self, p, q): # 将p,q连通 root_p = self.find(p) # 查询p,q的父节点 root_q = self.find(q) # 将父...
f5e296e5ffc8e5cac00b5fa49cb897141d1e4928
daniloaleixo/hacker-rank
/Algorithms_track/Sorting/QuicksortInPlace/quicksort.py
2,866
4.40625
4
# The previous version of Quicksort was easy to understand, but it was not optimal. It required copying the numbers into other arrays, which takes up space and time. To make things faster, one can create an "in-place" version of Quicksort, where the numbers are all sorted within the array itself. # Challenge # Create...
db385601ac79bcae9c2329e139e3b36153ff4a1e
feiyu4581/Leetcode
/leetcode 101-150/leetcode148.py
1,750
3.96875
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None @classmethod def generate_node(cls, vals): root, current = None, None for val in vals: node = cls(val) if not root: root ...
aa420f7119efacceb45f9491afa3c3a64e7b2487
alenaivanova-ebs/python_course
/task2/task2_5.py
576
3.859375
4
def get_calc(l): """ Создать строку равную всем элементам введенной строки с четными индексами. (считая, что индексация начинается с 0, поэтому символы выводятся начиная с первого, индексы 0,2,4,6….). """ # new_string = '' # for i in l: # if l.find(i) % 2 == 0: # new_stri...
885623b933d16ca7a12fa3b0a9ecbfd1ad5294da
Sudarshan-Patil/Python
/Assignment7/Assignment7_3.py
620
3.796875
4
from Arithmetic import * class Number: def __init__(self, number): self.number = number def showResult(self): if (ChkPrime(self.number)): print("Given number is prime number") else: print("Given number is not prime number") if (ChkPerfect(self.number)): print("Given number is a perfect number") e...
780f79f1fca5c5d9e6cf5c9a34989daa1380d01f
Amad1704/lessson1
/answers.py
278
3.703125
4
answers={"привет": "И тебе привет!", "как дела": "Лучше всех", "пока": "Увидимся"} def get_answer(question, answer = answers): question=question.lower() print(answer[question]) question = input() print(get_answer(question))
28eedbf4a20d6dfd5099cebfae88c6d9826d6a11
adithyabsk/portfoliohut
/portfoliohut/finance.py
1,173
3.890625
4
"""Financial Helper functions""" from collections import namedtuple from typing import Dict, List, Tuple import yfinance as yf TickerDetail = namedtuple( "TickerDetail", ["ticker", "prices", "total_value", "website"] ) def get_current_prices(stock_map: Dict[str, float]) -> Tuple[List[TickerDetail], float]: ...
3dab067e939f6820862ce0d2a3d19ab6795a4901
Arshad-Ahmed/DataSciencePortfolio
/Dataquest/data-analysis-intermediate/Introduction to Pandas-8.py
1,827
4.4375
4
## 3. Read a CSV File into a DataFrame ## import pandas food_info = pandas.read_csv("food_info.csv") print(type(food_info)) ## 4. Exploring the DataFrame ## print(food_info.head(3)) dimensions = food_info.shape print(dimensions) num_rows = dimensions[0] print(num_rows) num_cols = dimensions[1] print(num_cols) first...
06d8b2365bc18b26d0bb149557e8e41885a44731
SeimmyW/CS4SOF
/Color Choice.py
659
4
4
def namecheck(name): if name != "Red": if name != "Blue": if name != "Green" : if name != "Yellow": raise Exception('Invalid Color Choice!') else: print("Yellow is ok I guess..") else: pr...
62be1b214653cfd53d9d941b4663ee892e78a5f5
idobleicher/pythonexamples
/examples/functions-and-modules/modules_example1.py
438
3.984375
4
# Modules are pieces of code that other people have written to fulfill common tasks. # The basic way to use a module is to add import module_name at the top of your code, # and then using module_name.var to access functions and values with the name var in the module. import random for i in range(5): value = rand...
bd1e29f61ac532abaf00b760de61ed4c126e3c7e
amantyagi95/python-beginner-projects
/sum of quare of N no.py
161
3.8125
4
def sum(n): if n==1: return 1 return n**2 + sum(n-1) print(sum(5)) #2nd method sum = lambda n: 1 if n==1 else n**2+sum(n-1) print(sum(12))
dd5162bd82585eadfe63e2ffc46f47991a8fa4f7
soniaabhyankar/MayLeetCodeChallenge
/22_sort_characters_by_frequency.py
472
3.609375
4
class Solution: def frequencySort(self, s: str) -> str: dictionary = {} result = '' for c in s: if c in dictionary: dictionary[c] += 1 else: dictionary[c] = 1 sorted_dict = sorted(dictionary, key = lamb...
bbd065db5b2a15de749d490e2a15fce4c76d7ea4
timyates/RaspberryGreet
/Python/greeting.py
142
3.6875
4
# Print our question and read the response into `name` name = input( 'Enter your name: ' ) # And print our greeting print( 'Hello ' + name )
a2631255e4974043bbd76b8c40909da6113aa0f8
wucy/pythonhomework
/chap10/10-12.py
515
3.8125
4
#!/usr/bin/env python word_list = [] word_file = open('../data/words.txt') for word in word_file: word_list.append(word.strip()) reverse_word_list = [] for word in word_list: r_word = [] for i in range(len(word)): r_word.append(word[i - 1]) delimiter = '' reverse_word_list.append(delimiter...
797a00fe1961d7d6e99fbf3384b2cc1c8072fe98
itsolutionscorp/AutoStyle-Clustering
/assignments/python/wc/src/537.py
259
3.578125
4
from collections import Counter def word_count(string): x = filter(lambda d: d.isalnum() == False, string) f = filter(lambda c: len(c.strip(x)) > 0, string.split()) words = map(lambda m: m.strip(x).lower(),f) cnt = Counter(words) return dict(cnt)
dbc8d38797adb99a80d13a233d8077c577fe8472
Xinchengzelin/AlgorithmQIUZHAO
/Week_02/实战题目/98.验证二叉搜索树.py
1,564
3.765625
4
# # @lc app=leetcode.cn id=98 lang=python3 # # [98] 验证二叉搜索树 # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # class Solution: # def isValidBST(self, root: TreeNode) -> bool: # 1、递归-...
7ea05f6a83c85a847e6bbe1a97d8f78b4c09f7e5
jdajung/autosketch
/part_division.py
6,712
3.8125
4
import math import sys from conversions import * #finds the absolute difference between values in the same position of 2 lists #not used for find_divisions, but maybe useful for testing? def list_abs_diff_cost(part_vals, proposed_vals): if len(part_vals) != len(proposed_vals): cost = -1 print('ERRO...
0cc39d1694b3caec81c40fb4c2f759cb0862c68d
daniel-reich/ubiquitous-fiesta
/JPfqYkt6KGhpwfYK7_12.py
240
3.671875
4
def replace_the(st): st = st.split() lst = [i for i in range(len(st)) if st[i]=='the'] for i in lst: if st[i+1][0] in 'aeiou': st[i]='an' else: st[i]='a' return ' '.join(st).strip()
3d9dd802c8254b12bc36f450e1da81d9a874e959
Jackmrzhou/codewars
/python/get_loop.py
354
3.78125
4
class Node(): pass node1 = Node() node2 = Node() node3 = Node() node4 = Node() node1.next = node2 node2.next = node3 node3.next = node4 node4.next = node2 def loop_size(node): node_list = [] while node not in node_list: node_list.append(node) node = node.next return len(node_list)-node_list.ind...
e2cb0a8e5cbee4ed9f216693fdef0d76f566e706
Indrajeet71/FDS-Programs
/B11(a).py
1,153
3.734375
4
""" a)Write a Python program to store roll numbers of student in array who attended training program in random order. Write function for searching whether particular student attended training program or not, using Linear search and Sentinel search. """ def linearsearch(arr, x): for i in range(...
d1746d35bd49c068e406de31c66f421b817c30ab
SmartDogHouse/SmartDogHouse-Software
/src/test/python/test_motor.py
832
3.640625
4
import unittest from src.main.python.motor import Motor class TestMotor(unittest.TestCase): motor = Motor(99) def test_create(self): m2 = Motor(88) self.assertEqual(self.motor.is_running(), m2.is_running()) m3 = Motor(77, running=True) self.assertTrue(m3.is_running()) ...
41c899bde69302c8d301d3f3b36c23bf842437fe
convolu/string_stats
/test_text_stats.py
3,302
3.984375
4
import unittest import text_stats class simple_unit_tests(unittest.TestCase): ''' Here go the unit test for the text_stats class ''' def test_empty_string(self): ''' When an empty string is passed, an empty dictionary should be returned ''' word_stats = text_stat...
e3cd28c6ba6c87f04a6aac3f364e0be0c13c3cfe
apalaciosc/quantum_python
/clase_02/conversor_monedas.py
623
3.796875
4
def convertir_moneda(tipo_de_cambio, moneda): monto = float(input(f'Hola, ingresa tu monto en {moneda}: ')) monto_dolares = round(monto * tipo_de_cambio, 2) print(f'El monto en dólares es: {monto_dolares}') mensaje = """ Hola, este es un conversor de monedas Ingresa cualquier de estas 3 opciones: 1 = Soles...
19347cb383027acc208dd08ce0a93e34c72e8285
zickymay/pdsnd_github
/bikeshare_final.py
7,746
4.40625
4
# coding: utf-8 # In[4]: import time import calendar as cdr import pandas as pd import numpy as np CITY_DATA = { 'chicago': 'chicago.csv', 'new york city': 'new_york_city.csv', 'washington': 'washington.csv' } def get_filters(): """ Asks user to specify a city, month, and day ...
9012bc887d1e8ec0cf164c6a1ffd6607752953e6
daniel-reich/ubiquitous-fiesta
/EcBpRwgYsbmEWXKB9_23.py
134
3.5
4
def prime(x): x_sqr = int(x ** (1/2)) sum = 0 for i in range(1, x_sqr + 1): if x%i == 0: sum += 1 return sum == 1
ba950b1b4cb4ae76329b3c9ec4537b5cb3f8cd89
HeptaSean/ABNFEarley
/src/abnfearley/grammar.py
23,515
3.546875
4
"""Structure of ABNFEarley grammars. The following classes are provided to define the structure of and programmatically create Grammars: Grammar -- whole grammar consists of rules with names as left-hand sides and GrammarElements as right-hand side GrammarElement is the abstract base class for all of these:...
c28a4a17cb1eb77ad6f326cf9a4a6d413a4c620a
rainamra/ClassAssignment
/1.7.py
1,874
3.8125
4
class Time: __hour : int __minute : int __second : int def __init__(self, hour : int, minute : int, second : int): self.__hour = hour self.__minute = minute self.__second = second def getHour(self) -> str: if self.__hour < 10: return "0" + str(self.__ho...
075ca5d8fa77c2c636ccf650e3b1087bfe284db2
daniel-reich/ubiquitous-fiesta
/3JX75W5Xvun63RH9H_4.py
334
3.546875
4
def describe_num(n): d = { 1: 'brilliant' , 2: 'exciting' , 3: 'fantastic' , 4: 'virtuous' , 5: 'heart-warming', 6: 'tear-jerking' , 7: 'beautiful' , 8: 'exhilarating' , 9: 'emotional' , 10: 'inspiring' } quals = [d[x] for x in d if not n % x] return 'The most {} number is {}!'.format(' '.joi...
6bff6764b42feef84720429f5710ff9a96961d08
daddyotwo/Breaking-the-Code
/mit_6_0001_ps2_hangman_with_hints.py
11,185
3.921875
4
# -*- coding: utf-8 -*- """ Created on Fri Jul 21 10:58:27 2017 @author: Пользователь """ import random import string WORDLIST_FILENAME = "words.txt" def load_words(): # """ # Returns a list of valid words. Words are strings of lowercase letters. # # Depending on the size of the word ...
7155f190515b969445d383f2c01bb899d9e964fb
zyjImmortal/LeetCode
/exercise/reverses.py
2,054
3.515625
4
def reverse(x): """ :type x: int :rtype: int """ tran_list = list(str(x)) if tran_list[0] == '-': reverse_list = tran_list[1:] reverse_list.reverse() for i in reverse_list: if i == 0: reverse_list.remove(i) else: br...
7a5297deb82fd6c5c280d494f3154cf12904fc50
jnash67/eulerpython
/euler41.py
1,910
3.890625
4
import math import collections # find largest pandigital prime # let's first see if there's any 9 digit pandigital primes and take the largest of those # there are no pandigitals greater than 9 digits def num_digits(n): d = int(math.log10(n))+1 return d # pandigital use all digits from 1-9 # num-digit pandig...
0c56601a293ca56389f5ed18e74494b3e403f662
Valvar00/Python
/content1.py
7,258
3.546875
4
# -------------------------------------------------------------------------- # ---------------- System Analysis and Decision Making -------------------- # -------------------------------------------------------------------------- # Assignment 3: Logistic regression # Authors: A. Gonczarek, J. Kaczmar, S. Zareba # 2...
31add78949b1658c8901570f8342bdbb40addaf7
SteveBlackBird/EM_HW
/Chapter_5/5_8_EM.py
274
3.578125
4
# Hello Admin user_names = ['steve', 'mark', 'jenny', 'admin', 'sergio'] for name in user_names: if name == 'admin': print(f"Hello {name}, would you like to see a status report?") else: print(f"Hello {name.title()}, thank you for logging in again")
fb10929fbed7bea2e23dee696ad3699c0c754fef
kishore12141214/MY_SCRIPTS
/lesthanorequal.py
146
3.953125
4
#!/usr/bin/python2.7 num=input('enter the value:') if num >= 10: print "value is grater than 10" else: print "value is less than 10"
c1de45ddc8f0caaf47831190df3d3750ad9ee605
zepler2011/leetcode_solution
/zshen/dp-dfs/word-square-2.dfs+trie.py
3,193
4.03125
4
class TrieNode: def __init__(self): self.children = {} self.isWord = False self.word = None class Trie: def __init__(self): # do intialization if necessary self.root = TrieNode() """ @param: word: a word @return: nothing """ def insert(self, wor...
9a45eaec03afa1b549b93fe6d6ac49a2e92f9ab8
YaniVerwerft/Python
/Exercises/3_Iteration/Exercise_5.py
635
4.125
4
number = int(input('Enter a number:')) smallest = False biggest = False while number != 'Done': if number == 0: number = 'Done' else: if (number > biggest or biggest == False) or (number < smallest or number == False): if number > biggest or biggest == False: biggest...
0ac9a25d3aae481f143501430ff370e9cad86f9c
Dummy-Bug/Love-Babbar-DSA-Cracker-Sheet
/Binary Trees/22 Construct a Binary Tree from Inorder and Preorder.py
933
3.75
4
class Solution: def buildTree(self, inorder: List[int], postorder: List[int]) -> Optional[TreeNode]: self.lookup = dict() # lookup table to get the index of element in inorder array. for index , element in enumerate(inorder): self.lookup[element] = index ...
c7ce30ff1a47c6e327af32322e40e12288c2d546
BiancaStoecker/cpinsim
/cpinsim/protein.py
3,098
3.5
4
# -*- coding: utf-8 -*- from bitarray import bitarray class Protein: """ Representing a protein instance in the simulated cell. Contains the state of the protein in it, a pointer to the protein-type and the neccesary methods for protein interaction. """ def __init__(self, name, protein_po...
ee7ba7381e2b2f348a4c678c3f2d83d2ad535e4c
Aasthaengg/IBMdataset
/Python_codes/p03399/s931211831.py
151
3.625
4
a=int(input()) b=int(input()) c=int(input()) d=int(input()) ans=0; if a>b: ans+=b else: ans+=a if c>d: ans+=d else: ans+=c print(ans)
438d387f1f46369910f733bb46723bb5e362781b
VinayakBagaria/Python-Programming
/New folder/Weird and Not weird.py
226
4.09375
4
n=int(input()) if n%2==0: str='Weird' else: str='Not Weird' if n>=2 and n<=5 and n%2==0: str='Not Weird' if n>=6 and n<=20 and n%2==0: str='Weird' if n>20 and n%2==0: str='Not Weird' print(str)
c0545e79bb28af09629c6c51d184428a5de0c436
vikash-india/DeveloperNotes2Myself
/languages/python/src/concepts/P098_Closures_NestedFunction.py
961
4.375
4
# Description: Nested Functions """ ### Nested Functions * A function which is defined inside another function is known as nested function. * Nested functions are able to access variables of the enclosing scope. * In Python, these non-local variables can be accessed only within their scope and not outside their scope....
a0c3cabed76f840ddbbc2953866099b77f4f7365
daniel-laurival-comp19/slider-game-1o-bimestre
/getBlankPosition.py
235
3.625
4
def getBlankPosition(board): # Return the x and y of board coordinates of the blank space. for x in range(BOARDWIDTH): for y in range(BOARDHEIGHT): if board[x][y] == BLANK: return (x, y)
549b65d9a04e3dcaca59268c471b54a04402e90b
123tian/vue
/--master/web/006.通过send启动生成器.py
483
3.90625
4
def create_num(all_num): a,b = 0,1 current_num = 0 while current_num < all_num: ret = yield a print("---ret------",ret) yield a a,b = b, a+b current_num+=1 #如果在调用函数的时候,发现函数中与yield,那么此时不再是调用函数,而是创建一生成器 obj = create_num(10) #如果已创建生成器就send会报错,yeild,也没有ret去接受 obj.send(None) ret = next(obj) pr...
2f8c568f80c216a79fc95e66cbf10f36cce8f188
JaeD42/CUNOCR
/lib/DisjointSets.py
977
3.9375
4
class DisjointSets(object): """ Helper class to create Datasets """ def __init__(self,arr=[]): """ Initialize with list :param arr: """ self.sets = [set([i]) for i in arr] self.is_set = [True for i in arr] def in_same(self,a,b): """ ...
3267dc319c6e96afd1979b22a7a493ad0da9c925
lbczk/levenshtein
/edit.py
2,893
3.75
4
import numpy as np class Edit(): """ Computes the edit distance between s1 and s2 using a classical dynamic programming approach. >>> Edit("", "a").distance() 1 >>> Edit("a", "b").distance() 1 >>> Edit("aa", "a").distance() 1 >>> Edit("abcdef", "abd...
0002d695278e3f7a82c47da42daa221336f891df
natesb3/HelloWorld
/Team3.py
1,346
3.890625
4
import Fighter # here we declare your fighter class Team3(Fighter.Fighter): # this is your constructor, it runs when you create your fighter def __init__(self, name="Hillary"): # this command tells your fighter to use the constructor I made in # the Fighter class (which is this class's super...
491b4626c91da8b16f8f873053491dd396edd00c
MedAziz11/Algorithms
/Node.py
724
3.875
4
class Node(object): """Directed Node""" def __init__(self, key, neighbors={}): self.key = key self.neighbors = neighbors#all the succ to a Node def addNeighbor(self, neighbor, cost=0): self.neighbors[neighbor] = cost def getNeighbors(self): return s...
33ff546ccc82a380861d3a0a92c848e99ad53f63
99ashr/PyCode
/Infytq/Programme_Name/calendar.py
283
3.859375
4
#!/usr/bin/Python3 # importing calender to display calendar import calendar #date module can give current date and time import datetime as d date=str(d.datetime.now().date()) # year=str(date[0:4]) year=2019 month=8 # month=str(date[5:7]) cal=calendar.month(2019,8) print(cal)
dd6627b7d59ab1e861132c0f44b92bbd8939a932
izeus1/python-ch2.1
/assignment.py
465
4
4
# 치환문 예 a=1 b=a+1 print(a, b) # 변수값 할당 오류 # 1 + a = c e = 3.5; f = 5.3 print(e, f) e ,f = 3.5, 5.3 print(e, f) # 같은 값을 여러 변수에 할당할 때 x = y = z = 10 print(x, y, z) # 동적 타이핑: 변수에 새로운 값이 할당되면 기존의 값을 버리고 # 새로운 값(타입)으로 치환된다. a = 1 print(a, type(a)) a ="hello" print(a, type(a)) # 확장 치환문 a = 10 a += 10 print(a) ...
4d3c6c24c780803a26f4103729199e593aedd898
xin3897797/store
/day2_2.py
308
3.8125
4
# 输入10个数字,打印最大的数、和、平均数 list_ten1 = [] for i in range(10): a = int(input("输入第{}个数字:".format(i+1))) list_ten1.append(a) print("最大值:", max(list_ten1)) print("求和:", sum(list_ten1)) print("平均数:", sum(list_ten1)/len(list_ten1))
f3adf09dbc474bb1742f7969940c4468e6553bb3
RenanSiman/Inteligencia-Artificial
/aestrela.py
3,331
3.5625
4
import networkx as nx from queue import PriorityQueue def criaGrafo(file): """Builds a weighted, undirected grafo""" grafo = nx.Graph() for line in file: # insere em 'v1' e 'v2' as cidades e em 'w' as distancias v1, v2, w = line.split(',') # retira os espacos em branco da s...
b255592eefac512255fb6ed321ecc5b86adfdbf9
jkvasagar/tn_map
/map.py
4,359
3.6875
4
class priorityDictionary(dict): #Initialized as binary heap of dicitionary def __init__(self): #Used to optimize graphs self.__heap = [] dict.__init__(self) def smallest(self): if len(self) == 0: return heap = self.__heap while heap[0][1] not in sel...
59cda60243180d3f145b81497b9accdb396907bd
yyywxk/Python-Experiment
/2.2.py
525
3.96875
4
def Conjecture(n): c=0 while(n!=1): c=c+1 if n%2==0: n=int(n/2) print("此时N为偶数,第"+str(c)+"次变换的结果是: "+str(n)) else: n=int(n*3+1) print("此时N为奇数,第"+str(c)+"次变换的结果是: "+str(n)) print("该数共经过"+str(c)+"次变换,得到自然数1") return n=int(inpu...
c0d490e621251c68a73ed41a64ede3836c9b676f
samisverycute/python20210203
/3-4.py
605
3.828125
4
math=[] total = 0 high = 0 low = 100 n = int(input("How many people in this class")) for i in range(n): stuname = input('Please input the name:') score = int(input("Please input the score:")) total = total=+score math.append(stuname) math.append(score) for i in range(1,n*2,2): if mat...
41d9dd534aa54118c23ec469ac39f61d41861e0a
olivethomas/DSA
/8/8-9.py
1,450
3.703125
4
#implement cyclic right shift for singly linked lists class node(): def __init__(self, data=None, next_node=None): self.data = data self.next_node = next_node def get_data(self): return self.data def get_next(self): return self.next_node def set_next(self, new...
d83fa29bc3aee7672ad5557064572731682ab13c
fgokdata/python
/extra/scope.py
543
3.90625
4
name = 'john' # global parametres age = 36 def hello(): name = 'ali' # local parametres in fuctions !!! age = 20 return f'my name is {name} and i am {age} years old' print(hello()) print(name) ################ x = 'global' def myfunc(): x = 'local' return x print(x) print(myfunc()) #####...
54476d5a03a05794d40606e702dbb59ef4179323
c940606/leetcode
/笔试/英伟达2.py
402
3.59375
4
# -*- coding:utf-8 -*- from collections import Counter class Solution: def __init__(self): self.c = None # 返回对应char def FirstAppearingOnce(self): # write code here cnt = Counter(self.c) for a in c: if cnt[a] == 1: return a return "#" ...
ab269c328eec7de3bd1e1835481101b38de0ea88
leanardos/CS50x
/pset6/readability.py
831
3.78125
4
from cs50 import get_string # Getting text input from the user text = get_string("Text: ") # counting sentences by looking for dot, question and exclenemation mark sentences = text.count(".") + text.count("!") + text.count("?") # whitespaces white_spaces = text.count(" ") # would be better just to check with ascii ...
719c1850c3a09cd468a26aab3bbe9a676436fae8
sawaseemgit/Pymongo
/CRUD.py
618
3.546875
4
import pymongo from pymongo import MongoClient client = MongoClient() db = client["mydatabase"] # alternate way # db = client.mydb Users = db.users # users(=collection)=>tables in mysql # define records user1 = {'username': 'bob', 'password': 'abc789', 'stu_id': '23', 'hobbies': ['python', 'games']} # Add Single reco...
c5483b8fbc19d9dde7f6463102901e855979c06a
Daniel-Loaiza/CodingSamples
/HelloWorld.py
639
4.15625
4
def greet(who="World"): """Prints a greeting to the user >>> greet(Pedro) Hello Pedro! """ print ("Hello "+who+"!") if __name__=="__main__": greet() #Calls the function to print the default option greet(who='amigo') #Calls the function to print with a specific argument name='' whi...
2d5d10304850f3468c9c4dbf71384bdd22756fff
joyzo14/advent_of_code_2020
/day8_2020.py
1,884
3.734375
4
import re def solve(input): index = 0 accumulator = 0 lines = input.splitlines() listOfIndexes = [] numberOfLines = 0 for line in lines: numberOfLines += 1 while True: instructionPerLine = re.search('(^.{0,3}) ([-/+])(\d*)', lines[index]) instruction ...
259d44a5c886c1bfea90721560dcb101cd4d8df1
udaykumarbpatel/PyInterview
/InterviewCake/ReverseLinkedList.py
1,774
4.25
4
class ListNode: def __init__(self, value): self.value = value self.next = None class MyList: def __init__(self): self.head = None def append(self, value): node = ListNode(value) if self.head is None: self.head = node else: current = ...
a312cf0680f3ea44e56c3894d55e17474995afe9
shruti-mathur/Python-Projects
/DataHandling/Python_Demo.py
340
3.9375
4
# Basics of calc x = input("Enter the first number : ") y = input("Enter the second number : ") # Type casting add = int(x) + int(y) sub = int(x) - int(y) mul = int(x) * int(y) div = int(x) / int(y) print("addition is: ", add) print("subtraction is: ", sub) print("multiplication is: ", mul) print("di...
34f7486ee4bf5981a96b1c43c7df2863c43048fc
Bobby981229/Python-Learning
/Day 03 - Branch Structure/Triangle.py
438
3.625
4
""" 输入三条边长,如果能构成三角形就计算周长和面积 """ a = float(input('a = ')) b = float(input('b = ')) c = float(input('c = ')) if ((a + b) > c) and ((a + c) > b) and ((b + c) > a): print('三角形周长: ', a + b + c) p = (a + b + c) / 2 s = (p * (p - a) * (p - b) * (p - c)) ** 0.5 # 海伦公式 **0.5 开根号 print('三角形面积: %.2f' % s) else: ...
107c1988e584fc865d401abfcce39cc095fc663d
anthony20102101/Python_practice
/practice/LeetCode/EverydayPrac/43.py
1,111
4.0625
4
# 给你单链表的头节点 head 和两个整数 left 和 right ,其中 left <= right 。请你反转从位置 left 到位置 right 的链表节点,返回 反转后的链表 。 # # 输入:head = [1,2,3,4,5], left = 2, right = 4 # 输出:[1,4,3,2,5] # Definition for singly-linked list. # class ListNode(object): # def __init__(self, val=0, next=None): # self.val = val # self.next = next ...
f57d40b8879adbc636f1765b3873031452023ff1
AdamZhouSE/pythonHomework
/Code/CodeRecords/2249/60901/309773.py
417
3.828125
4
inf = input() + input() if inf == '21,2': print(17) elif inf == '31,1,1': print(14) elif inf == '32,2,2': print(21) elif inf == '12': print(5) elif inf == '23': print(2) elif inf == 'ababa': print('aaabb') elif inf == '2.0000010': print('1024.00000') elif inf == 'aaab': print('') elif in...
da790a1db84c2788a3ebbe4e2ac89deb30812c8f
architsangal/Python_Assignments
/a2/Q5.py
269
3.5625
4
from Q5input import * # Your code - begin output = [] if(len(l)>=n and n>0): #Not a valid input if n is negative for i in range(n,len(l)): output.append(l[i]) for i in range(0,n): output.append(l[i]) else: output("Invalid Input") # Your code - end print output
cf23ddd3405a996ce0ab8561a677cd1ab050664d
TimotheeAnne/stage-m2
/gym_flowers-armToolsToys/gym_flowers/envs/mazes/maze_generator.py
5,730
3.921875
4
# -------------------------------------------------------------------- # An implementation of the "Recursive Division" algorithm. # The maze descriptor is a numpy array saved in .txt, 1 for wall pixels. # The corresponding image and the dictionary of parameters are saved in # .png and .pkl (pickle) respectively. # Par...
a47a056fc2270f05c84780401aeb3d482a4754a2
normanc529/Module-1-Challenge
/module_1_challenge.py
12,125
4.375
4
import csv from pathlib import Path csvpath = Path('inexpensive_loans.csv') #print(csvpath) check file path relative #print(csvpath.absolute()) check file path absolute """Part 1: Automate the Calculations. Automate the calculations for the loan portfolio summaries. First, le...
965b267b0af2cda4e77bca4cce1873f0d14010d0
GlenHaber/AdventOfCode
/2016/day1.py
691
3.53125
4
pos = (0, 0) direction = (0, 1) visited = {pos} first_revisit = None def turn(LR): global direction if LR == 'L': direction = (-direction[1], direction[0]) elif LR == 'R': direction = (direction[1], -direction[0]) with open('day1.txt') as f: steps = f.read().split(', ') for step in ...
ed519708b0f46cade416af3a359df6c7af0a42be
bhatiakomal/pythonpractice
/Practice/Practice93.py
816
4.03125
4
def show(): monthlyLoan=int(input("How much pay you for ur mothly loan")) monthlyInsurancePayment = int(input("How much pay you for ur Insurance Payment")) monthlyGasPayment = int(input("How much pay you for ur gas payment")) monthlyOilPayment = int(input("How much pay you for ur oil payment")) mont...
1a9118d0f7b9c0ff6f2a8171a133a3336eff7cc6
liupy525/LeetCode-OJ
/23_Merge-K-Sorted-Lists.py
2,108
4.03125
4
#!/usr/local/env python # -*- coding: utf-8 -*- ''' Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. ''' import random # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None from heapq import hea...
7b9dd797c549aa5beaf0b685d238708a96343727
noaheli/Computer-Science
/asdasdasd.py
404
4.125
4
anExampleList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] for item in anExampleList: print item print "" for item in range(11, 20, 1): print item print "" for item in range(99, 0, -2): print item print "" ExampleList2 = [] for item in range(0, 5, 1): print "Enter a number" userinput = raw_input() ...
9a7bbeddfd7668f73418da6cb5ebbebc9d5d1c8d
danielholmes839/Sobel-Operator
/main.py
1,813
4.09375
4
# Daniel Holmes # 2019/1/6 # Sobel Operator # Takes an image from a file or url and outline the edges using a sobel operator import os from functions import sobel_from_file, sobel_from_url while True: file_or_url = str(input('image from file or url: ')) # choose to get an image from a url or a file ...
0641b3f6a03a38da8802eaf75e98a4d65577b139
hellflame/leetcode
/345.reverse_vowels_of_a_string.py
1,627
3.71875
4
# coding=utf8 # https://leetcode.com/problems/reverse-vowels-of-a-string/#/description # Easy # C Version """ int is_vowel(char a){ if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u' || a == 'A' || a == 'E' || a == 'I' || a == 'O' || a == 'U'){ return 1; } return 0; } char* reverseVowels...
f9bc9bf2cdcdeae336cd299a7ddbd15636378b0c
tomasolodun/kolokvium
/53.py
477
3.65625
4
'''В масиві X (1: n) кожен елемент рівний 0, 1 або 5. Переставити елементи масиву так, щоб спочатку розташовувалися всі нулі, потім все одиниці, а потім всі п'ятірки. Додаткового масиву не заводити. ''' from random import randint array = [randint(0, 1) if i % 3 == 0 else 5 for i in range(int(input()))] print(sort...
546050647bc8afee0b285928c0bcdf5d4dffee6d
Sebelino/dotfiles
/scripts/pad.py
500
3.5625
4
#!/usr/bin/env python import os import sys if __name__ == '__main__': if len(sys.argv) != 2: print("Usage: pad.py <directory>") sys.exit(1) directory = '.' filenames = os.listdir(directory) max_filename_length = max(len(name) for name in filenames) for name in filenames: h...