blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
aeb3f6aa657ebefacc56affd351f7c421718f86a
Snehal-610/Python_Set
/set1/dbu_program049.py
373
4.40625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # program 49 : # Write a program which can map() to make a list whose # elements are square of numbers between 1 and 20 (both included). # Hints: # Use map() to generate a list. # Use lambda to define anonymous functions. result = map(lambda a : a**2,[i for i in range(1,21)...
4e185ba1567e2ad2aba2c38038dbb69cd3dcd7d0
mrfox321/leetcode
/leetcode/p456.py
598
3.796875
4
def find132(nums): if len(nums) < 3: return False stack = [[nums[0],nums[0]]] for i in xrange(1,len(nums)): for interval in stack: if interval[0] < nums[i] and nums[i] < interval[1]: return True elif interval[1] < nums[i]: interval[1]...
fde10b0c8de28eb6f5ee3f29614ee16f039eedd3
kav2k/AoC
/template/solver.py
497
3.71875
4
"""AoC 201X.XX problem solver. Takes input from STDIN by default. """ import sys def solver(file): """ Take a file object with input and solve AoC 2015.XX problem on the input. Keyword arguments: file --- a file object to read input from """ answer_a = 0 answer_b = 0 return (answer_a, answ...
0dbe3a3d2316d222ace4aa0efcb4e24bbd3ed0b5
hyj1116/LeetCode-HYJ
/1-Easy/283. Move Zeroes/283. Move Zeroes.py
1,164
3.5
4
class Solution: def moveZeroes(self, nums): """ Do not return anything, modify nums in-place instead. """ # res = [] # for i in range(len(nums)): # if nums[i] != 0: # res.append(nums[i]) # nums.pop(i) # res.extend(nums) ...
9c0fa53e8644f2aedb03862ab9e8e3ad1ed130bc
rachel6854/Python-Projects
/python_iterators/prime_factors_generator.py
315
3.765625
4
from math import ceil, sqrt def get_prime_factors_generator(num): if num < 2: return [] prime = next((x for x in range(2, ceil(sqrt(num)) + 1) if num % x == 0),num) return [prime] + get_prime_factors_generator(num // prime) for x in get_prime_factors_generator(17): print(x)
6d9113c46439fb22d577725043f019c5b4a8686a
AlanLozz/ejercicio-regresion-lineal
/index.py
1,611
3.734375
4
import numpy as np #Librería numérica import matplotlib.pyplot as plt # Para crear gráficos con matplotlib from sklearn import datasets, linear_model from sklearn.model_selection import train_test_split boston = datasets.load_boston() #Cargar el dataset print(boston.keys()) # Mostrar las claves del dataset print(bosto...
af07a07b253d233e76afa03cc43085e52980aea0
vinija/LeetCode
/151-reverse-words-in-a-string/151-reverse-words-in-a-string.py
697
3.609375
4
from collections import deque class Solution: def reverseWords(self, s: str) -> str: left = 0 right = len(s) -1 while left <= right and s[left] == " ": left +=1 while left <= right and s[right] == " ": right -=1 loca...
33da87582045e6b81db1621a2ffde411f5c473f0
wjqmichael/workspace
/leetcode/edit_distance.py
544
3.671875
4
def min_distance(word1, word2): if len(word1) > len(word2): sw, lw = word2, word1 else: sw, lw = word1, word2 dp = range(len(sw) + 1) for i in xrange(1, len(lw) + 1): old = dp[:] dp[0] = i for j in xrange(1, len(dp)): dp[j] = min(dp[j - 1] + 1, old[j]...
344dc514ce45fad7c6c59a206ef0db72b33a0f54
egorbolt/studying
/tooi/lab8/lab8a.py
338
3.5625
4
class A: def __init__(self, number): self.number = number class B: def __init__(self, number): self.number = number def changeNumber(self, c, newValue): c.number = newValue a = A(5) a2 = A(100) b = B(10) print(a.number) print(a2.number) print(b.number) print() b.changeNumber(a, 1...
911511346e14c1f845ae3726d5040103107055c3
turganaliev/python_basics
/python_files_and_exceptions/data_storage/data_storage.py
3,896
4
4
#Функции json.dump() и json.load() import json numbers = [2,3,5,7,11,13] filename = 'numbers.json' with open(filename, 'w') as f_obj: json.dump(numbers, f_obj) import json filename = 'numbers.json' with open(filename) as f_obj: numbers = json.load(f_obj) print(numbers) #Сохранение и чтение данных, сгенериро...
1c877a8d639e43cfa370f418eae3607011a1d3f0
kenma34567/Codeforces
/String Task.py
205
3.65625
4
Vowels = {'a', 'e', 'i', 'o', 'u', 'y'} x = input() x = x.lower() for i in x: if i in Vowels: x = x.replace(i, "") y = '' for i in range(len(x)): y += '.' y += x[i] print(y)
6cff2e62da2d80bb25230ce098edc6fa96c9177f
swang2000/CdataS
/Practice/AWS_numberoccur.py
707
4.03125
4
''' Count number of occurrences (or frequency) in a sorted array 2.6 Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[]. Expected time complexity is O(Logn) ''' def binarysearch(a, x): n = len(a) if n ==0: return -1 else: if a[n//2]== x: ...
522a33bff9eae062ebc8c26f85d5c0a7cb686804
SauravSuman0918/IITBombayX-PYTHON101x-solution
/GPA5.py
400
3.515625
4
def oddeven(lst): counteven=0 countodd=0 mst=[] j=0 m=1 for i in lst: if i%2 !=0: j=j+i countodd+=1 else: counteven+=1 m=m*i mst.append(j) mst.append(m) return tuple(mst) # changes in main.py # ans =...
dd3bc29b029f3f2f3858d856d5c2586960378b3a
sauravvgh/sauravreacts.github.io
/46.py
191
4.0625
4
#Write a Python program to find the length of a tuple #create a tuple tuplex = tuple("w3resource") print(tuplex) #use the len() function to known the length of tuple print(len(tuplex))
ab488c0b56496a78c7d4960df3497465341fa018
OOYUKIOO/Lin-Sharon_Chen-Yuki
/occupation_Method2.py
984
3.796875
4
# Sharon Lin and Yuki Chen # SoftDev1 PD8 # HW01 -- Divine your Destiny # 2016-09-15 import csv, random #dictionary jobs = dict() #variable to keep track of which percentile we are up to percentile = 0.0 #read csv file with open('occupations.csv','r') as csvfile: f = csv.reader(csvfile) for row in f: i...
7229fec857825f69f9dc6e230eef39522792fa33
rishavrajjain/hello-world
/Python/palindrome.py
149
3.78125
4
a=input(); l=len(a) b=[] for i in range(l-1,-1,-1): b.append(a[i]) r=''.join(b) if r==a: print('Palindrome') else: print('Not a palindrome')
7d1eb04335b08cf7c944171fd7e2497c034d6add
trosh/feutreballe
/feutreballe.py
3,029
3.65625
4
#!/usr/bin/env python3 """ Statistiques du Feutre-Balle On m'a dit que ce script pourrait être plus générique qu'au seul usage du Feutre-Balle. De telles hérésies sont à proscrire. """ # pylint: disable=too-few-public-methods class Record(): """ A numeric record, which can be beaten """ best = None ...
2571674cf96489c87e7a946d3a78a392ce999ad0
Anuragsekhri/hospital
/venv/Scripts/entepatientdata.py
7,557
3.5
4
# import openpyxl and tkinter modules from openpyxl import * from tkinter import * # globally declare wb and sheet variable # opening the existing excel file wb = load_workbook('C:/Users/Lenovo/Desktop/Book1.xlsx') # create the sheet object sheet = wb.active def excel(): # resize the width of columns in ...
75b348ffc62431f47744af2e893553c2cb8433af
kobechenhao/1807
/10day/7-排序.py
80
3.5
4
list = [10,8,40,56,100,2] list.sort(reverse=True)#从小到大 print(list)
7424ff76fbdd3c760521908b42f220bf7f3a64f8
aleksds/teaching
/misc.py
1,087
3.6875
4
# Aleks Diamond-Stanic # 13-Sep-2016 import numpy as np # consider mean and standard deviation of three position measurements x = np.array([0.751, 0.745, 0.753]) print('x mean: ', np.mean(x)) # print the mean with three decimal places print('x mean: {0:5.3f}'.format(np.mean(x))) print('x std: ', np.std(x)) # print th...
4fd38911d78acfef85bc052c1c6af6612a3c03bf
danielspottiswood/ML_Connect_4
/model.py
2,900
3.703125
4
from game_setup import connect4 from heuristics import score import copy from random import randint def minimax(game, depth, computer): #print("Initial Board:") #game.display_board() if(computer == 1): maxi = -10000 max_row = [] for row in range(7): #print("For Row Numer...
0d75414532965932cd5f32e2a88714fcd97895b4
siyuchen712/temperature-profile-analysis
/obsolete/helper_functions.py
128
3.6875
4
##### helper functions def shorterLengthOf(a, b): if len(a) < len(b): return len(a) else: return len(b)
9676846f1fbce341c74ab1da46255bc2fba4b7ca
wuxu1019/leetcode_sophia
/medium/dp/test_583_Delete_Operation_for_Two_Strings.py
2,137
3.90625
4
""" Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string. Example 1: Input: "sea", "eat" Output: 2 Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea". Note:...
083ec8e3ef85733e0d2237759abdc2431250d1fc
fiscompunipamplona/taller-basicpython-darwin-77
/ejercicio1.py
114
3.546875
4
print("ejercicio 1") yi=input("diite la altura yi:") t=input("digite el tiempo t:") g=9.8 print(yi-0.5*g*(t**2))
041914f77050ee1965c7032a692e0018bdc3bf5e
seeprybyrun/project_euler
/problem0035.py
1,264
3.765625
4
# The number, 197, is called a circular prime because all rotations of the # digits: 197, 971, and 719, are themselves prime. # # There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, # 71, 73, 79, and 97. # # How many circular primes are there below one million? import numbertheory as nt import ...
fe758947d1bccc9630aef0a1a2840dae79059497
karenyyng/Fall14_Phy102
/Lab 2/lab_2.py
1,798
4.125
4
# lab_2.py # # Author: # Student ID: # # This library was written as part of Physics 102: Computational Laboratory # in Physics, Fall 2014. # import required libraries # Exercise 1 def make_regular_array(x, num_points): """create numpy array with evenly spaced points Arguments ========= x = numpy arr...
d733ded77b845e1ab699d86c7a400502665208e4
UWPCE-PythonCert-ClassRepos/SP_Online_Course2_2018
/students/HiroyukiTakechi/Lesson7/assignment1/query_db.py
1,341
3.640625
4
""" Assignment 1: Query the database table Finally, produce a list using pretty print that shows all of the departments a person worked in for every job they ever had. """ from create_db import * from populate_db import * import logging import pprint logging.basicConfig(level=logging.INFO) logger = l...
added6a5d5648f8c372b34745b58f11b5ad68b5a
tigranmovsisyan123/introtopython
/week3/practice/problem6.py
134
3.5625
4
list5 = ["a","s","d","f","1","2","3", "5", "6"] newlist5= list5.copy() del newlist5[4:6] newlist5.pop(0) print(list5) print(newlist5)
a19e47ba10cead12b37cafbf523ec8203c4f6d31
hellozepp/iotest-pyy
/iotestpy/oop/slots1.py
420
3.609375
4
class Some: __slots__ = ['a','b','d'] s=Some() s.a="aaa" s.b="bbb" # s.__slots__.append("c") print(s.__slots__) # s.c="xxx" #此属性由于slots没有预先配置,因此不可加入 s.d="xxx" print("="*50+"1") #======================================================= class Some: __slots__ = ['a','b','__dict__'] s=Some() s.a="aaa" s.b="bbb"...
4d46ff52b8d5165d539af54450956580d78d4dab
ZHANGSTUDYNOTE/s_python
/04-进阶语法/04-3-线程.py
546
3.703125
4
import threading import time # 线程可以共享全局变量(可能会有数据不同步或数据错误) g_num = 100 def test1(): global g_num for i in range(30000000): g_num += 1 print("test1-g_num=%d" % g_num) def test2(): global g_num for i in range(300000000): g_num += 1 print("test2-g_num=%d" % g_num) print("creat...
06c1df64a7c2b64a25cc958e0f10872886ba0e7f
CrazyITDream/DataStructuresandAlgorithms
/Recursions/RecursionVisual.py
1,181
3.90625
4
# -*- coding: utf-8 -*-# # ------------------------------------------------------------------------------- # Name: RecursionVisual # Author: xiaohuo # Date: 2020/4/3 # Prohect_Name: data_structure # IEDA_Name: PyCharm # Create_Time: 16:59 # ---------------------------------------------...
96cfbfb8d404dcf6071b6d2a2ecb62b85a9b12f9
pi-2021-2-db6/lecture-code
/aula22-24-listas-ii/historicos.py
988
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Cria um historico estatico das notas de 5 alunos em 5 disciplinas. Demonstra como acessar os elementos de uma matriz. @author: Prof. Diogo SM """ historicos = [[0.0] * 5, [0.0] * 5, [0.0] * 5, [0.0] * 5, [0.0]...
10c8b4decadba8fae1687d06a73190d8eed1e713
ksayee/programming_assignments
/python/CodingExercises/CousinsBinaryTree.py
2,879
4.15625
4
''' Check if two nodes are cousins in a Binary Tree Given the binary Tree and the two nodes say ‘a’ and ‘b’, determine whether the two nodes are cousins of each other or not. Two nodes are cousins of each other if they are at same level and have different parents. Example 6 / \ 3 5 / \ / \ 7 8 1 ...
c625d7cdbe5785d0695e4d7a0f970c3a047e107d
dongxinghuashao/practise
/list.py
333
3.703125
4
''' Number String List Tuple Sets Dictionary ''' my_list=["你好",2018,"milesfashion",2020,2020,2020] # help(my_list) # print(len(my_list)) # print(my_list[0]) # print(my_list[1:3]) # my_list.append("5000") # print(my_list) # my_list.remove("milesfashion") # print(my_list) print(my_list.count(2020)) print(my_list.count("...
5b99c6ce787e935c5bc8e885c3566901a14b524f
zplab/zplib
/zplib/image/maxima.py
1,459
3.65625
4
import numpy from scipy import ndimage def find_local_maxima(image, min_distance): """Find maxima in an image. Finds the highest-valued points in an image, such that each point is separted by at least min_distance. If there are flat regions that are all at a maxima, the enter of mass of the regio...
141ebd0df650565d5f2ed210014463d260ac9597
hazemabdo15/Function-Task
/Function_Task.py
462
3.8125
4
#https://github.com/hazemabdo15/Function-Task.git def check_div (list=[1,2,3,4,5,6], num=2): print("The numbers in ", list1, "that are divisible by", num,"are:") for i in list: if i % num == 0 : print(i) list1 =[] print("Enter Length of list :") len = int(input()) print("Enter Num...
816ae53d38f3b843c211c696381febc8aea7df87
sprinzs123/study
/stack.py
538
3.9375
4
class Stack: def __init__(self): self.start = [] def push(self, data): self.start.append(data) def pop(self): return self.start.pop() def peek(self): return self.start[-1] def result(self): return self.start def reverse(self): fin = '' ...
81af6f93215b81aaf7176e77db00680b8cc72044
samprasgit/leetcodebook
/python/49_GroupAnagrams.py
755
3.875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/2/28 5:00 PM # @Author : huxiaoman # @File : 49_GroupAnagrams.py # @Package : LeetCode # @E-mail : charlotte77_hu@sina.com class Solution(object): def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[...
6453e568fe02029640e7b2754de6d74d841ba793
7ulyWzh/leetcode_python
/editor/cn/[167]两数之和 II - 输入有序数组.py
1,914
3.78125
4
# 给定一个已按照 升序排列 的整数数组 numbers ,请你从数组中找出两个数满足相加之和等于目标数 target 。 # # 函数应该以长度为 2 的整数数组的形式返回这两个数的下标值。numbers 的下标 从 1 开始计数 ,所以答案数组应当满足 1 <= answer[0] # < answer[1] <= numbers.length 。 # # 你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素。 # # # 示例 1: # # # 输入:numbers = [2,7,11,15], target = 9 # 输出:[1,2] # 解释:2 与 7 之和等于目标数 9 ...
20fd7ca651119ab160b5d0fd8466510f4a48ddf6
mansal3/Python-From-Scratch
/regularexpreesionpython.py
2,512
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 7 07:39:29 2019 @author: manpreetsaluja """ #REGULAR EXPRESSION #A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expressi...
0066ee50612c6e8941724e67525d253e3b4c4c0d
pvardanis/Deep-learning-with-neural-networks
/Codes/sentdex/RNN_examples/RNN.py
2,866
3.875
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data from tensorflow.python.ops import rnn, rnn_cell mnist = input_data.read_data_sets("tmp/data", one_hot=True) n_classes = 10 no_of_epochs = 10 # feed data in form of batches batch_size = 128 chunk_size = 28 n_chunks = 28 rnn_size = 128 ...
a8bba2dfdb4880467f71a12e16f5a2fa0e570c60
ema-rose/wordnik-repl
/practice/practice_perfect/ex7.py
109
3.65625
4
def remove_duplicates(lst): new = [] for x in lst: if x not in new: new.append(x) return new
4127b3674780fdca05986eae39435db03e7dc4b1
wangyunge/algorithmpractice
/eet/Merge_Intervals.py
1,097
4.1875
4
""" Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] and [4,5] are ...
f4343f414f79a2f580c8cf70210c8f082aa3b4c2
rafaelperazzo/programacao-web
/moodledata/vpl_data/54/usersdata/68/23009/submittedfiles/av1_p2_civil.py
380
3.59375
4
# -*- coding: utf-8 -*- from __future__ import division n=input ('Digite a quantidade de pinos:') m=input ('Digite a aluta para a fechadura ser desbloqueada:') alturas=[] soma=0 i=0 for i in range (0,n,1): alturas.append (input('Digite a altura do pino:')) while i<len(alturas): soma=soma+alturas[i]-alturas[i...
7a20aca997f5ba8f3e5c1cb4b59a2ae1abdfd4c6
SlvrWl/way_pythons
/Задания на множества/example.py
163
3.640625
4
var_1 = [1,2,3] var_2 = [0,1,4] def func(a): var_1 = [] for i in a: var_1.append(i**2) return var_1 print(func(var_2)) print(var_1)
25ff866d615593a363646b96e19b05d543ed912d
jimengya/Algorithms
/实操演练/templates/t002.py
366
3.78125
4
def fibonacci(n): """Return n. Args: n: n 2X1 retangles Returns: number of methods. """ # Put your code here. pass if __name__ == "__main__": assert 1 == fibonacci(0) assert 1 == fibonacci(1) assert 2 == fibonacci(2) assert 8 == fibonacci(5) assert 89 == fi...
84c63d673b157364f0a5b8810ab8bafcf3a74e45
colemccaulley/MIS407
/c26-gui_desktop_1/sample_code/tkinter03.py
368
4.375
4
import tkinter as tk window = tk.Tk() # insert handlers here def write_hello(): print("hello world") # to see this display as button it push, run "python -u tkinter03.py" # insert widgets here button = tk.Button(window, text="It's Wednesday afternoon and I'm in a programming class!", width=100, height=2, command...
186eab5bde6b74d2babb02e8f439af1c5b1d098e
mayank1101/uri
/1073.py
91
3.671875
4
N = int(raw_input()) for n in range(1,N+1): if n % 2 == 0: print ('%d^2 = %d'%(n, n**2))
fc2dffb29d3b9aa6a002eeff998ca469c18311ef
Johnscar44/code
/python/projects/final.py
1,054
4.09375
4
def adding_report(): while True: type = input("choose report type (\"A\" or \"T\")\nreport types include all items (\"A\") or total only (\"T\")".title()) if type.isalpha(): if type.lower() == 'a': return type elif type.lower() == 't': return t...
fd60c1823caa397a14bf71db4ea2d537c8e14630
arliemoore/pygex
/src/Stack.py
433
3.765625
4
class Stack: def __init__(self): self.stack = [] # Use list append method to add element def push(self, dataval): self.stack.append(dataval) # Use list pop method to remove element def pop(self): return self.stack.pop() def peek(self): return self.sta...
b9239041088dcb0f6157284cd84438e161a6e618
shhp/codes
/Python/longestSubstring.py
1,151
3.828125
4
#find the longest substring without duplicate letters def longestSubString(string): maxLength = 0; longestSubstringStartIndex = 0; start = 0; letterLastIndex = {}; for i in range(0, len(string)): if(string[i] in letterLastIndex): if(lette...
964c57519fef620459c349b19fccb59ad3cbded2
Altynaila/homework-month1
/lesson5/lesson5.py
491
3.859375
4
todos = [] while True: print("1) Добавит задачу") print("2) Показать задачу") option = int (input()) if option == 1: task = input() deadline =input() date_added = input() todo = [task, deadline,date_added] todos.append(todo) print("Задача добавлена") ...
8b4d14f2ad97821e6fb38c40cc718a02ce6af9a2
shruti2919/LeetCodeSolutions
/ReverseLinkedListII.py
1,446
3.84375
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def reverseBetween(self, head, m, n): """ :type head: ListNode :type m: int :type n: int :rtype: ListNode """...
c43fb41612b0c0dba231b4a65e9a097a955490bf
ZhengyangXu/LintCode-1
/Python/Wildcard Matching.py
1,029
4.09375
4
""" Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). """ class Solution: """ @param s: A string @param p: A string inc...
1c6947ff8563c902cb4375077fe1e3ddcc47b728
kreilisk24/RTR105
/test1.py
237
4.0625
4
while True: rawstr = input("number please:") try: nmbr = int(rawstr) except: nmbr = "Invalid" if nmbr == "Invalid": continue if nmbr == int(rawstr): break print(nmbr) print("Done")
c747ac20de8c329f1774817e65ec62409fddc735
ArunDharavath/CodeChef-DSA-Series
/l0_reverseme.py
106
3.6875
4
# cook your dish here n = int(input()) l = list(input().split()) l.reverse() for i in l: print(i, end=" ")
1a4b6ae7256ecfc112dfd146e48fce716243cb6d
jednghk/Connect-4
/c4_app/board.py
3,308
4.15625
4
board_config = {(row, column): ' ' for row in range(1, 7) for column in range(1, 8)} def generateBoard(): for i in range (1, 8): print(' {}'.format(i), end = '') print ('') for row in range(6, 0, -1): for column in range(1, 8): print ('|' + board_config[(row, column)], end = '')...
d850efbc55bf3a4c660d0c4350db715ba024c9da
ayush554/Data-Visualization-Haptics
/Data_Vis_mrtk/Assets/StreamingAssets/Python/BlockLibraries/UnityExamples/RandomInt.py
1,288
3.65625
4
# Random Blocks # These Operation Blocks produce random numbers from pysensationcore import * import random # === RandomInteger === # A Block which Returns a random integer value in the range of min to max randomIntBlock = defineBlock("RandomIntGenerator") defineInputs(randomIntBlock, "t", "min", "max", "period", "see...
2a8d034561bec2c715ec01aae8890908aa5b121e
Tanvi179/CRUD-Operations
/app.py.py
4,494
3.53125
4
import pymysql servername="localhost" username="root" password="" dbname="school" print print("1.Create A Record") print("2.Edit A Record") print("3.View A Record") print("4.Delete A Record") print("5.Exit") ch=int(input("Please Enter your choice:")) if ch==1: name=input("Enter student name:") rno...
8fd649174364868bfac7143bfaaddede4ff5341b
MAG-BOSS/fermulerpy
/src/fermulerpy/analytic/partitions.py
1,259
3.953125
4
import math import warnings def euler_pentagonal_num(n): """ Returns n'th euler pentagonal number (1-indexed) Parameters ---------- n : int denotes positive integer return : int returns n'th euler pentagonal number """ if(n!=int(n) or n<1): raise ValueError( ...
e05afff64300a8d51f11c8622cd095cfe4583cbe
Axlvid23/mines
/HW1.py
5,732
4.0625
4
import matplotlib.pyplot as plt import numpy as np import scipy.misc import statistics # Question # 1 # A test to detect certain bacteria in water has the following characteristics: if the water is # free from the bacteria, which happens with probability 0.99, the test indicates the the water # has the bacteria with ...
a22c87a56c1921068eafe1e387515bd61cf08764
BrichtaICS3U/assignment-1-functions-cbanc1
/main.py
3,719
4.09375
4
# Assignment 1 # ICS3U # <Cade Bancroft> # March 28, 2018 def CtoF(temperatureC): F = ((1.8) * temperatureC) + 32 return F def FtoC(temperatureF): C = (0.55556) * (temperatureF - 32) return C def selection(count): try: counter = count print("#-----------------Select One-----------...
c398d3e0197636e408e146e1ddfa32606e7423c6
dhzhd1/LeetCode
/JudgeCircle.py
590
3.625
4
def judgeCircle(moves): """ :type moves: str :rtype: bool """ r = [0, 0] for m in moves: if m == 'U': r[1] += 1 if m == 'R': r[0] += 1 if m == 'D': r[1] -= 1 if m == 'L': r[0] -= 1 if r[0] == 0 and r[1] == 0: ...
5eb99451950b1bb48e993f6f3d7d6ae021522909
iluvjava/Fucking_LeetCode_ShitLikeThat
/LeetCodes/old problem solutions/PythonSoln/Maximum Length of Repeated Subarray.py
2,061
3.78125
4
""" This is a possible solution to leetcode problem Maximum Length of Reapted subarray. A nested for loop solution might be better, a recursive one will be cool for more than 2 array. """ def Solve(array1:list, array2:list)-> int: """ """ memo = [[None for i in range(len(array2)+1)] for j in range(len(a...
f298559f195c017ab8951415dcba7ce818ac7bd1
SpikyClip/rosalind-solutions
/bioinformatics_stronghold/HAMM_counting_point_mutations.py
790
4.15625
4
# url: http://rosalind.info/problems/hamm/ # Problem # Given two strings s and t of equal length, the Hamming distance between # s and t, denoted dH(s,t), is the number of corresponding symbols that # differ in s and t. See Figure 2. # Given: Two DNA strings s and t of equal length (not exceeding 1 kbp). # Return: ...
32ae3f09b1b31363d133eeea988cf08cb89d25d7
haroldjin/interview-notes
/interviewing/algorithm_solutions/heapsort.py
1,125
4.40625
4
# importing "heapq" to implement heap queue import heapq # initializing list li = [5, 7, 9, 1, 3] # using heapify to convert list into heap heapq.heapify(li) # printing created heap print("The created heap is : ", end="") print(list(li)) # using heappush() to push elements into heap # pushes 4 heapq.heappush(li, 4...
90c3aa082ae2d26d2ed584bd2d147c37be3a7b3f
LachezarKostov/SoftUni
/02_Python-Advanced/04_Comprehensions/01_Lection/02_No Vowels.py
135
4.0625
4
input_str = input() vowels = ["a", "o", "u", "e", "i"] no_vowels = [x for x in input_str if x not in vowels] print("".join(no_vowels))
ef8538975693f4888c905aa07fb8c7925f386ee2
microwu/leetcode
/202004/45.py
927
3.515625
4
from typing import List class Solution: def jump(self, nums: List[int]) -> int: if len(nums) == 1: return 0 # dp = [-1 for _ in nums] # dp[0],dp[1] = 0,1 rest = nums[0] step,current = 0,0 while True : if current + rest >= len(nums)-1: ...
8aa1c3756640dd8b91d772dd335d4b16605e1d73
mahmudz/UriJudge
/URI/URI/1984.py
125
3.640625
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 22 11:49:34 2017 @author: Matheus """ n=input().strip() print ("%s"%n[::-1])
bf236aea03dc768e28c545f21613f4d735a2a6b0
north-jewel/data_analysis
/homework/Alex-赵鑫荣/生命游戏/gameofplt.py
3,330
3.546875
4
# -*- coding: utf-8 -*- """ File Name: gameoflife Product: PyCharm Project: python4 File: gameoflife.py Author : ZXR date: 2018/11/12 time: 14:22 """ import numpy as np import matplotlib.pyplot as plt # print(np.random.randint(0,2,(10,10))) class gameli...
5f47e53dd3375b4d95bcb4c2e57b5591c6893227
vuamitom/Code-Exercises
/codility/distinct_intersection.py
2,641
3.875
4
# -*- encoding: utf-8 -*- """ We draw N discs on a plane. The discs are numbered from 0 to N − 1. A zero-indexed array A of N non-negative integers, specifying the radiuses of the discs, is given. The J-th disc is drawn with its center at (J, 0) and radius A[J]. We say that the J-th disc and K-th disc intersect if J ≠...
2f1df7bb9b99572701ee784b4605c46f53890721
techsharif/python_training_2021
/day3/start/08_functions.py
331
3.859375
4
# def function_name(parameters): # statement(s) # 01 def f1(): print("Hello") f1() # 02 def f2(s): print(s) f2("one") # 03 def f3(s="Hello"): print(s) f3() f3("one") # 04 def f4(): return "hello" f4() print(f4()) # 05 def f5(x): if x < 0: return "Hello!" else: return 0 f5(1) print(f5(-1)) p...
ca095ba51a78b9803ecb0b2575cbe7f4a71adc70
SravaniJalibili364/Python_Excercises
/Day1/Python_Strings/Sphere_Volume.py
385
4.53125
5
'''Calculate volume of a sphere by prompting user for radius.''' #importing pi value from math module and using alias we name as pi_value from math import pi as pi_value radius_of_the_sphere = int(input()) #Now calculating the volume of the volume of the sphere using the formulae Volume_of_the_sphere = round((4/3)*pi...
5fe942d744a1002e09eacc3f7e505a2d5affed5a
dvlupr/fdn_course
/Week1/mod1_lab3.py
986
4.46875
4
#!/usr/bin/env python """ Ask the user three original questions and store their input as variables Combine the three answers into a sentence of your choosing Print out the final combined sentence using one of the string operations Add docstrings and comments to your code Upload your script to canvas (optional: include...
d3b4aba01535035ab8f012bb89187f151ea65998
shadiqurrahaman/python_DS
/leat-code/str.py
645
3.578125
4
def strStr( haystack, needle): if len(needle)==0: return 0 if len(haystack)<len(needle): return -1 h_index = 0 n_index = 0 while(h_index<len(haystack)): if haystack[h_index]==needle[n_index]: h_index+=1 n_index+=...
08ba32bd109736583b3fe1beb0f488374bf11ab3
yuanyu90221/python_learn_30
/control_flow.py
209
3.890625
4
first = 9 second = 8 if first > second: print("A is greater than B") else: print("B is greater than A") list_a = [1,2,3,4,5] for item in list_a: print(item) i = 1 while i < 10: print(i) i = i + 1
e4ec301edda7824948e5258f7771ae4335c4987a
Aasthaengg/IBMdataset
/Python_codes/p02705/s916899082.py
55
3.671875
4
import math PI = math.pi R = int(input()) print(2*R*PI)
b9ffa3cd05dfc6573f72aa3bcd9a77e104c6cb86
j0netzky/basics-exercise-python
/python_exercise_koodikarpat/h2/h2_pallo.py
771
3.53125
4
PI = 3.1416 def laske_ala(sade): return 4 * PI * sade ** 2 def laske_tilavuus(sade): return (4 / 3) * PI * sade ** 3 def laske_sade(piiri): return piiri / (PI * 2) def laske_pallon_ominaisuudet(piiri): sade = laske_sade(piiri) ala = laske_ala(sade) tilavuus = laske_tilavuus(sade) return ...
7cac82913183a389db989a4cd86bdfd950ff27ac
RoshanaMane/MyCapSubmission
/task3.py
258
4.28125
4
#Write a Python program to print all positive numbers in a range. list1= [12, -7, 5, 64, -14] for i in list1: if i >= 0: print(i, end=" ") list2 = [12, 14, -95, 3] for value in list2: if value >= 0: print(value, end=" ")
a98f6d30616f28b3407d37735edd136fc297e733
amanpate531/undergraduate_portfolio
/Year 4/CSCI-B 363/Labs/lab10.py
653
3.53125
4
file = open('rosalind_ba6b.txt', 'r') contents = file.readlines() s1 = contents[0].rstrip('\n') # Counts the number of breakpoints in the sequence # A breakpoint occurs between two numbers if the first is not one less than the second. # e.g. a breakpoint occurs between -3 and -4 because -3 is not one less than...
f5bfcf70206b2eaa86ba6d697f7c3b434759490c
nianxw/sword_leet
/sword/day6/33-二叉搜索树的后续遍历序列.py
1,095
4.0625
4
''' 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历结果。如果是则返回 true,否则返回 false。假设输入的数组的任意两个数字都互不相同。   参考以下这颗二叉搜索树: 5 / \ 2 6 / \ 1 3 示例 1: 输入: [1,6,3,2,5] 输出: false 示例 2: 输入: [1,3,2,6,5] 输出: true ''' class Solution(object): def verifyPostorder(self, postorder): """ :type postorder: List[int] ...
fa8a28c4189e846fbd2587f1a1889a7aea715c64
baxter-t/Practice
/codingProblems/cdrCar.py
377
3.953125
4
''' cons(a, b) constructs a pair, and car(pair) and cdr(pair) returns the first and last element of that pair. For example, car(cons(3, 4)) returns 3, and cdr(cons(3, 4)) returns 4. ''' def cons(a, b): def pair(f): return f(a, b) return pair def car(c): return c(lambda x, y: x) def cdr(c): return c(lambda...
f24870a2f54579ea2dfd28062c37936ab0e90a05
KevinPhomm/PythonTraining
/nombrepremiers.py
285
3.546875
4
def estPremmier(n): for i in range(2, n-1): if (n % i) == 0: return False return True def trouveLesPremiers(limit): i = 1 while i <= limit: if estPremmier(i): print("%s est premier" % i) i += 1 trouveLesPremiers(100)
753cc6df492a6823d4772c7aaee94c919664a0d1
betelgeuse-7/data-structures-and-algorithms
/Exercises/Strings/count_vowels_and_strings.py
701
3.953125
4
# count vowels and consonants def count_vowels_and_consonants(s: str) -> dict[str, int]: vowels = "aeiouy" consonants = "bcdfghjklmnpqrstvwxyz" res = { "vowels": 0, "consonants": 0 } if len(s) == 0: return res for char in s: if char in vowels: res["...
e7b541852538355cf6ea04e87c2266a23a97410e
8563a236e65cede7b14220e65c70ad5718144a3/introduction-python-programming-solutions
/Chapter08/0022_rev17_clear_set.py
981
4.1875
4
""" Review Question 17 Write a program to clear a set """ def clear1(set_to_clear): while True: try: set_to_clear.pop() except KeyError: break def clear2(set_to_clear): temp_set = set(set_to_clear) for element in temp_set: set_to_clear.remove(element) de...
61f8b2d0aa7176b9226855f055d78f839624c225
presentzeng/Python_base
/map_reduce.py
275
3.5
4
from functools import reduce x = abs #print(x(-10)) #input func def add(x, y, f): return f(x) + f(y) #map def sqart(x): return x*x L = map(sqart, [1, 2, 3, 4]) print(list(L)) #reduce def f(x, y): return x + y L1 = reduce(f, [1, 2, 3, 4]) #print(list(L)) print(L1)
a0177d667b456c79110512cbaa81aa1ce941a581
kkuziel/WordCount
/WordCount.py
1,448
4.21875
4
# python 3.5 # Word Counter # Find N most frequent word from a file from collections import Counter import re import os.path def find_and_print(input_file, top_frequent=20): """ Method that open the file and find frequent words @param input_file @param top_frequent @return tuple top_frequent words...
f6545837f1fccf434f384acc4aa19f14ce5b9fd5
ktissan13/ICS3U0
/Excercise/Count consonants.py
173
3.640625
4
# Count Consonants # Tissan Kugathas # ICS 3U0 # May 2 2019 text = str(input("Enter text: ")) string = [] for index in range(len(text)): string.append(text[index])
91aa8671b5ab6e25c7535d1554a70f8577955efc
fiatjaf/accountd.xyz
/app/helpers.py
701
3.5625
4
import re def account_type(account): if len(account.split("@")) == 1: if re.match(r"^\+\d+$", account): return "phone" if len(account.split(".")) > 1: return "domain" return None # otherwise the account is in format <username>@<provider> name, provider = ac...
a9cd2db8128acda2efb35f47f4b45182450ce9c8
asharif123/python_programs
/dict.py
670
3.921875
4
##dict stuff = {"name": "Zed", "age": 18, "height": 126} print(stuff["name"]) print(stuff["height"]) ##add more info to stuff stuff["city"] = "Los Angeles" stuff[1] = "practice" print(stuff[1]) print(stuff) states = { 'Oregon': 'OR', 'Florida': 'FL', 'California': 'CA', 'New York': 'NY', 'Michigan': 'MI' } cities = ...
a5f97b94c66ab57cbdff7bdbfce3f4a35ea12cc2
yhshu/DATA130006-Introduction-to-Natural-Language-Processing
/Assignment1/edit_distance.py
2,753
4.34375
4
import Levenshtein def edit_distance(str1, str2, m, n): """ A Naive recursive Python program to find minimum number operations to convert str1 to str2 Reference: https://www.geeksforgeeks.org/edit-distance-dp-5/ """ # If first string is empty, the only option is to # insert all character...
86b78170bd0e1a728a480ade7093d3fc28ec2f08
gessichen/algorithms
/maxPathSum.py
639
3.734375
4
# Definition for a binary tree node class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # @param root, a tree node # @return an integer self.curmax = 0 def maxPathSum(self, root): self.findMax (root) return...
b7b74895d33a42838125e8f00bb8053893aedf59
dilynfullerton/tr-A_dependence_plots
/src/parse.py
6,216
3.53125
4
"""parse.py Abstracted file parsing functions """ from __future__ import division, print_function from re import match from os import walk, path def sub_directories(parent_dir): """Returns a list of all subdirectories of parent_dir """ root, dirs, files = next(walk(parent_dir)) return [path.join(root...
e25a9c98b10c1183b447b1f28496274e4464757c
Chahat2609/radiobutton
/123.py
169
4.15625
4
num=int(input("enter num")) for i in range(0,6): print() for j in range(num-i): print(end="") for j in range(0,2*i-1): print("*",end="") print()
da34fe5f51f83b2b849844470b6b95c8cc27ce87
museaynan/guess_the_number_python
/guess_the_number.py
352
4.15625
4
import random print("Hello! Today we are going to play Guess The Number!") number = int(input("Guess a number between 0 and 5")) random_number = random.randint(0, 5) if number == random_number: print("You won!") print("Your prize is...") print("Nothing!") else: print("You lost!") print("The number w...
1003ee5d972150955fb7f7b93f306b3ab70d5bd7
Komashka/algorithm
/selection_sort.py
258
3.578125
4
def selection_sort(lst): for i in range(len(lst)): min = i for j in range(i + 1, len(lst)): if lst[min] > lst[j]: min = j temp = lst[i] lst[i] = lst[min] lst[min] = temp return lst
94be9e29351a4bc4781bd2744f04ce7c25418324
sphenginx/python
/dataStruct.py
262
4.15625
4
#!/usr/bin/python items1 = dict(one=1, two=2, three=3, four=4) # 通过zip函数将两个序列压成字典 items2 = dict(zip(['a', 'b', 'c'], '123')) # 创建字典的推导式语法 items3 = {num: num ** 2 for num in range(1, 10)} print(items1, items2, items3)
92cdf399005f812cf9e5a81c5105e3139874c340
cocal/notes
/daydayup/pySort.py
2,403
3.78125
4
# -*- coding: utf-8 -*- #没时间了 写个冒泡排序好了 - - li = [1,1,5,6,7,3,2,1,9,0] def bubSort(li): lenth = len(li) for x in range(lenth-1,-1,-1) : # print x for i in range(x) : if li[i] < li[i+1] : # print li[i],li[i+1] li[i] , li[i+1] = li[i+1] ...
f155354b35262e45f2a33e4ab225625ac5601031
vaishalimurugavel/-Unagi-Ingress-Hackathon
/Imageclassification-module1/autism_classify.py
1,775
3.53125
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 13 19:57:58 2021 @author: Vaishali """ from keras.models import Sequential from keras.layers import Conv2D, MaxPool2D, Flatten, Dense, InputLayer, BatchNormalization, Dropout from keras.preprocessing.image import ImageDataGenerator # create a new generator ...
cfe12d6ba7c60e132adb2a0bb6467755f897030e
aniketmandalik/ProjectEuler
/Problem009.py
397
4.03125
4
from timeit import default_timer as timer def pythagorean_triplet(total): """ Finds a pythagorean triplet a, b, and c such that a + b + c = sum Returns i * j * k """ for i in range(1, int(total/2)): for j in range(1, total - i): k = 1000 - i - j if k**2 == i**2 + j**2: return i * j * k start = timer(...