blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
dc667827ff7f0f9adf8364033a3bf325b64327fb
XuemingNotCute/Alogrithm
/bfs/search.py
1,171
3.75
4
from collections import deque # 这个算法的背景是检查人际网络的有向图里面,某人的好友里有无芒果营销商。要点一, 用散列表表示图 def return_dict(name): graph = dict() graph['you'] = ['bob', 'alice', 'claire'] graph['bob'] = ['anuj', 'peggy'] graph['alice'] = ['peggy'] graph['claire'] = ['thom', 'jonny'] graph['anuj'] = [] graph['peggy'] ...
c95c502184424b7d7f56da51ec7df1bd24c11499
rosexw/LearningPython
/Exercise Files/Ch2/loops_start.py
843
4.25
4
# # Example file for working with loops # def main(): x = 0 # define a while loop # while (x < 5): # print(x) # x = x+1 # define a for loop # for x in range(5,10): # print (x) # use a for loop over a collection # days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"] # for d in days: # p...
544080992dc1add6385dd1eebc3c18c3289dc86b
AymanInSpace22/Python
/.split()_method.py
338
3.859375
4
# the delimiter can be anything. If you just leave empty parenthesis it will wil default to spaces # howevery you can put any character you want in between the '' quotation marks in the () parenthesis words = 'You=a=bitch' print(words.split('=')) words = 'You a bitch' print(words.split()) words = 'You a bitch' print(...
914544f42b91b5d6b7c17378a310add1ea9a67a6
Adarsh2412/python-
/python11.py
663
4.21875
4
def calculator(number_1, number_2, operation): if(operation=='addition'): result=number_1+number_2 return result elif(operation=='subtract'): result=number_1-number_2 return result elif(operation=='multiply'): result=number_1*number_2 return result ...
7b55cee64945c3ea331581f80551e3a2d49ad285
madhurimore746/PublicData
/speedTypingTestProject.py
1,500
3.890625
4
from tkinter import * from timeit import default_timer as timer import random #To create window window = Tk() #To set window size window.geometry("400x200") x=0 def game(): global x if x == 0: #to destroy initial window window.destroy() x = x+1 def check_result(): ...
f63b1e545649607f8e38a537eaf3d92071f818b9
AlekJaworski/nn_exploring
/layers.py
4,129
3.71875
4
from abc import ABC, abstractmethod import numpy as np import functions as fn class Layer(ABC): def __init__(self, input_size, output_size): self.input_size = input_size self.output_size = output_size @abstractmethod def compute(self): pass class ReLu(Layer): """ a ReLu ac...
04810b656783016a50b51ec026e8100266bb2643
snorthway/algo-viz
/ransac_2d.py
4,162
3.828125
4
# Visualization of the RanSaC algorithm in one dimension. # (RanSaC stands for Random Sample Consensus). # # RanSaC is meant for dealing with situations where # taking the average (or doing the linear regression in 2d) # would be misleading due to outliers. from random import choice from functools import partial im...
0b64539e2f92d328e678f0c5988bea305cf0d349
MatheusKunnen/robo-bombeiro
/src/motorController.py
2,539
3.65625
4
##################################################### # @autores: # # - Jhonny Kristyan Vaz-Tostes de Assis # # - Matheus Kunnen Ledesma # # - Patricia Abe Turato # #################################################...
b5ec4bc7198106155cce7f0e988e0213f6aa5c70
540928898/LeetCodeMe
/Python/GoogleKicstart/ListUtils.py
1,672
3.890625
4
class ListNode: def __init__(self, x): self.val = x self.next = None class GenList: head = ListNode(-1) def createListNode(self,list1): for i in list1: newNode = ListNode(i) newNode.next = self.head.next self.head.next = newNode def printList(s...
cbb905bed36e815d19deda8a5b4245266919e345
540928898/LeetCodeMe
/Python/LeetCode/LeetCode945minIncrementForUnique.py
637
3.65625
4
''' [1,2,2] 输出:1 解释:经过一次 move 操作,数组将变为 [1, 2, 3]。 ''' class Solution: def minIncrementForUnique(self, A): A = sorted(A) res = 0 N = len(A) if N <= 1: return 0 for i in range(1,N): if A[i] >A[i-1]: continue else: ...
81a70875591b632c5053e2ce953c71573fa0d840
AlekOK/ReposForCV
/testsPython/test4.py
712
3.96875
4
# #16. Task with number (my number is 1234) # #16.a multiplication all digits of my number # my_number = 9215 # first_number = my_number //1000 # second_number = my_number % 1000//100 # third_number = my_number % 100 //10 # fourth_number = my_number % 10 # print(first_number, second_number, third_number, fourth_numb...
d1087cf2c64d2679423d0c6948341c090ae9b7a2
totorodev0032/Python----Recursion-and-Dynamic-Programming
/Recursion/DirectRecursion.py
682
4
4
# Recursion is a process of repeating a procedure. # In computer science, recursion refers to a function calling itself directly or indirectly. ## DIRECT RECURSION # Direct Recursion occurs when a func calls itself directly in its body or definition. ###### Example ######### def func(str, n): if n > 0: ...
cb78d83eeb2aa6d4d6a1c9399d9ee6596e809348
MichaelHFGrant/seniorProject
/tests/testScript.py
380
3.921875
4
#! /usr/bin/python3.5 import queue newItem = 'hello' nextItem = 'bye' newQueue = queue.queue(newItem) newQueue.push(nextItem) x=0 while (x<10): newQueue.push(x) x=x+1 item = newQueue.pop() print(item) item = newQueue.pop() print(item) item = newQueue.pop() print(item) item = newQueue.pop() print(item) item = n...
d93925a5f55732d6acf98c612230728c63d07453
mkao006/nlp_playground
/nltk/ch03.py
2,105
4.03125
4
# Source : http://www.nltk.org/book/ch03.html from __future__ import division # Python 2 users only import nltk import re import pprint from nltk import word_tokenize # 3.1 Accessing Text from the Web and from Disk # Download the English translation of Crime and Punishment. import urllib2 url = "http://www.gutenber...
bb64f9a3ee03dbdf32442a913c2b4450b4e1d823
abtpst/Home-Depot
/src/preproc/Slicing_Aides.py
3,511
3.734375
4
''' Created on Oct 26, 2016 @author: abhijit.tomar Helper methods for slicing data frames ''' import pandas as pd import numpy as np ''' Return portion of df where string s occurs in df[col] ''' def filter_str(df, s, col='search_term'): return df[df[col].str.lower().str.contains(s)] ''' input_df is the attributes...
6fb7dd326ffb231a8f8e1850b8eb892cca7b6359
naveenshandilya30/EXCEPTION-HANDLING
/Assignment_13.py
1,279
3.875
4
# Question 1 try: a = 3 if a < 4: a = a / (a - 3) except ZeroDivisionError: print(a) # Question 2 try: a = [1, 2, 3] print(a[3]) except IndexError: print("Index does not error") # Question 3 try: raise NameError("Hi there") except NameError: print("An exection") # Question...
59426f45994889e9a34aff394ec7a324ee1cdae7
elagasteratou/python_tryout_wk2
/tryout_functions.py
1,518
3.875
4
import random # Function generates random advice based on how user says they feel. # IDEA: as a future feature, make it so that can't have advice you've already been given def give_advice(dictionary, adjectives): user_cont = 1 used = [] issue_gen = (random.randint(1, len(dictionary))) - 1 while user_c...
515eb3c5bb48343effa54434c4c1ff1e8d8bd921
irobbwu/Python-3.7-Study-Note
/basic Grammar/20. 文件:因为懂你,所以永恒.py
3,215
3.5625
4
# 10.12 作业 # 集合:在我的世界你就是唯一 # 1.试尝试将文件(OpenMe.mp3)打印到屏幕上。 # 参考答案 f = open('OpenMe.mp3') for each_line in f: print(each_line , end='') f.close() 输出结果: 长期使用Windows操作系统的朋友很容易被扩展名所误导,认为扩展名决定文件类型,其实这种观念是错误的! 其实这就跟一个姓张的坏人,尽管把名字改为了“张好人”,但他还是一个坏人是一个道理的^_^ 关于文件的扩展名,初学者容易走进的误区: 误区一:文件扩展名是一个文件的必要构成部分 ...
1291c76bea3aad595e5aba5f7fd78aa0d86ab48d
irobbwu/Python-3.7-Study-Note
/basic Grammar/02. 数据类型.py
5,787
3.90625
4
# 8.24 作业 # 一、当用户输入错误类型的时候,及时提醒用户重新输入,防止程序崩溃 # 答 import random ser = random.randint(1,10) sp = input('please input your number?') if isinstance(sp, int) == False:# 报错,因为input输入的永远是字符串 print('Please input an integer') sp = input('please input your number?') guess = int(sp) while guess != ser:...
d9de8d029ec05b744ce3e349f7043d6c4a9ff332
irobbwu/Python-3.7-Study-Note
/basic Grammar/10. 函数:python的乐高积木.py
1,471
4.125
4
# 10.7 作业 # 函数:python的乐高积木 # 1.编写一个函数power()模拟内建函数pow(),即power(x, y)为计算并返回x的y次幂的值。 def power(x, y): return (x ** y) # 参考答案: def power(x,y): result = x**y return result print(power(2, 8)) # 2.编写一个函数,利用欧几里得算法求最大公约数,例如gcd(x, y)返回值为参数x和参数y的最大公约数 def gcd(x,y): c = 1 w...
6a9de59ee99479dc0adfe20a130beefa326d8011
irobbwu/Python-3.7-Study-Note
/basic Grammar/04. 了不起的分支循环.py
4,578
3.921875
4
# 9.12 作业 # 了不起的分支循环(1) 加载背景音乐 播放背景音乐(设置单曲循环) 我方飞机诞生 interval = 0 while True: if 用户是否点击了关闭按钮: 退出程序 interval += 1 if interval == 50: interval = 0 小飞机诞生 小飞机移动一个位置 屏幕刷新 if 用户鼠标产生移动: 我方飞机中心位置 = 用户鼠标位置 屏幕刷新 if 我方飞机与小飞机发生肢体冲突: ...
dbe00f7712f950e33b36e69e05d56d7465609c04
StevenM42/Sandbox
/password_check.py
389
4.3125
4
"""Password check program that returns asterisks of password length""" Minimum_character_limit = 6 password = input("Please enter password at least {} characters long: ".format(Minimum_character_limit)) while len(password) < Minimum_character_limit: password = input("Please enter password at least {} characters ...
20249aa5b2985f6250efabfea0cc4148f2be1baa
EmZet97/Checkers_Game
/ProjektWarcaby/Background/Board.py
1,631
3.5
4
from Background.Field import Field class Board: _colors = [(255, 255, 241), (153, 102, 51)] def __init__(self, size, x, y, field_size): self.size = size self.fields = [] self.pawns = [] self.x = x self.y = y self.field_size = field_size self.create() ...
ffac4f7a078c8221458dbba66af1ee4f95ad374c
shreesha-bhat/Python
/reverseofanumber.py
309
4.28125
4
#program to accept a number from the user and find the reverse of the entered number number = int(input("Enter any number : ")) rev = 0 while (number > 0): remainder = number % 10 rev = (rev * 10) + remainder number //= 10 print("Reverse of the entered number is ",rev)
45d3281927b36d539619554889b92fac37af3460
shreesha-bhat/Python
/Series1.py
339
4.15625
4
#Program to accept a number “n” from the user; then display the sum of the series 1+1/2+1/3+……….+1/n num = int(input("Enter the value of N : ")) for i in range(1,num+1): if i == 1: print(i,end='+') if i != 1 and i != num: print(f"1/{i}",end='+') if i == num: print(f"1/{i}...
3c23bc4b31be19db9439b1b1e8e96b5069c3bd35
shreesha-bhat/Python
/Swapnumbers.py
376
4.1875
4
#Program to swap numbers Number1 = int(input("Enter the First number : ")) Number2 = int(input("Enter the Second number : ")) print(f"Before swap, the values of num1 = {Number1} and num2 = {Number2}") Number1 = Number1 + Number2 Number2 = Number1 - Number2 Number1 = Number1 - Number2 print(f"After swa...
bd8865b4498e92755aa5470e56485b3132d8c9da
shreesha-bhat/Python
/34question.py
238
3.609375
4
#Program to Draw the pattern as shown in 34th question for i in range(1,4): for j in range(1,4): if i == j: print("19",end=' ') else: print('0', end=' ') print("")
92a5b52e620fabf557ff30f4d1e471d783db4f2c
shreesha-bhat/Python
/series3.py
417
4.125
4
#Program to accept a number “n” from the user; find the sum of the series 1/23+1/33+1/43……..+1/n3 num = int(input("Enter the value of N : ")) sum = 0 for i in range(1,num+1): if i == 1: print(i,end='+') if i != 1 and i != num: print(f"1/{i}^3",end='+') if i == num: print(f...
1beaffc1dcebe9e0ed823208ad6fdfdae9ffe74d
navhos/Mancala
/mancala.py
7,167
3.921875
4
############################################################################## # # File: mancala.py # Date: Mon 15 October # Author: Navid Al Hossain # Description: Mancala # ############################################################################## # State is a list of length 15 # Stones in...
93be6abde8da9690ba3739a3b25044e797b0147a
lumc-python/introduction-mihailefter
/ex6_nested_dictionaries.py
3,026
4.5625
5
# Exercise 6: Nested dictionaries # ========== # # Assume a dictionary that has country names as keys and as values another # dictionary with the following keys: continent, capital, population. # Example: # # { # 'The Netherlands': { # 'capital': 'Amsterdam', # 'population': 17283008, # 'continent': 'Euro...
ab1fa14fa6ca3e9eb7ac60355a5cd74e914faef1
RailGun15/Hangman-game
/hangman/game.py
2,229
3.5625
4
from .exceptions import * import random # Complete with your own, just for fun :) LIST_OF_WORDS = ["lion", "umbrella", "window", "computer", "glass", "juice", "chair", "desktop", "laptop", "angel","dog","shotgun","tiger", "phantom", "cat", "lemon", "cabel", "mirror", "hat","car","python"] def _get_random_word(list_...
2dcedd0793fa49bd65332a868352c1c0ddb0e244
TKettunen/GH_Non-linear_Optimization
/Exercises 2.py
2,376
3.640625
4
# Exercises 2. # # 1: # Electricity buying prize per kWh: f(x) = 1 - 0.01*x # Electricity selling prize per kWh: g(x) = 2 - 0.01*x # Electricity buying limits: 0 <= x <= 50 # Maximize F(x) = g(x)*x - f(x)*x # # Formulate an optimization problem. # # Solution: # min F(x) = (1 - 0.01*x)*x - (2 - 0.01*x**2)*x # s.t...
7d22b78dd8ee7c38782294b9b0094cbfb1ee2e0b
amosniu/tkinter_canvas_use
/module.py
1,386
3.875
4
from tkinter import * import random # 生成随机数 def tz(): print('凌菲小姐姐声音好甜') # 创建窗口 tk =Tk() # tk.geometry('550x250+300+200') # 画布大小 以像素为单位 px canvas = Canvas(tk,width = 400,height = 400) canvas.pack() # # 画一条直线 # canvas.create_line(0,0,100,50) # # 绘制矩形 # canvas.create_rectangle(50,50,100,100) # #...
1be945846fbca27309d887d7cea8a0664e08ec65
Boyu1997/CS110
/Session_1_2.py
650
3.96875
4
def insertion_sort(lis): step = 0 for i in range(1, len(lis)): for j in range(0, i): if lis[j] > lis[i]: lis[i], lis[j] = lis[j], lis[i] step += 1 print step, lis print "end" return lis def bubble_sort(lis): step = 0 for i in range...
12d1be8d3ec8156a1aad1df98a92e9e888fa2de7
Boyu1997/CS110
/Session_7_2.py
2,253
3.671875
4
import random import string import numpy as np def randomword(length): return ''.join(random.choice(string.lowercase) for i in range(length)) def empty_hash_table(N): return [[] for _ in xrange(N)] def add_to_hash_table(hash_table, item, hash_function): N = len(hash_table) # Your code here has...
98a590132334e46bdc9914cef08093f28954fe2b
Arrancar86/Python
/Licznik Kalorii.py
1,539
3.796875
4
print("Cześć tu Python.Jak masz na imię?") imię=input().strip() print("Więc witam Cię",imię+".\nMiło Cię poznać.") print("Ile masz lat?",imię+".") wiek=int(input().strip()) print("W wieku",wiek,"lat ile masz wzrostu w cm?") wzrost=int(input().strip()) print("I przy wzroście",wzrost,"cm ile masz wagi w kg?") wag...
fd771d3c85d81246cd3ba40ba7cf65ff09f1e001
seguidor777/hackerrank_ctci
/bfs.py
1,208
3.8125
4
import queue from collections import defaultdict class Graph: def __init__(self, n): self.n = n self.adjacents = defaultdict(list) def connect(self, x, y): self.adjacents[x].append(y) self.adjacents[y].append(x) def find_all_distances(self, s): dist...
3abf48e464effaf352cef087f4e7150dc230ac8d
LukasKirchner/HSP_Galileo_KIP
/Basemap/Main.py
475
3.515625
4
from TkMap import TkMap import sys # import the correct Tk library based on python version if sys.version_info[0] < 3: import Tkinter as Tk else: import tkinter as Tk window = Tk.Tk() m = TkMap(window) # ToDo: read this from csv file data = [[y*x for x in range(360//5)] for y in range(180//5)] m.draw_data(d...
a74755124fbe6576834e81dcf5147ffb3c636c22
robin9804/RoadToDeepLearningKing
/SJ/Problem_sol.py
4,733
3.640625
4
#Problem 106 sports = ['soccer'] sports.append('baseball') sports.append('hocky') print(sports) sports.insert(1, 'tennis') print(sports) sports.sort() print(sports) print(sports.pop()) sports.reverse() print(sports) #Problem 128 list1 = [] for i in range(10): num = int(input('insert numbers:')) ...
688346c370ea3f59a97632e5cac45d000e112afd
robin9804/RoadToDeepLearningKing
/YR/week4/ex304.py
197
3.5625
4
# example 304 answer = 0 for i in range(1, 4): for j in range(i+1, 5): for k in range(j+1, 6): print(i, j, k) answer += 1 print('num of case', answer)
277d24a0277aa1a26b85ef5711d31e32f20cf270
robin9804/RoadToDeepLearningKing
/Jinu/week3/problem206.py
393
4
4
score = int(input("점수를 입력하시오 :")) if (score <= 100) & (score >= 90): grade = 'A' print(grade) elif (score < 90) & (score >= 80): grade = 'B' print(grade) elif (score < 80) & (score >= 70): grade = 'C' print(grade) elif (score < 70) & (score >= 60): grade = 'D' print...
e3074b4c89bf72c3549e5b124ff8ab313c4c8757
robin9804/RoadToDeepLearningKing
/YR/week2/problem142.py
693
3.734375
4
# problem 142 nums = input('insert 6 numbers: ') # 6개의 정수 입력 nums.split() # 모두 붙여서 문자열로 저장 number = '' for i in nums: if i != ' ': number += i print(number) # 세 자씩 나누어 수 들의 합을 출력하기 number = list(number) length = len(number) //3 print(length // 3) # 3으로 나눴을 때 몫이 얼마나 나오는지 확인하기 sum = 0 for i...
5af2629442ea71b364279e5b45d819f688d1c85c
robin9804/RoadToDeepLearningKing
/Jinu/week4/example302.py
173
3.671875
4
def sum(n): sum = 0 for i in range(n+1): sum += i return sum answer = 0 for i in range(100): answer += sum(i) print(answer)
6f031071b59d59970d582022379514ac06e1e227
robin9804/RoadToDeepLearningKing
/YR/week2/problem183.py
318
3.609375
4
# problem 183 A = input('enter 1st number :') B = input('enter 2nd number :') a = int(A) b = int(B) answer = 0 sik = '' for i in range(a, b+1): if i % 2 == 1: answer += i sik += '+' + str(i) else: answer -= i sik += '-' + str(i) print(sik) print('=',answer)
f0379ec4e6b0939e42e13ac8a4ccfc1d93797be9
robin9804/RoadToDeepLearningKing
/Jinu/week2/problem180.py
398
4
4
print('Enter the number : ') a = int(input()) nums = list(range(a)) def prime_test(x): i = 1 count = 0 while i < x: rest = x % i if rest == 0: count += 1 i += 1 if count == 1: print('{} is prime number'.format(x)) els...
f80cdd162e867764e0f9d3cd0d55be02753f8c54
inlet33/AIBASIC
/python1_1.py
961
4
4
## this is variable # print("welcome to Python!") # MY_NAME = "Jan-Joven Jumao-as" # my_age = 25 # number1 = 110 # number2 = 100 # print("my name is "+ MY_NAME + " and i am ",my_age," years young") ## this is data type # stringval = "25" # intval = 25 # numb = 25.0 # booleanval = True # # print(intval - int(st...
d5e7558db352fbdab601257849904282b4f82718
lufeng0614/leetcode
/leetcode_7.py
891
3.5
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ @Author: lufeng @Contact: lufeng0614@163.com @Time: 2018/11/8 15:46 @note: leetcode 7 """ class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ def revs(x): ...
fba8eef2cbffd2557b63a17f21f59409bacacef5
lufeng0614/leetcode
/leetcode-67.py
711
3.5625
4
class Solution(object): def addbinary(self, a: str, b: str) -> str: """ :param a: 二进制字符串a :param b: 二进制字符串b :return: a+b 二进制表示 """ print("十进制a:", int(a, 2)) print("十进制b:", int(b, 2)) print("二进制a:", bin(int(a, 2))) # 转二进制 print("二进制b:", '{:b}'....
e28735a52f2ad739072e8d781353efe1e52badcf
lufeng0614/leetcode
/leetcode-350.py
618
4.3125
4
给定两个数组,编写一个函数来计算它们的交集。 示例 1: 输入: nums1 = [1,2,2,1], nums2 = [2,2] 输出: [2] 示例 2: 输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 输出: [9,4] 说明: 输出结果中的每个元素一定是唯一的。 我们可以不考虑输出结果的顺序。 ======================================================================= class Solution(object): def intersection(self, nums1, nums2): ...
18b2985b4ac5a4e2fee0505cad6f87d5f5e81f05
lufeng0614/leetcode
/leetcode-290.py
1,316
3.953125
4
给定一种规律 pattern 和一个字符串 str ,判断 str 是否遵循相同的规律。 这里的 遵循 指完全匹配,例如, pattern 里的每个字母和字符串 str 中的每个非空单词之间存在着双向连接的对应规律。 示例1: 输入: pattern = "abba", str = "dog cat cat dog" 输出: true 示例 2: 输入:pattern = "abba", str = "dog cat cat fish" 输出: false 示例 3: 输入: pattern = "aaaa", str = "dog cat cat dog" 输出: false 示例 4: 输入: pattern = "...
5d76ab761b8b371991f052164207cdedb17eacb3
lufeng0614/leetcode
/leetcode-383.py
948
3.546875
4
给定一个赎金信 (ransom) 字符串和一个杂志(magazine)字符串,判断第一个字符串ransom能不能由第二个字符串magazines里面的字符构成。如果可以构成,返回 true ;否则返回 false。 (题目说明:为了不暴露赎金信字迹,要从杂志上搜索各个需要的字母,组成单词来表达意思。) 注意: 你可以假设两个字符串均只含有小写字母。 canConstruct("a", "b") -> false canConstruct("aa", "ab") -> false canConstruct("aa", "aab") -> true ===================================...
2db2dbcfdf5ce7c15f7fdbd24b82127fa5f3f9cf
DavidKerslake/4170TradingCodeTest
/problem1.py
1,049
3.59375
4
import numpy as np import time # Number of combinations using coins in array unob_coins that come to the total. D is the reference array to store answers def change_combinations(unob_coins, total, D): if (len(unob_coins) == 0 and total >= 1) or total < 0: return 0 i = unob_coins.index(unob_coins[-1]) ...
b4877686a561190f95163d6e7c2f391b99ecbe44
PrakhyaVanaparthy/LeetCode
/AddTwoNumbers.py
703
3.65625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def addTwoNumbers(self, l1, l2): addedlist = ListNode(0) carry = 0 total = 0 x = addedlist while l1 ...
e403fb87c010986eaed0a380047b7ddfacd305cc
raresmihai/Numerical-Calculus
/Tema2/matrixValidation.py
880
3.59375
4
def matrixIsSimetric(matrix): return (matrix.transpose() == matrix).all() def matrixIsSquared(matrix): matrixShape = matrix.shape # (3, 3) return matrixShape[0] == matrixShape[1] def matrixIsDiagonallyDominant(matrix): n = matrix[0].size for i in range(0, n): if abs(matrix[i, i]) < sum(...
11cbf735d693692738e1d3fb116c3e0e027f6fcb
raresmihai/Numerical-Calculus
/Tema7/Aitken.py
1,270
3.625
4
def get_divided_difference(d0dk,d1k1,x0,xk1): return float(d1k1-d0dk) / (xk1-x0) def get_pair_div_diff(x0, x1, y0, y1): return float(y1-y0)/(x1-x0) def get_initial_div_diff(n, x, f): initial_dd = [] for i in range(0,n): initial_dd.append(get_pair_div_diff(x[i], x[i+1], f[i], f[i+1])) ret...
67adb06e0d9acb77ff4e714f021a98513eec7a2b
raresmihai/Numerical-Calculus
/Tema1/Ex1.py
394
3.59375
4
from tkinter import * def compute_u(): m = -1 u = 10 while 1.0 + u != 1.0: u = 10 ** m m -= 1 return u if __name__ == "__main__": root = Tk() root.title("Exercitiul 1") root.geometry("230x200") app = Frame(root) app.grid() label = Label(app, text="Precizia m...
1cc2bade7b9c08be021593f117bed4971658184d
samdawes/iD-Emory-Python-Projects
/MAD.py
1,155
4.15625
4
print("Mad Libs is starting!") adjective1 = input("Enter an adjective: ") name = input("Enter a name:") verb1 = input("Enter a verb: ") place = input("Enter a place: ") animal = input("Enter a plural animal: ") thing = input("Enter a thing: ") verb2 = input("Enter a second verb: ") noun2 = input...
4ee85d1788d70185c9107a935cde3debbd93faa9
rcmhunt71/hackerrank
/arrays/left_rotation.py
430
3.90625
4
def shift_list_left(element_list, num_shifts): for rotation in range(num_shifts): element_list.insert(len(element_list), element_list.pop(0)) print(f"{rotation}: {element_list}") return element_list if __name__ == '__main__': nd = input().split() n = int(nd[0]) d = int(nd[1]) ...
a452c61845d7ec8f285b3aec32bbb707b8ac38e8
rcmhunt71/hackerrank
/DLLs/insert_into_dllist.py
2,038
4.15625
4
#!/bin/python3 class DoublyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None self.prev = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None def insert_node(self, node_data): node = Doubly...
d9b437283616b1d92f2881a77c4505c421a7f10b
mariasilviamorlino/python-programming-morlino
/PB_implementations/backward_hmm.py
2,510
4.21875
4
""" Backward algorithm implementation for hmms ########### INPUT: model parameters sequence to evaluate OUTPUT: probability of sequence given model ########### Setup Read list of states Read transition probabilities Read emission probabilities Read sequence rows = n. of states cols = length of sequence Create a ro...
2cf6aac10d65d2065ec902a62ef4fda42dc6c774
olabknbit/Compilers
/TreePrinter.py
4,996
3.515625
4
import AST def addToClass(cls): def decorator(func): setattr(cls, func.__name__, func) return func return decorator class TreePrinter: @addToClass(AST.Node) def printTree(self): raise Exception("printTree not defined in class " + self.__class__.__name__) ...
cd4f12eb93a440e00c489a8f3958d023be6f7aad
MintMissy/Hangman
/letterFunctions.py
416
3.828125
4
from string import ascii_letters def is_in_word(letter, word): if letter in word: return True else: return False def is_enabled(letter): if letter in ascii_letters: return True else: return False def get_indexes_in_word(letter, word): indexes = [] for i in r...
02fcfb08b11357278169abfa2c70d2ce71df7eec
Akshay-Kumar/accurate_analytics
/music_prediction_app/theme_river.py
6,977
3.75
4
from plotly.graph_objs import Figure import pandas as pd from music_prediction_app.helper_lib import get_numeric_columns, standardize_column def create_theme_river(): """ :return fig: This method is used to generate the Theme River plot from the spotify dataset based on various song features """ ...
aff295769b6688ffa8ffc3f68202e9ffe0280967
treyceraso/hackerrank
/Day 7: Spearman's Rank Correlation Coefficient.py
409
3.65625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT input() X = list(map(float, input().split())) Y = list(map(float, input().split())) def spearman_corr(X, Y): X_r = [sorted(X).index(x) for x in X] Y_r = [sorted(Y).index(y) for y in Y] D = [(x-y)**2 for x, y in list(zip(X_r, Y_r))] ...
9b03a12a5e6e06ce39942936dc381f3af5ffdfcd
dotunpeters/coding_challenge
/vh travling is fun.py
1,743
3.546875
4
def connectedCities(n, threshold, originCities, destinationCities): # Write your code here result = [] #Function returns path existence def gcd(x, y, threshold): x_gcd = [] y_gcd = [] #append each divisor of x to x_gcd for i in range(x): i += 1 ...
b2f2b3de516317628c653180aaa45f22be193829
dotunpeters/coding_challenge
/collisionCourse.py
2,050
3.890625
4
#There are n particles numbered from 0 to n − 1 lined up from smallest to largest ID along the x-axis. #The particles are all released simultaneously. Once released, each particle travels indefinitely in a #straight line along the positive x-axis at a speed. When two particles collide, the faster particle moves throu...
300e8b758c432a0278d397497a246f03bec88393
dotunpeters/coding_challenge
/my_class.py
1,507
4.03125
4
class Employee(object): all_employee = 0 change_pay = 1 def __init__(self, first, last, pay): self.fname = first.lower() self.lname = last.lower() self.pay = pay Employee.all_employee += 1 def get_email(self): return f"{self.fname}.{self.lname}@gmail....
fd388f21b7f7e3609a461ac786e7c28d27258be3
dotunpeters/coding_challenge
/contacts.py
767
3.6875
4
#!/bin/python3 import os import sys # # Complete the contacts function below. # def contacts(queries): # # Write your code here. # #return queries listings = [] result = [] count = 0 for each in queries: if each[0] == "add": listings.append(each[...
af9c80ee963376e08e20638f4924867902a4e8a8
dotunpeters/coding_challenge
/Picking Numbers Next.py
1,134
3.90625
4
#Given an array of integers, find and print the maximum number of integers you #can select from the array such that the absolute difference between any two of #the chosen integers is less than or equal to . For example, if your array is , #you can create two subarrays meeting the criterion: and . The maximum...
c71a272e07bf86cb6641371c50dcf65b8436c5a7
dotunpeters/coding_challenge
/squad_of_robotic.py
316
3.671875
4
def final(top_right, position): coord = ["N", "E", "S", "W"] for key, value in position.items(): current_coord, coord_index = key[-1], x, y = key[0], key[1] top_right = "55" position = { "12N": "LMLMLMLMM", "33E": "MMRMMRMRRM" } print(final(top_right, position))
5492a784f423e553f2d98c40308565b09e99dd4a
dotunpeters/coding_challenge
/dating.py
313
3.609375
4
from datetime import datetime, date, time, timedelta from pytz import UTC print(datetime.now(tz=UTC).microsecond) print(date.today()) #timedelta operation print(datetime.now() + timedelta(weeks=7)) print((date.today() - date(1995, 2, 13)).days) print((date.today() - date(1995, 2, 13)).total_seconds())
d808c6fcd8cfee1922c8db0562a4efe797dd34f9
iistrate/AstroPlay
/parser.py
2,836
3.5625
4
import sqlite3 print("Module loaded; activating Python super powers in 3 2 1..") def parse(string): #clean string starts empty cleanedString = "" #if there's more than one char in string if(len(string) > 0): #from immutable string to mutable list sarray = list(string) #get eac...
beadfa1d1fe5b6f95dbf54a3d9185fa56fa227e4
shmilyvidian/Python001-class01
/week07/homework.py
1,782
3.96875
4
from abc import ABCMeta, abstractmethod # 定义一个抽象基类 class Animal(metaclass=ABCMeta): @abstractmethod def __init__(self, mold, body, character, isViolent): self.mold = mold self.body = body self.character = character if self.body >= '中等' and self.mold == '食肉类型' and self.characte...
c9a639a825435e9d1de470b78932fef03d6ea324
luckintt/caculator
/compute.py
5,585
3.6875
4
import re op = ('+','-','*','/') def inputFormat(expression): i = 0 if expression.count('(') != expression.count(')'): # 左右括号的数目不一致 return False while i < len(expression): if i == 0: if expression[i].isdigit() == False and expression[i] != '(' and expression[i] != '-...
f54be361051cbd9c5d6cff1c05f745df78edf61e
ChristineWasike/Advanced-Algorithms
/longest.py
398
4
4
# Take 2 strings s1 and s2 including only letters from ato z. # Return a new sorted string, the longest possible, # containing distinct letters - each taken only once - coming from s1 or s2. ##### # a = "xyaabbbccccdefww" # b = "xxxxyyyyabklmopq" # longest(a, b) -> "abcdefklmopqwxy" # a = "abcdefghijklmnopqrstuvwxyz"...
1ba4deb4daf175538ebc3491d3fad563f20e3026
barseghyanmher/HTI-1-Practical-Group-1-Mher-Barseghyan
/Homework_3/exercise_3_1.py
325
3.75
4
def missing_num(nums): max_num = max(nums) lst = list(range(max_num + 1)) if sum(nums) == sum(lst): missed_num = max_num + 1 else: missed_num = sum(lst) - sum(nums) return missed_num numbers = [int(i) for i in input("Enter N-1 numbers whit space :").split()] print(missing_num(numbe...
4fc95e4391dddac7a54da9841cdac8b62b2f8072
barseghyanmher/HTI-1-Practical-Group-1-Mher-Barseghyan
/Classwork_1/triangl.py
361
4.1875
4
a = int(input("Enter a number :")) b = int(input("Enter a number :")) c = int(input("Enter a number :")) if a >= b and a >= c: c,a = a,c elif b >= a and b >= c: b,c = c,b if c>= a + b: print("Not a triangle") elif c*c == a*a + b*b: print("Right triangle") elif c*c < a*a + b*b: print("Acure triang...
5a036cb3a1dc4b5292feb82e29b91e22cfa9acb7
barseghyanmher/HTI-1-Practical-Group-1-Mher-Barseghyan
/Homework_2/exercise_1.py
162
4.21875
4
def uppercase(): check_word = word.isupper() return check_word word = input("Input a text :") if uppercase(): print("Yes") else: print("No")
ce889f6f244e8582424f6db1bd964fc60c61a916
barseghyanmher/HTI-1-Practical-Group-1-Mher-Barseghyan
/Classwork_1/is_leap.py
254
3.90625
4
year_num = int(input("Your Birth Year :")) if year_num % 4 != 0: print("No") elif year_num % 4 == 0 and year_num % 100 != 0: print("Yes") elif year_num % 4 == 0 and year_num % 100 ==0 and year_num % 400 ==0: print("Yes") else: print("No")
4666df03289583063ab96acf818572d98bab1c71
kavin525zhang/leetcode
/source_code/283.移动零/mine_v2.py
576
3.65625
4
from typing import List class Solution: def moveZeroes(self, nums: List[int]) -> None: """ Do not return anything, modify nums in-place instead. """ count = 0 if len(nums) > 1: i = 0 while i < len(nums): if nums[i] == 0: ...
b622acece6a2f1cd18bad3348b00f04bbe8f6fec
AnthonyKang/ece404
/Finite_Fields/test.py
259
3.609375
4
import sys FILEOUT = open(sys.argv[1],'w') num = int(raw_input("Please enter a number less than 50: ")) for i in range(2,num): if i % num == 0: print('ring') FILEOUT.write('ring') break else: print('field') FILEOUT.write('field') FILEOUT.close()
9b548afd8bcc7e368781cf0c9ffd4f63745a07b1
den01-python-programming-exercises/exercise-4-26-numbers-from-a-file-JaimePSantos
/src/exercise.py
538
3.765625
4
def main(): #write your code below this line fileName = input("File?") lowerBound = int(input("Lower bound?")) upperBound = int(input("Upper bound?")) noNumbers = 0 try: with open(fileName,'r') as f: lines = f.read().splitlines() for number in lines: if int(number...
ea5d56c7bd0a0b8c134456e1e63612d865ec53e5
Guillermo-Arjona/githubtarea1
/Tarea1.py
3,619
3.84375
4
import sqlite3 BASE_DE_DATOS = "diccionario.db" def obtener_conexion(): return sqlite3.connect(BASE_DE_DATOS) def crear_tablas(): tablas = [ """ CREATE TABLE IF NOT EXISTS diccionario( id INTEGER PRIMARY KEY AUTOINCREMENT, palabra TEXT NOT NULL, significado...
fb8c35f57f98c80fe0afa3ac07e8a2d472b09f2b
starcigi/MyProjectPythonLearn
/jiaohuan.py
177
3.734375
4
member = ['张贻辉','狗','李宗彬'] print(member) member.insert(0,member[len(member)-1]) member.append(member[1]) del (member[1]) del (member[len(member)-2]) print(member)
969e52e2aba158a82d26362c143fee7bafdd824c
starcigi/MyProjectPythonLearn
/xunhuan2.py
296
3.9375
4
print('============RESTART=============') num = input('请输入一个整数:') star = int(num) while star: i = star - 1 while i: print(' ', end = '') i = i - 1 j = star while j: print('*', end = '') j = j - 1 print() star = star -1
03ccdb618105c687f67a7065f41e700f8b4470db
gibbs-shih/stanCode_Projects
/stanCode_Projects/Breakout Game/breakout_extension.py
2,609
3.78125
4
""" stanCode Breakout Project Adapted from Eric Roberts's Breakout by Sonja Johnson-Yu, Kylie Jue, Nick Bowman, and Jerry Liao This program runs a classic breakout game. """ from campy.gui.events.timer import pause from breakoutgraphic_extensions import BreakoutGraphics FRAME_RATE = 1000 / 120 # 120 frames per sec...
7dab3037afa1f2cf84dd957060a094840efe7308
gibbs-shih/stanCode_Projects
/stanCode_Projects/Weather Master/quadratic_solver.py
1,207
4.5
4
""" File: quadratic_solver.py ----------------------- This program should implement a console program that asks 3 inputs (a, b, and c) from users to compute the roots of equation ax^2 + bx + c = 0 Output format should match what is shown in the sample run in the Assignment 2 Handout. """ import math def main(): ""...
9139e03d276b2d33323343e59a2bf01ad9600911
gibbs-shih/stanCode_Projects
/stanCode_Projects/Hangman Game/similarity.py
1,801
4.34375
4
""" Name: Gibbs File: similarity.py ---------------------------- This program compares short dna sequence, s2, with sub sequences of a long dna sequence, s1 The way of approaching this task is the same as what people are doing in the bio industry. """ def main(): """ This function is used to find the most sim...
677e4b731e6d2fc976fdb6abaf103191eed14e29
karthikpala/Python-tutos
/programs/sample.py
5,552
3.5625
4
#%% [markdown] # # # Programming is fun # # ## introduction to python # # Before getting started, lets get familiarized with the language first. # # Python is a general-purpose language. It has wide range of applications from Web development (like: Django and Bottle), scientific and mathematical computing (Orange,...
04c3866dffd76be57803ed83ffcbcbe0d8184645
karthikpala/Python-tutos
/programs/print.py
942
4.0625
4
print(''' print(*objects, sep=' ', end='\\n', file=sys.stdout, flush=False) ''') print(1,2,3,4) # Output: 1 2 3 4 print(1,2,3,4,sep='*') # Output: 1*2*3*4 print(1,2,3,4,sep='#',end='&') # Output: 1#2#3#4& print('I love {0} and {1}'.format('bread','butter')) #print('Hello {name}, {greeting}'.format(greeting = 'Goodmo...
e491da332b6de4780066c1b3468c5b9019762753
feliska/python3_netology
/homework_cookbook.py
1,726
3.59375
4
import json with open("cook_book.json", 'r') as cook: cook_book = json.load(cook) def get_shop_list_by_dishes(dishes, people_count): shop_list = {} for dish in dishes: for ingredient in dish['ingredients']: new_shop_item = dict(ingredient) # пересчи...
4468de91bbfa7aa8b2e3a2020801fde2fb414773
NaNoFernando/pregunta_1_segundo_examen_inf_354
/python_Caminante/utils.py
2,570
3.515625
4
from ciudad import Ciudad import csv import random from ruta import Ruta from copy import deepcopy def generate_cities( city_count:int,minx:int,miny:int,maxx:int,maxy:int ): cities=set() with open("cities.csv",encoding="utf8") as readable: reader=csv.reader(readable) for raw_city in reader:...
290305ec63f3b95070b5a52eaa27de91d68b1653
xxks-kkk/old_web
/fperez.org/mkthumb
870
3.546875
4
#!/usr/bin/env python """Make a thumbnail for each file listed at the command line. Usage: mkthumb file1 file2 ... Simply calls ImageMagick's convert with a fixed width (250px). """ from __future__ import print_function import os import sys # Width of the thumbnails, hardcoded for now width = 250 # Set of for...
d17c126332f252da0eda996267391c4dcaf8bc87
takisforgit/Projects-2017-2018
/minimal_hanoi-V4.py
4,416
4.3125
4
#!/usr/bin/env python3 """ turtle-example-suite: tdemo_minimal_hanoi.py A minimal 'Towers of Hanoi' animation: A tower of 6 discs is transferred from the left to the right peg. An imho quite elegant and concise implementation using a tower class, which is derived from the built-in type list...
0619ec96483920be456730016ece7f7ef5b3ed57
takisforgit/Projects-2017-2018
/hash-example1.py
2,939
4.1875
4
import hashlib print(hashlib.algorithms_available) print(hashlib.algorithms_guaranteed) ## MD5 example ## ''' It is important to note the "b" preceding the string literal, this converts the string to bytes, because the hashing function only takes a sequence of bytes as a parameter ''' hash_object = hashli...
983d2123866c5a7a4b3dac59a4ffbb2f1afd4a1d
marx-saul/random_walk
/simulate14.py
1,657
3.5
4
import matplotlib.pyplot as plt import numpy as np import random import copy import sys INF = -1 Going = 0 PlayerLose = 1 MasterLose = 2 MAX_TIME = 2 * 10**3 MAX_SIM = 2 * 10**3 class Game: # money, money, probability of player winning def __init__(self, player = 20, master = INF, p = 0.50): self.pla...
c3a49470faa2ee114133334b0607c0fc3decf5d1
nickpeters741/alx-higher_level_programming5
/0x04-python-more_data_structures/2-uniq_add.py
135
3.765625
4
#!/usr/bin/python3 def uniq_add(my_list=[]): nums = set(my_list) sum = 0 for i in nums: sum += i return sum
496b844ee91254645533d4b44980bdd1a11157be
olamug/tkinter_workshop
/first_file.py
1,445
3.921875
4
import tkinter from tkinter.colorchooser import * def color_label(lab): color = tkinter.colorchooser.askcolor(parent=top) # parent to jest przypisanie, że chodzi o top-główne okno print(color) lab.configure(bg=color[1]) top = tkinter.Tk() top.wm_title('Hello...') top.resizable(width='false', height='f...
1c1be73bf2b33e63a7931465c715160bc8a16c0b
zahcaryanstey/images
/HT29 Models/HT29CSV.py
2,080
3.796875
4
""" This is a script used for the augmentation of the data given in the text files. For the use of labeling in a deep learning model we want to table to look like Cell # | file name | nucelus diameter | cell diatmer | NC | the steps involved in this process is 1) import pandas 2) read the cell diameter txt file 3) read...
4857270fea8ce8efc6aa51a90bb1091629e6cdb6
AzureCloudMonk/Python-Networking-Cookbook
/ch01/convert_variables.py
206
4.03125
4
the_age = input("What's your age?: ") age_as_num = int(the_age) age_as_num = age_as_num + 10 age_as_text = str(age_as_num) print("Your age + 10 is " + age_as_text) print(f"Your age + 10 is {age_as_num}")